Temperature sensor for Home Assistant
- jfdesignnet
- Electronics , Iot
- April 8, 2020
The world has changed a little bit in the past couple of weeks/months depending on where you live with a global pandemic currently on-going, meaning more and more of us are currently spending a lot more time indoors that we would either like or are used to thanks to the Coronavirus/COVID-19 situation.
Now that many of us have much more free time on our hands than we perhaps normally do, we thought it was the perfect time to get round to some of those projects that have been on back burner for a while!
I just found out the tiny bmp180 sensor under my stash drawer (tbh, I cannot remember why or when I buy this little sensor) and want it to use as a temperature sensor for my bedroom.
It’s really a tiny sensor with low-cost sensing solution for measuring barometric pressure and temperature. Because pressure changes with altitude this can also be use as an altimeter. noice … I already had some dht22 temperature sensor that I use for my living room and outside temperature sensor on my patio and also already integrate that with my home assistant, so this bmp180 will be a good addition to those sensors collection.
Hardware
The hardware wiring is pretty simple since it’s only 2 components and it’s using i2c protocol and here is the table wiring :
WEMOS D1 MINI | BMP180 |
---|---|
3v3 | Vcc |
Gnd | Gnd |
D1 | SDA |
D2 | SCL |
I put bmp180 sensor into a small protoboard shield for Wemos D1 because I already have it, not because it needs to. The jumper connection is underneath the protoboard and it looks like this when it’s ready :
For power supply, usually I use a small 220VAC to 5VDC isolated stepdown converter like this for all my iot device :
It’s pretty small and reliable since it runs without troubles for many years on me, but for this bedroom temp sensor, I have plan to put it on my near bed shelf that already have 10 ports usb charger and it’s free so I don’t integrate the psu on this iot sensor.
Software
On software part I’m using ESPHome for all IoT device on my home since I want to control over it using home assistant platform. Quick creating the config yaml for this sensor and it’s ready for flash, like this :
esphome:
name: jfbmp180
platform: ESP8266
board: d1_mini
wifi:
ssid: "<ssid-name>"
password: "<wifi-password>"
mqtt:
broker: '<mqtt-broker>'
username: '<mqtt-uid>'
password: '<mqtt-pwd>'
# Enable logging
logger:
# Enable Home Assistant API
api:
password: '<ha-api password>'
ota:
password: '<ota-api-password>'
i2c:
sda: D1
scl: D2
scan: True
id: bus_a
sensor:
- platform: bmp085
temperature:
name: "Bedroom Temperature"
pressure:
name: "Bedroom Pressure"
update_interval: 60s
Run ESPHome and upload it to Wemos D1 mini :
Excellent!
Now head into Home Assistant and configure it via integrations. Once added the temperature will show up :
I also refresh the home assistant on my smartphone the bedroom temperature is shown up :
It also can be monitored directly from mqtt subtopic payload, here I use MQTT Dash :
Wrapping up
Now I have a working temperature sensor that I can use to control my Air Conditioner smartly or just generally keep an eye on the temperature all from within Home Assistant.
Ok, that’s it for now, and while it’s still related, for you who know how to code and trying to be useful amidst this lockdown season, you may try to help fix bugs on Debian Med Covid site The Debian Med team is inviting programmers to a virtual COVID-19 Biohackathon from April 5-11, 2020. The Debian Med team wants your help in improving free and open-source biomedical software programs, tools and libraries. If cannot, it’s ok, just be nice to each other and stay home.
Hope you are all keeping safe and well amidst the Coronavirus pandemic. See ya.