Skip to content

Instantly share code, notes, and snippets.

@Eibwen
Last active March 27, 2021 08:02
Show Gist options
  • Save Eibwen/00f5b72ed28ac4eef3aa271ac80461f9 to your computer and use it in GitHub Desktop.
Save Eibwen/00f5b72ed28ac4eef3aa271ac80461f9 to your computer and use it in GitHub Desktop.

Sonoff Basic R3 DIY Mode (LEAST STEPS METHOD, no weird apps, no weird exe files)

Using a sonoff wifi switch, in DIY mode (no flashing required), and octoprint to automatically turn on/off a 3d printer!

Basically just step 2 of this (all the rest can really be ignored): https://tasmota.github.io/docs/Sonoff-DIY/

  1. Follow instructions how to enter DIY mode from Sonoff. This is the excerpt from it:
  1. Long press the button for 5 10 seconds to enter pairing mode, then press another 5 10 seconds to ender Compatible Pairing Mode (AP). The LED indicator should blink continuously.
  2. From mobile phone or PC WiFi setting, an Access Point of the device named ITEAD-XXXXXXXX will be found, connect it with default password 12345678
  3. Open the browser and access http://10.10.7.1/
  4. Next, Fill in WiFi SSID and password. Once successfully connected, the device is in DIY mode.

That didn't work on my cellphone, but did work on my computer. Maybe I should have disabled cell data on my cellphone when trying it???

(Optional) shitty api documentation: https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/other/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v1.4.md

Use this octoprint plugin: https://github.com/kantlivelong/OctoPrint-PSUControl

With the system commands of (Replace your deviceId and sonoff_ip): curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "{deviceId}", "data": { "switch": "on" }}' http://{sonoff_ip}:8081/zeroconf/switch

and

curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "{deviceId}", "data": { "switch": "off" }}' http://{sonoff_ip}:8081/zeroconf/switch

So I believe there is no security risk in sharing my example:

curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "100108297b", "data": { "switch": "on" }}' http://192.168.0.189:8081/zeroconf/switch

and

curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "100108297b", "data": { "switch": "off" }}' http://192.168.0.189:8081/zeroconf/switch

TODO

Figure out a command for sense. Needs to have exit code 0 == on, 1 == off (per https://github.com/kantlivelong/OctoPrint-PSUControl/wiki/Settings#sensing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment