I wanted to monitor internal and external temperatures as part of my home automation, so I decided to use Wemos D1 mini boards for this, running Tasmota, as they are small, feature rich and really inexpensive (about $2 each).
The Wemos D1 mini is a fully functional ESP8266 board with built in WiFi antenna, 11 GPIO pins that support protocols like SPI & I2C, an analog input and USB interface. There are also many shields that provide lots of different features like temperature sensors, OLED Screens, Relays, LEDs, etc. You can buy the boards and shields on AliExpress. I particularly like the OLED displays and the temperature sensor board.
I initially designed a custom PCB for the old ESP01 development boards, which contained a USB to 3.3v power supply and space for a DS18B20. However, most of the ESP01 boards only have 512kB of Flash which is too small to easily enable over-the-air updates for the firmware. So, I quickly switched to the Wemos D1 Mini boards instead.
Although it is trivial to attach a 1-wire DS18B20 temperature sensor to the Wemos, a shield makes the wiring neater.
The Wemos SHT30 Temperature Shield contains a SHT30 sensor, which provides accurate temperature and humidity readings over an I2C interface. Configuring the temperature sensor in Tasmota is trivial. Just configure the I2C pins in the admin interface and temperature and humidity is displayed on the home page.
The Tasmota code automatically searches for all connected I2C sensors when it boots and displays anything it finds. You do not need to tell Tasmota which sensor it is. A full list of support sensors in Tasmota can be found here.
Note: To get sensor support you will need to flash the devices with the tasmota-sensors.bin binary, instead if the generic tasmota.bin file. Sensor support was recently moved into its own binary to make the default binary smaller.
Reading the data – HTTP
You can query the data directly over HTTP using the url :
(Substituting for your IP number)
The response is a JSON structure containing all the sensor data.
On a Raspberry Pi you can extract raw data values using jq to navigate the JSON Structure.
curl -s http://192.168.1.20/cm?cmnd=status%208 | jq '.StatusSNS."SHT3X-0x45".Temperature' 18.1
Note: you must encase the “SHT3X-0x45” in double quotes. It is an artefact of the jq library, it does not like the -0x in the middle of the sensor name. I don’t really know why … it works fine for sensors that don’t have funny characters in the middle. E.g. ‘.StatusSNS.MAX31855.ProbeTemperature’)
Reading the data – MQTT
You do not need to read the temperature directly from the device if you are using MQTT. By default Tasmota automatically sends “Telemetry” messages out over MQTT every 5 minutes containing all the sensor data, which can be received and processed by NodeRed.
An example MQTT “TELE” message:
I configured a dashboard gauge in NodeRed to show the temperature data in real time for my internal and external temperature sensors.
The function to extract the payload strips all the other information from the message and just returns the value in the payload ready for the dashboard gauge to display.
msg.payload = msg.payload["SHT3X-0x45"].Temperature; return msg;
Voila a simple, real-time, temperature gauge on my phone over MQTT.