HomeHome AutomationSonoff R3 DIY mode & why it sucks

Sonoff R3 DIY mode & why it sucks

Sonoff R3 DIY mode is here and... it's pants!

Sonoff Basic line just got upgraded. You can now purchase Sonoff Basic R3 and Sonoff RF R3. Both devices are compatible with DIY mode, something I mentioned a while back. I finally got the devices shipped to me so I can test the Sonoff R3 & DIY mode. I noticed that people praise the Sonoff DIY mode for completely wrong reasons. A closer look is needed. Thankfully Sonoff DIY 2.0 is out and made things better!

Sonoff Basic R3 & Sonoff RF R3

It’s hard to tell which one is which

If you are running firmware version 3.4 and below, you can use Sonoff DIY mode on R3 series devices equipped with a physical jumper, as of April 2020 firmware 3.5 version supports Sonoff DIY 2.0.

Both devices are basically the iterations of well known and respected Sonoff Basic which is an ESP8266 based relay. Sonoff devices are popular among the makers, as come with exposed GPIOs (often extra ones) and are flashable with Tasmota (flashing Sonoff Basic) and AFE Firmware (using AFE Firmware).

Sonoff Basic R3:

  • Max Current: 10A;
  • Max Power: 2200W;
  • Power Supply: AC 100-240V;
  • Gang: 1;
  • Wireless Standard: IEEE 802.11 b/g/n 2.4GHz;

Sonoff RF R3:

  • Max Current: 10A;
  • Max Power: 2200W;
  • Power Supply: AC 100-240V;
  • Gang: 1;
  • Wireless Standard: IEEE 802.11 b/g/n 2.4GHz, 433.92MHZ;

Buy Sonoff Basic R3

Buy it using these links to support NotEnoughTech.

The internet is impressed with R3 DIY and the ability to push the Tasmota or AFE Firmware via OTA, I’m not that bothered mainly, because I could probably flash the chip quicker in a traditional way then faffing about with Sonoff R3 plagued with the issues listed below.

What made the Tasmota and AFE Firmware popular was the API access to the sonoff device (MQTT and REST) and exposed pins which could be used as LED drivers, temp sensor hook-ups and much more. Sonoff R3 DIY already provides you with REST API that can be used with NodeRED and HA (offline) which makes the entire operation slightly pointless if you are not going to take the advantage of the extra features offered by the custom software.

Firmware update issues

I guess it’s off to a bad start, both devices caused issues during the firmware update. The progress halts on 90% and refuses to move any further. Fortunately, there is a way to bypass this issue, although it’s a rather bizarre one!

Solving firmware update issues
To upgrade the firmware, create a hotspot with another device (yes, you will need another phone) remove the device and connect your Sonoff R3 to that hotspot. Then run the firmware update. On one of my units, the firmware did not show as updating, but the firmware update has been completed and I could see the new firmware version once the Sonoff R3 had been rebooted.

Why Sonoff R3 DIY mode sucks

Use the supplied jumper to enable DIY mode

To “enable” DIY mode, you have to put the jumper on the designated pins on the Sonoff R3 board. Since this is a hardware implementation, it means that you won’t see the DIY mode on other than “enabled” devices. That’s rather disappointing for anyone hoping to use Sonoff DIY mode on older devices.

Take extra care when opening Sonoff R3. The button with the long actuator is prone to accidental damage. Sonoff R3 shell consists of 2elements – remove one by one to decrease the risk of breaking the button.

Unfortunately, this is not over. When Sonoff R3 is powered on while the jumper is installed, it will try to connect to the following WiFi credentials:

SSID: sonoffDiy
Password: 20170618sn

To change this, you will need to create a hotspot with these credentials on your phone (or use the guest network if your router supports it), then download the special DIY tool on your computer. Note that both, Sonoff R3 and DIY Tool have to be on the same network.

I’m not sure why such a convoluted way to something so simple, but I decided to roll with it. I changed the WiFi credentials and I could use this cumbersome tool to toggle the status ON and OFF. It was time to see if I can issue commands.

At first, the official documentation was very poor. I had to use WireShark and Fing app to figure out the port that is open on Sonoff R3: 8081, but despite knowing that and the path (/zeroconf/switch) for a POST request, neither of my requests were accepted. I struggled to send the requests until a new version of the firmware got released (3.3.0). Since then the docs have been updated a fair bit and they are finally useful.

But the worst thing is…

My assumption was that I use the Sonoff R3 DIY mode to submit POST request without losing the eWeLink integration. It’s something that Yeelight Smart Bulbs do incredibly well. You can use the REST API and take advantage of the app and all available integrations at the same time.

Can you do the same with Sonoff R3 DIY mode?

NO

As soon as you activate the DIY mode the device becomes not responsive in the eWeLink app and you no longer can use it, even if you select LAN mode. Now that sucks!

Controlling Sonoff R3 in NodeRED

Since I have the Sonoff R3 DIY mode enabled, I will show you how to get the basics done in NodeRED if you want to use that instead of actually getting the flash done.

Once you have the DIY tool working, start with changing the SSID and password so the Sonoff R3 was on the same network as the rest of the home automation. Since we are dealing with REST API we will need the IP of the device to send the request to. Sonoff R3 hosts a server using port 8081 and the available URLs are:

  • /zeroconf/switch (change status)
  • /zeroconf/info (get device info)
  • /zeroconf/startup (initial power state)
  • /zeroconf/signal_strength (WiFi signal strength)
  • /zeroconf/pulse (inching setting)
  • /zeroconf/wifi (set WiFi setting)
  • /zeroconf/ota_unlock (OTA unlock status)
  • /zeroconf/ota_flash (flash OTA firmware)

A sample of the correct URL for the API calls:

http://192.168.1.12:8081/zeroconfig/info

Since you need the device ID and the device IP to configure the REST request, I have written a tiny configurator. Just enter these details in the inject node and these will be saved as your flow variables. Make sure you have the variables preserved, so you don’t have to inject it every time your NodeRED reboots.

I have formatted the request so you can simply inject different types of payload and topic configuration. The response is a JSON formatted payload.

Getting the info

To get the information, submit the payload to the URL: http://192.168.1.12:8081/zeroconfig/info

{"deviceid": "yourdeviceid", "data":{}};

And you receive the status update that contains the most useful info about the Sonoff R3 status and the current configuration:

{"seq":2,"error":0,
     "data":{"switch":"on",
             "startup":"on",
             "pulse":"off",
             "pulseWidth":2000,
             "ssid":"SlowFrog",
             "otaUnlock":true}}

Toggle the switch

To turn the Sonoff R3 on/off simply submit the correct value to the URL: http://192.168.1.12:8081/zeroconfig/switch

{"deviceid":"10008xxxx",
 "data":{"switch":"off"}}
OR
 {"deviceid":"10008xxxx",
 "data":{"switch":"on"}} 

The response will contain the number of the request and the error code.

{"seq":3,"error":0}

Inching settings

Inching emulates a “long press of a push-button”. This will enable the relay for a short time then automatically turn the relay off. To use the setting you have to enable it and provide the pulse duration in ms (and increments of 500) in the range of 500 – 36 000 000. (0.5 sec – 10h). Submit the values to URL: http://192.168.1.12:8081/zeroconfig/pulse

{"deviceid":"10008fxxx","data":{"pulse":"on","pulseWidth":2000}}
OR
{"deviceid":"10008fxxx","data":{"pulse":"off"}}

Startup status

You can configure the “power-up” state of your Sonoff R3 and set it to ON|OFF|STAY to preserve the previous value. Submit the payload to URL: http://192.168.1.12:8081/zeroconfig/startup

{"deviceid":"10008fxxx","data":{"startup":"on"}}
OR
{"deviceid":"10008fxxx","data":{"startup":"off"}}
OR
{"deviceid":"10008fxxx","data":{"startup":"stay"}}

WiFi signal and settings

To monitor the WiFi signal and receive the strength of the link, submit the payload to URL: http://192.168.1.12:8081/zeroconfig/signal_strength

{"deviceid":"10008fxxx","data":{}}

And the response will contain the value in dB:

{"seq":6,"error":0,"data":{"signalStrength":-67}}

If you want to change the WiFi credentials submit your new credentials to URL: http://192.168.1.12:8081/zeroconfig/wifi

{"deviceid":"10008fxxx",
 "data":{{"ssid": "yourSSID", "password": "yourPASS"}} 

OTA commands

You can also unlock the Sonoff R3 and push the new firmware to it. Yes, it’s possible to load Tasmota or AFE firmware this way, but I would still recommend you to make the back up of the original one just in case. Once the firmware is overridden, you won’t be able to go back without that image. To unlock submit the payload to URL: http://192.168.1.12:8081/zeroconfig/ota_unlock

{"deviceid":"10008fxxx","data":{}}

To flash new firmware, use URL: http://192.168.1.12:8081/zeroconfig/ota_flash and push the correct firmware details:

 {"deviceid":"10008fxxx",
 "data":{"downloadUrl": "http://192.168.1.112/ota/firmware.bin",
         "sha256sum"  : "123sa32s1da2354f9874fewsd21s6afd49wf4wefs1df59"}} 

I would still recommend you to go through the method of flashing Sonoffs detailed here.

Conclusion

Sonoff R3 DIY mode is disappointing. The clunky implementation, unreliable ways of updating the firmware and inability to use the eWeLink app alongside the REST API makes this mode hard to recommend over flashing Tasmota or AFE Firmware.

I will simply flash Tasmota or AFE Firmware and enjoy the redesigned hardware my way. I’m pretty sure you will appreciate the tutorial describing just that. If you have any questions or comments, feel free to use this Reddit thread.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.