ePrivacy and GPDR Cookie Consent by TermsFeed Generator Home Automation System - Temperature sensor with SONOFF mini - Software setup | IoT - smartHome | DomoticsDuino - Computer engineer, Smart Home, Flight Sim and others...
IoT - smartHome (181 posts)


Home Automation System - Temperature sensor with SONOFF mini - Software setup [Versione in italiano]

by Marco Lamanna

After some times testing my new "Tasmoted" SONOFF mini (see previous post) I take a small step forward, studying how to interface it with a temperature sensor, as already done with other SONOFF products

My choice went on DHT11 temperature / humidity sensor the, as we already known it's fully compatible with TASMOTA firmware. This sensor is not very accurate but for my targets it's ok...and very cheap

The first thing to do is to take a look at available GPIO on SONOFF mini and let's find which of them are available on TASMOTA, using SONOFF Basic module. So let's have a look at the web management module and select CONFIGURATION -> CONFIGURE MODULE looking for DHT11 device.

Unfortunately I noticed the DHT11 device doesn't exist. Yes, because I flashed TASMOTA Lite, which has only a subset of sensors

First unexpected thing: this firmware is not usable but I cannot flash with TASMOTA standard or TASMOTA sensors because SONOFF mini has not enough available space in OTA mode. I have to flash sonoff "minimal" and then the desidered firmware. What can I do? After some research, I decided to customize TASMOTA. What's the meaning of this? In simple words I will edit source code to generate a custom firmware. So, I downloaded TASMOTA source code and, based on Lite version, I will find a way to use DHT11. Before this, I have to choose my development suite... Taking a look at TASMOTA online documentation . I decided to use Visual Studio Code (which already I know), with PlatformIO plugin.

Before compiling the source code, you need to configure the environment so that a TASMOTA custom firmware, completely similar to the Lite version but with the addition of the DHT11 device, will be generated. It requires some changes to the downloaded files. In particular, we have to tell to compiler what kind of release it must build (Tasmota Lite in this case) editing platformio_override.ini file, commenting on the "tasmota" line and uncommenting the "tasmota-lite" line, in the platformio section

Well, now we can add DHT11 sensor. In tasmota_configurations.h file you have to look for a row with #ifdef FIRMWARE_LITE to get the code block used to enable/disable devices based on your target.

Then, after found the right code block, you have to comment on the #undef USE DHT row. In this way DHT11 sensor will be included in the firmware.

Here we are! Next step is to perform a full build (hoping no errors will be raised) and flash the generated file on the SONOFF Mini, as a standard firmware. To run the build you can use the button in the bottom-left bar of visual studio code

After updating the firmware the DHT11 magically appeared in the configuration comboboxes.

Well, now it's time to prepare our SONOFF Mini to perform some test.

Stay tuned