Example working SONOFF OTA and Blynk code

I’ve been working for some while with SONOFF basic devices, have a fairly well-developed sketch posted now on Github

I’m using the Blynk_WiFIManager from @khoih , some terrific and simple OTA code from Andreas Spiess (YouTube’s Guy with the Swiss Accent). The sketch uses 4 Blynk Widgets for ON/OFF, a heartbeat, a label showing what’s being switched, and an optional/hidden text entry for changing the label.

The sketch supports multiple SONOFFs with simple compiler switch changes. It uses a state machine to test if the SONOFF actually switched and reports that state. It even still fits onto a SONOFF! There’s a README to explain more.

Just sharing. All comments welcome.

1 Like

A couple of comments…

Your GitHub list of requirements makes no mention of installing the ESP core.

The Blynk library needs to be 0.6.x (as opposed to 1.0.0-beta.x which is catching a lot of people out at the moment)

This statement is rather confusing:

Depending on where you are in the world, blynk-cloud.com should resolve to your local Blynk cloud server (unless your ISP is dong some odd things with DNS servers), so blynk-cloud.com is the url that needs to be used regardless of where you are in the world.

You list the Blynk widgets that are required, but you don’t explain in the readme file that the default virtual pins used for these widgets are defined in Blynk_WM_Template.ino and can also be set in the captive portal.

I think some users who aren’t familiar with C++ coding and want an ‘off the shelf’ solution may find this confusing?


1 Like

Thank you @PeteKnight for your helpful comments. I have updated the README at my GIthub repository to more completely describe the SONOFF sketch, its requirements and accompanying files.

I also removed a second sketch that may have caused confusion.

We agree that this should probably not be the first Arduino/Blynk sketch someone grabs. I learn from others, both basic and advanced, hope this is helpful to some.

Comments welcome, as always. Thanks again.

Big screen shot below…
ON/OFF buttons… Switch description… bllinking heartbeat for each of 6 SONOFFs
All controlled by same code using #compiler switches



6 posts were split to a new topic: OTA Update Strategy Discussion