temperature humidity and pressure meter to mqtt (bme280)

i wanted to log temperature and humidity values in my sons room as he caughed a lot during the first winter and we had to buy a humidifier. i therefore ordered a BME280 module off Aliexpress for $2.18 (i know, only the best for my kid ;)). The sensor actually mesures both temperature and humidity at a good accuracy and as a “free” bonus it also measures the airpressure.

my plan is to connect it to a wemos D1 mini and then publish the values via mqtt so i can log them in Home Assistant, Node Red, thingboard or somewhere else.

OpenMQTTGateway

first try was with the OpenMQTTGateway as i had the arduino IDE ready to go and the code configured and compiled from trying to set up an ble_mqtt_gateway which sadly did not work, probably due to a DOA module. however, read that article on setting up the OpenMQTTGateway software for flashing. for the BME280 to work you need to enable the ZsensorBME280 in User_config.h, the rest is identical.

the hardware wiring by default looks like this:

I2C Module NodeMCU / ESP8266
Vcc 3.3V
GND GND
SCL D1
SDAD2
ADD N/C (Not Connected

at least with this sensor it worked right out of the box and reported all sorts of measurements. i could track them using the serial console or via a mqtt client like so:

mosquitto_sub -h 192.168.168.1 -u myuser -P mypass -v -t home/#

i think OpenMQTTGateway is still rough around the edges, it works and all but for example the web interface to configure the device is only available if it can't connect to a wifi and therefore goes into setup mode.. this is not ideal as the mqtt parameters could also be managed in there.

so lets try also

Tasmota

also check out my detailed description for the sonoff setup. basically download the latest release and then copy the lib folder into your arduino sketchbook/libraries folder. then edit the my_user_config.h file and make sure the #define USE_BMP is enabled. also sest the #define MODULE to WEMOS. as a side-note: this will be called “Generic” in the web-interface but in the source code it's still called WEMOS.

the hardware setup looks like this (note, the scl and sda lines could be changed to match OMG for example or vice versa, however, i have it on a breadbord, so i simply changed the patch wires):

I2C Module NodeMCU / ESP8266
Vcc 3.3V
GND GND
SCL D4
SDAD3
ADD N/C (Not Connected

despite selecting the WEMOS module we still have to log into the web interface once the firmware is flashed and booted and go to Configuration –> configure module and then set D3 GPIO0 Button 1 to I2C SDA(06) and D4 GPIO2 to I2C SCL (05).

now you get a new reading every 5 minutes via MQTT. if you want to change this interval you can either do this in the my_user_config.h file or via mqtt or the “console” in the web interface by publishing this mqtt topic and value:

tasmota/sonoff/cmd/TelePeriod 30

this will set it to 30 seconds