- Health Is Wealth
- Posts
- [TUTORIEL] Reprogram Sonoff Dual R2
[TUTORIEL] Reprogram Sonoff Dual R2
In this new tutorial, we will reprogram our Sonoff Dual R2 so that we can integrate it into our Jeddom. And little surprise, we will add a temperature / humidity sensor to it. If you want to know more about the Sonoff Dual R2, do not hesitate to review our first presentation article.
As you probably know, Sonoff hardware is open source, which means you can easily modify it. We will use the Tasmota firmware for this.
Once done, we will have full access to the features. In this example, I will use it to control my electric shutters.
Reprogram Firmware
To reprogram the firmware, we will first download it from the GitHub. In the following, we will be helped by Atom software. To learn more about its installation and use, do not hesitate to review our first explanatory tutorial.
The most important thing in configuring Tasmota is to enter an IP address and the information of our WiFi access point. Because once the module is smart health connected to Wifi, we will finish the configuration directly on the Web console. We did the same thing with our Sonoff SC, it's faster and more convenient as well.
Well, let's go now to the hardware part, for that, we will disassemble our module by removing the screw on the front. This leaves us access to the electronic card, as we can see connections are available and labeled.
The first series of connections allows you to plug in a button if you want to keep a manual control. But the most important thing is that by connecting "Button 0”And“GND”Then by powering the module, we will be able to put the ESP8266 in programming mode.
The second series of connection allows communication and powering of the ESP8266, this is where we will connect our USB / Serial converter to reprogram the firmware.
The connections are made, the ESP8266 is in re-programming mode, we then upload our new firmware. And here is our Sonoff Dual R2 now working on Tasmota, now let's go to the configuration and adding the module in Jeedom.
Configure Tasmota on our Sonoff Dual R2
To configure the module, go to the Web console by entering the IP address previously provided before uploading.
We start by entering the module model, go to “Configuration”, “Module configuration”, then select “39 Sonoff Dual R2”.
And little bonus, to connect our DHT11 temperature / humidity sensor, we fill in “DHT11”In the serial output box. For connection, it's very simple, 5V> 5V, GND> GND and Signal> TX.
To ensure communication with our Jeedom in MQTT, go to “Configuration”, “MQTT Configuration”, and enter the connection information.
Very important little tip, here we are on a module that will manage the electric shutters. It is therefore imperative that at no time both relays be activated at the same time, this may destroy the shutter motor. To avoid this, we will switch the relays to “interlock” mode. This means that in any case, there cannot be more than one relay activated. Likewise when the module starts, we want all the relays to remain deactivated.
We go to the "console" and enter the command "SetOption14 on", then we verify the correct operation by activating the two relays, one of the two must deactivate itself. And for the start option, the command is "PowerOnState 0". To this we add “SerialLog off“, To disable logs on the serial port and not interfere with our DHT. Find these commands and many others directly on the Tasmota wiki, It's very well done.
That's it, it's over for the module, now let's go to our Jeedom.
Configure Jeddom to communicate using MQTT
On the Jeedom side, I use the "JMQTT" plugin here. Because it is capable of interpreting information in JSON format and transcribing it into unitary information. As soon as the first data arrives, we will check the box “parseJSON”And display only interesting information. And here we are with new tiles on our dashboard.
Conclusion
The re-programming and configuration only took 20 min. Thanks to this, we have regained full control of our module, which can now adapt to all of our needs.
The native integration with Jeddom via the MQTT standard is a big plus we can both receive and send instructions to our module. We can for example trigger the shutters, but also trigger a firmware update remotely.
But we will see that in a next article, see you soon.
AB SMART HEALTH health home & BUILDING REVIEW