One of the things I’ve been meaning to get for a while now was a Sonoff R3 Pro. Now for those of you not familiar with this device, it’s essentially a 4 channel smart switch. There’s a non-pro version and the pro version. I opted for the Pro version mainly due to the fact that it comes with inbuilt 433Mhz RF control, as well as the ability to handle higher loads. I thought I would write a quick post describing how I integrated it into my current setup.
First thing’s first, there’s no way am leaving this running Sonoff firmware. So Tasmota was the first port of call. Thankfully the pin out holes on the motherboard are just the right size for some dupont jumper cables. I know some like to solder on headers, but personally, I don’t like to solder anything if I can get away with it. I connected the jumpers to my USB FTDI programmer except the ground. You need to hold down the relay 1 button as you power it up so that the sonoff can go into flash mode (remember RX=>TX and vice versa). You’ll know if you’ve done it right because as you power it up, the Wifi led (blue) won’t flash on. I downloaded the latest version of Tasmotizer and fired it up.
Within seconds it had found the correct port and we were good to go. I elected to backup the original firmware first (note this .bin file will download automatically into the folder the tazmotizer.exe is located). I set the option to “release” (at the time of writing that’s Tasmota 9.2) and set it to go. A few moments later we were done. I must admit, i didn’t pay too much attention to tasmotizer, i’d used it a few times before, but the latest variants had the ability to send a config to the device (MQTT details, wifi SSID/Password etc). I hadn’t used that before, but I decided to give it a go.
On the module option at the bottom, I selected 4 channel sent the config across, waited a few moments and then hit the get-ip button. For some reason or another it didn’t work. It returned me the following XX.XX.XX.XX. It wasn’t an issue though, I checked my router’s IOT network and sure it enough, there was my r3 pro. I went to the website and tested the buttons, relays 1-4 were working as needed.
Next thng was to get it into Home-Assistant. Configuration->integration ->MQTT I clicked on the newly found r3 pro and added it to lovelace.
So far so good. The sonoff software supposedly allows for things such as Inching (closing the relay for X amount of time) and Interlocking where pressing 1 relay automatically turns off the rest. Am not quite sure exactly where the interlocking feature would come in to play, but I wanted to make sure I had the same capabilities. Enter Node-red. For those of you not familiar with using MQTT and node-red, might I suggest you take a look at the first post of my three part Node-red tutorial which can be found here.
First thing’s first, simple on/off of each relay via MQTT:
Next we send a command to output a full status report by sending a message of cmnd/r3pro/POWER0.
Then I wanted to look at Inching (timed closure), this was a simple case of using the trigger node. Change the time as per your requirements.i.e. send “true” to the relay and then after x amount of time send a new payload of “false” to switch the relay off.
Finally the missing part of the puzzle was interlocking. This could have been accompanied by sending several commands. i.e. turn relay 1 on, turn relay 2-4 off. Then rinse and repeat for the other relays. Whilst this would work perfectly well, I wsa searching only and found a simpler way of doing it, via the function node. I want to give credit for this piece of code to Matt from Notenoughtech. He has a cool youtube channel and a blog. See below for an example of one of the nodes.
Once I tested the first one, it was a simple case of rinse and repeat for the other relays, only varying which relay was going to become true.
So there we have it. One locally controlled 4 channel smart switch. I’m still trying to decide where to deploy this. At present, I’m thinking of the following potential usage cases:
- Outside garden lights – with four channels this could allow for certain zones and mood lighting to be deployed around the property.
- Garage controller – 1 channel for garage door control, 1 channel for main lighting, 1 channel for desk / focused lighting, leaving the last channel available for maybe a second garage door or additional outside lighting zone.
- Kitchen lighting – with 4 channels, you could have above and under cabinet lighting, as well as dual-main zone lighting.
- Aquarium or swimming pool control – lighting, pump, filter, heating
- Home-cinema control – Shades, projector screen, subwoofer control, zone lighting etc.
I’m a big fan of this small unit. for less than £30 you can potentially create a complete system. Let me know if you can think of any other cool ideas for this unit. The links below maybe affiliate, which mean they don’t cost you any extra, but help to support the blog if you’re interested in purchasing one of these units for yourself:
As a side point, if you enjoyed this type of content and would be interested in sharing your own solutions, tips and tricks with like minded people perhaps you’d consider joining our facebook group. The aim of this group will hopefully be more show and tell rather than support, but that’s not to say we can’t lend a helping hand 🙂