Flashing Tasmota on a Sonoff Dual R3 & Integrating With Home Assistant

PLC based appliance modules have been something of a staple in my house over the last 10 years and at recent count, I had 72 X10 appliance modules.

The challenges with X10 are pretty widely known but with the advances in X10, most of these challenges around reliability can be pretty easily solved.

Adding in JV Engineering’s excellent XTB-IIR which a high-power 2-phase X10 repeater eliminated basically all of my reliability problems and there is no need to use noise filters.

The XTB-IIR has two coupling networks to drive high power signals onto both phases. Its powerful transmitter delivers over 20 times the output power of typical X10 transmitters to greatly improve X10 automation system reliability.

But there are issues. X10 is a really old protocol, it is not duplex, meaning I can’t accurately deem module state if there is manual switching. Secondly, modules are becoming harder to come by, and lastly its lack of native integration without using a shim like HA-Bridge, allowing myself to wrap a HTTP or MQTT interface around these modules.

With everything considered I have been on a slow but steady march to rid my house of X10, and my weapon of choice has been Sonoff devices running a custom firmware, Tasmota.

From Sonoff Basics R2, R3’s though to Mini’s, flashing Tasmota on these Sonoff devices have been performed either OTA (Over The Air), or an easily accessible UART header on the PCB, via the python wrapper, Tasmotizer, kind of simple.

The Sonoff Dual R3 is the bees knees appliance module. It is small, provides power monitoring, is dual channel and has native support for external switches.

Dual switching with power monitoring


What’s there not to like? Well for starters, if you are Tasmota user, then flashing a custom firmware on this device is somewhat more complex, no Tasmotizer and no easily accessible UART headers 🙁

No UART headers accessible via standard pins


So in this post I will walk you through the process of flashing Tasmota on a Sonoff Dual R3 and interfacing with Home Assistant.

Tools used
– Hand Tools (Pliers, Cable Strippers, Screw Drivers)
– Solider and Cable
– Soldering Stand
– Soldering Iron
– Solder Sucker
– USB TTL (USB CH340)

Software Required
ESP Flasher (exe)
Tasmota.bin (ESP32 Sonoff DualR3 edition. After you have flashed Tasmota, you can perform OTA updates)
– MQTT Broker (this post will assume you have one already up and running in your environment)

WARNING Do not attempt this guide with the the Sonoff DualR3 connected to mains AC power. The USB TTL 3.3v is all that is required to power the ESP32 to which we will be flashing.

Step 1: Dissemble and Solider
Unlike other SonOff devices the Dual R3 does not support OTA updates, nor can you use standard headers. You will need to solider directly to the RX, TX, VCC (3.3V) and GND. If you are not experienced in soldering to PCB’s you may want to seek the help of someone more experienced or practice.

Take your time, when soldiering TX, RX and VCC as they very close to traces.

As GND is quite hard to solider (high risk), there is a capacitor that you can solider on to which is far more accessible and any GND will do.

GND is far left on a capacitor leg

Step 2: Flashing Tasmota
To enter flash mode you need to connect GPIO 0 to GND. The push button is GPIO 0 so holding this in as power is applied will place the device in to flashing mode.

Connect the Sonoff via a USB TTL, being sure to reverse the RX and TX pins

Sonoff DualR3USB TTL
3V3Vcc/3.3v
GNDGND
RXTX
TXRX
Using a cheap USB CH340

As the Sonoff Dual R3 is not based on an ESP8266, you can’t use Tasmotizer. It is based on the newer ESP32 as as such you need to use ESP Flasher. Open ESP Flasher select the port for your serial-to-USB adapter and your downloaded binary, make sure the Sonoff Dual R3 is in flash mode.

Within 2-3 minutes Tasmota will be flashed on the Sonoff Dual R3.

After the flashing is complete, reboot the device and connect to the Wifi Access Point running on the device and configure your WiFi details.

You will need to apply the following Tasmota template as Tasmota at the time of authoring(version 9.5.0) this post does not know about the Sonoff Dual R3.

{"NAME":"Sonoff Dual R3","GPIO":[32,0,0,0,0,0,0,0,0,576,225,0,0,0,0,0,0,0,0,0,0,7296,7328,224,0,0,0,0,160,161,0,0,0,0,0,0],"FLAG":0,"BASE":1}

You will then be able to connect to the IP address allocated by DHCP and you will be able to configure your device.

Configure your MQTT settings, specifically your MQTT Broker and MQTT Topic name.

MQTT settings

At this stage I would suggest wiring the device in to its final location as you now have IP connectivity to your Sonoff Dual R3. As this is AC power consult the rules and regulations in your jurisdiction, just remember AC voltage can be lethal.

Follow Sonoff’s wiring diagrams which will differ depending on your use case.

Sonoff Dual R2 wired with Clipsal 30PBL momentary LED switches

Step 3: Integration In To Home Assistant
For integration in to Home Assistant there are two methods to which you can use.

  • Configuration.yaml – You can define your switches directly in to you Home Assistant configuration file and you state and command topics will be based on your device topic name. You can use a tool such as MQTT Explorer to provide a structured overview of the MQTT topic
switch: 

  - platform: mqtt
    unique_id: your_unique_name
    name : "Your Friendly Name "
    state_topic: "stat/device_name/POWER"
    command_topic: "cmnd/device_name/POWER"
    value_template: "{{ value_json.STATE }}" 
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    qos: 2
  • HomeAssistant Tasmota Integration – After your define your MQTT settings, your device will start publishing messages to ‘tasmota/discovery’ with the devices name and a payload of its attributes and it’s capabilities.
Device attributes in MQTT explorer leveraging the built in Tasmota auto discovery topic

You can now leverage the Tasmota integration in Home Assistant which will detect your new device based on the auto discovery message published by the device on startup to ‘tasmota/discovery’

The device and its entities can now be added to LoveLace UI and added in to the relevant cards.

Summary
Whilst not providing information on a macro level, I hope this guide provides you some insight on how Tasmota can be flashed on a Sonoff Dual R3.

The Sonoff Dual R3 is more than just a basic smart switch, with power metering and other logging attributes, it provide you a plethora of information that will allow you to think big and create some pretty interesting automations.

I work for @Microsoft but opinions expressed are my own

Thanks
Shane Baldacchino

Leave a Reply

Your email address will not be published. Required fields are marked *