sonoff S26 didn't restart after an electrical power outage

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

sonoff S26 didn't restart after an electrical power outage

#1 Post by Gilles » 18 Mar 2025, 10:12

After an house electrical power outage , I have had to unplug it and plug again to make it work.

I don't use the SONOFF "button" .
It runs : mega-20231225

The relai device (GPIO 12) is configured with :
- Enabled is ticked
- Internal pullup is ticked
- Inversed Logic is not ticked

I have several rules to control it:

Code: Select all

on System#Boot do 
   gpio,12,1
//  gpio,13,1
//   TimerSet,8,37000

endon

On AL Do // http://192.168.1.49/control?cmd=event,AL
  gpio,12,1
EndOn

On ET do 
gpio,12,0
EndOn
I have a second SONOFF S20 with the same problem : It has not restarted (not pingable) and the raspberry pico connected to it was obviously switch off.

Any advice?
Thanks
Gilles

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#2 Post by TD-er » 18 Mar 2025, 10:55

I know there is some logic error in the WiFi related code when ESPEasy cannot find the configured access points.
In some cases, it is possible the ESP will end up in some situation where it thinks it doesn't have usable WiFi access points after a new scan as it already thinks those found were tried and tested.

I suspect your access points may not have been up-and-running when ESPEasy booted.

If it would be a usable option, I can assist you in writing some rules to power cycle the ESP when you were not able to connect to WiFi within X amount of time.

Another option can be to tick this checkbox on the tools->Advanced page:
"Restart WiFi Lost Conn"

This will completely turn off and on the WiFi when it is not possible to connect to WiFi and/or a WiFi connection is lost.
This does 'fix' some of the logic errors I mentioned.

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#3 Post by Gilles » 18 Mar 2025, 11:37

Unfortunately, it (Restart WiFi Lost Conn:) is already ticked on one of them.

But the two faulty are not connected to the same AP.
One is connected to the operator BOX (connected to Internet) and the second one is connected to a router Acher configured in brdge mode. May be the BOX takes time to be up after a power outage.
Idealy a 3 minutes delay would be nice. I could add a delay or a timer then reboot the sonoff.

Would be it possible to create this kind of rule which tests the wifi connection and reboots the sonoff if not?

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#4 Post by TD-er » 18 Mar 2025, 11:44

Sure it is quite easy to make such rules.

Something like this (untested)

Code: Select all

On System#Boot Do
  gpio,12,1   // Was already present in your own rules
  TimerSet,1,120 // 2 minute timer
Endon

on Rules#Timer=1 do
  reboot
endon


On WiFi#Connected Do
  TimerSet,1,0 // Clear timer
Endon

On WiFi#Disconnected Do
  TimerSet,1,120 // 2 minute timer
Endon
Make sure there is only one "On System#boot Do" section, so you may need to merge it with your own rules block where you set the GPIO-12.

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#5 Post by Gilles » 18 Mar 2025, 14:41

Thanks ,I will give it a try but I need to wait for the next outage :)

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#6 Post by TD-er » 18 Mar 2025, 14:44

You could let it connect to a different AP, for example a hotspot on your phone.
This is easy to keep 'offline'.
Just make sure you have something to detect what IP the node has when connecting to your phone so you can access the web interface to change WiFi settings.

Or as a test you can also power cycle your access point.

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#7 Post by Gilles » 25 Mar 2025, 06:55

I thought a little bit more to my issue and I think that the problem is not wifi related.
When the internet box reboots, the wifi is activated quickly but the Fiber connection is not yet up. It can take several minutes (up to 10). So, when the electrical power is up again,the Sonoff is connected to the wifi but not to internet.
Ideally, a "ping 1.1.1.1 ( or any public dns server)" rule for instance, would do the trick.
I went through the doc and found a ping plugin
https://espeasy.readthedocs.io/en/lates ... /P089.html
but I would need help to make it work (5 faulty pings -> sonoff reboot).

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#8 Post by Gilles » 25 Mar 2025, 08:04

I don't have this kind of device available 'Communication Ping).
I found this ino file : https://github.com/letscontrolit/ESPEas ... 9_Ping.ino
But I don't know how to add it to the sonoff.
I hope that I don't have to compile the mega-20231225 .

Thanks
Regards,

User avatar
Ath
Normal user
Posts: 4319
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sonoff S26 didn't restart after an electrical power outage

#9 Post by Ath » 25 Mar 2025, 08:27

The official list of plugins can be found here and that also shows the build where the plugin is included (Any COLLECTION build). Currently it's not compatible with ESP32 because of changes in the networking stack, so only available in ESP8266 builds. Adaption for ESP32 is on the TODO list.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#10 Post by TD-er » 25 Mar 2025, 08:40

Sonoff S26 is ESP8266 if I'm not mistaken.
Also it is probably one with 1M flash, right?
This makes it quite challenging regarding build size.

What other plugins and controllers do you need?

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#11 Post by Gilles » 25 Mar 2025, 17:22

I need to work on my design.

I have a pico which is connected to a moisture sensor . There is a loop every 5 minutes and when it is too dry, it triggers a relay(switch) which starts the watering for 20 seconds then back to the loop. The pico is protected by a sonoff S26(espeasy) just in case which actes as a switch.
For an unknown reason, after an electrical power outage, the sonoff remains off and so the pico and the watering has started and didn't stop. Fortunately I was at home so I have stopped it.
I need to think to an alert from the sonoff or from the pico ( telegram or automatic poweroff/on ).
I need to be sure that Internet is reachable.
I need to know if the pico is powered on.
I need to know if the pico relay is on for more than 5 minutes.

I need to be informed when something goes wrong.

So as you can see I need to work on the solution.
So no need for plugin or controller at the moment.
Thanks for your time. This forum is always very reactive.:)

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#12 Post by TD-er » 25 Mar 2025, 19:56

Just to be sure, what exact build are you now using?
So we know which flash size to use, etc.

The filename is shown in the lower right corner of each web page of ESPEasy and also on the sysinfo page, just in case your build is so old it doesn't have this shown in the corner of the page.

Also, if you're using an ESP8266 with 1M flash, you may need to flash any new build via the serial port of the device instead of update via the browser.

And just to be sure, when flashing such mains-powered plugs, make sure to never have it plugged into mains power when programming it via the serial port.

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#13 Post by Gilles » 25 Mar 2025, 20:32

My Sonoff s26 runs : Build: ESP_Easy_mega_20231225_normal_ESP8266_1M Dec 25 2023
I use to flash with FlashESP8266.exe . I select the COM port and the right bin file.

TD-er
Core team member
Posts: 9855
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sonoff S26 didn't restart after an electrical power outage

#14 Post by TD-er » 26 Mar 2025, 08:43

I made a custom build for you using the ping plugin.
https://www.dropbox.com/scl/fi/n0k5c1bk ... spnnf&dl=0
Can you test to see if it is working and has all you need included in the build?

If so, then we can help creating rules to detect if you have an internet connection.

Gilles
Normal user
Posts: 115
Joined: 21 Dec 2017, 11:09

Re: sonoff S26 didn't restart after an electrical power outage

#15 Post by Gilles » 26 Mar 2025, 09:29

Thanks for your help. I keep it in my mind . First I need to redeign the scenario ( sonoff +pico(micropython)).
I am thinking to configure the pico so it may send a command to reboot the sonoff before rebooting itself :)
Work in progress

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests