ESP8266 dropping WiFi connection
Moderator: leecollings
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
ESP8266 dropping WiFi connection
Hi,
I have setup a Simple Thermostat using ESP8266, ESPEasy and some Domoticz.
The script is in python on my RPI and the ESP8266 Boiler switch is switched on with a switch in Domoticz. (see picture)
The problem I encounter is that ESP8266 drops it's WiFi connection every now and then.
It has happened one time after we came back on Schiphol and I wanted to fire up the heating @home and another time when the temperature rose to 22+ degrees, with relay switched on.
Not often but 2 times too much.
On both occasions ESP8266 had dropped it's WiFi connection.
The hard reset is the only way out in such a case.
I tried a bit with System Alive checker.
Either I am not able to set it up with the provided dzVents software (present in examples) or the software doesn't do what it is intended to do.
I'm afraid the problem lies with me.
Anyway, I've found a bash script on this forum, written by @timmpo.
This script explains itself easily and works out of the box.
My questions to others on this forum.
- Did you encounter the same problems of an ESP8266 dropping WiFi connection?
if so:
- What is your solution to catch the disconnected WiFi connection and get the ESP8266 going again?
My solution for now is to place another ESP8266 plus relay (active by default) or a Sonoff switch in the 230V power line to the Boiler switch.
When the Boiler switch drops connection I will interrupt the power line and switch it on again.
The effect will be that the Boiler switch will restart and WiFi communication will be established.
I'm curious to see your comments and workarounds.
I have setup a Simple Thermostat using ESP8266, ESPEasy and some Domoticz.
The script is in python on my RPI and the ESP8266 Boiler switch is switched on with a switch in Domoticz. (see picture)
The problem I encounter is that ESP8266 drops it's WiFi connection every now and then.
It has happened one time after we came back on Schiphol and I wanted to fire up the heating @home and another time when the temperature rose to 22+ degrees, with relay switched on.
Not often but 2 times too much.
On both occasions ESP8266 had dropped it's WiFi connection.
The hard reset is the only way out in such a case.
I tried a bit with System Alive checker.
Either I am not able to set it up with the provided dzVents software (present in examples) or the software doesn't do what it is intended to do.
I'm afraid the problem lies with me.
Anyway, I've found a bash script on this forum, written by @timmpo.
This script explains itself easily and works out of the box.
My questions to others on this forum.
- Did you encounter the same problems of an ESP8266 dropping WiFi connection?
if so:
- What is your solution to catch the disconnected WiFi connection and get the ESP8266 going again?
My solution for now is to place another ESP8266 plus relay (active by default) or a Sonoff switch in the 230V power line to the Boiler switch.
When the Boiler switch drops connection I will interrupt the power line and switch it on again.
The effect will be that the Boiler switch will restart and WiFi communication will be established.
I'm curious to see your comments and workarounds.
Bugs bug me.
-
- Posts: 528
- Joined: Saturday 02 June 2018 11:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.1
- Location: Echt, Netherlands
- Contact:
Re: ESP8266 dropping WiFi connection
Once in a while my ESP also drops its wifi.
But that is once in a few month, maybe longer.
I made a script which automatically reboots the ESP on wifi loss
Place this in the rules page of the ESPEASY. You have to activated the rules tab. Go to Tools-->Advanced-->Rules Settings.
Activated it an reboot the ESP.
The scripts response on Wifi#Disconnected. After 3 minutes no wifi it reboots
When wifi will be back, the timer will be canceled
But that is once in a few month, maybe longer.
I made a script which automatically reboots the ESP on wifi loss
Place this in the rules page of the ESPEASY. You have to activated the rules tab. Go to Tools-->Advanced-->Rules Settings.
Activated it an reboot the ESP.
The scripts response on Wifi#Disconnected. After 3 minutes no wifi it reboots
When wifi will be back, the timer will be canceled
Code: Select all
on System#Boot do
Let,1,0 // set user variable to initial state of 0
endon
On Wifi#Disconnected do
if [VAR#1]=0
timerSet,1,180
Let,1,1 // set user variable 1 to 1 to prevent re-set of var1 on each event.
endif
endon
on Wifi#Connected do // if wifi returns, cancel reboot
timerSet,1,0 // cancel timer
Let,1,0 // set user variable 1 to 0
endon
On Rules#Timer=1 do
reboot
endon
Last edited by hoeby on Monday 13 January 2020 9:07, edited 1 time in total.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: ESP8266 dropping WiFi connection
Nice script, but it is just a bandaid for your problem.
On wifi loss my ESP's ( 5 now ) will auto connect again when Wifi is available again. So this must work.
Have a look at you channel you use for Wifi. Move it if neighbours are close or on the same channel. ( or at least find a better channel )
I have an ESP more or less outside the wifi range, made an external antenna on it and it does connect regularly to my network now. Just enough to
switch on and off the light...... Its a lighthouse tower in my garden
In other words.. A reboot script helps, finding a better wifi is advised.
Good luck , Frank
Ohhh and btw can't you make a backup script on the ESP that is Wifi is lost, it goes in emergency and connects the boiler?
On wifi loss my ESP's ( 5 now ) will auto connect again when Wifi is available again. So this must work.
Have a look at you channel you use for Wifi. Move it if neighbours are close or on the same channel. ( or at least find a better channel )
I have an ESP more or less outside the wifi range, made an external antenna on it and it does connect regularly to my network now. Just enough to
switch on and off the light...... Its a lighthouse tower in my garden
In other words.. A reboot script helps, finding a better wifi is advised.
Good luck , Frank
Ohhh and btw can't you make a backup script on the ESP that is Wifi is lost, it goes in emergency and connects the boiler?
-
- Posts: 528
- Joined: Saturday 02 June 2018 11:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.1
- Location: Echt, Netherlands
- Contact:
Re: ESP8266 dropping WiFi connection
There you have a good point, i share your point
I made the script because wifi lose was once in a few months, which made searching for the problem not easy
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: ESP8266 dropping WiFi connection
Great @hoeby
I have set it up in my ESP and switched off the bash script.
No more need for a second ESP ICE.
Thanks!
I have set it up in my ESP and switched off the bash script.
No more need for a second ESP ICE.
Thanks!
Bugs bug me.
-
- Posts: 139
- Joined: Thursday 19 February 2015 21:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: ESP8266 dropping WiFi connection
i had the same issue but not only the WiFi dropped the connection to domoticz as mysensor gateway dropped out when wifi was still connected.
i solved this with a script in domoticz that pings the ESP every minute (just switch on and off an IDX), the ESP has a counter that will stay 0 a ping is received and increments every minute if no ping is received. after 5 minutes no connection, it does a hard rest (since the softreset did not always work) by pulling a pin up that triggers the rest pin.
i solved this with a script in domoticz that pings the ESP every minute (just switch on and off an IDX), the ESP has a counter that will stay 0 a ping is received and increments every minute if no ping is received. after 5 minutes no connection, it does a hard rest (since the softreset did not always work) by pulling a pin up that triggers the rest pin.
-
- Posts: 63
- Joined: Thursday 04 February 2016 20:18
- Target OS: -
- Domoticz version:
- Contact:
Re: ESP8266 dropping WiFi connection
Hi all,
Nice solutions, but how do you cope with switching relais with the ESP. After a reboot, you don't know the on/off status anymore within the ESP. I tried getting the variable from Domoticz, but did not succeed yet. Also setup a MQTT interface and experimented with MQTT Import in ESP, but so far unsuccessfull.
Regards,
Marco
Nice solutions, but how do you cope with switching relais with the ESP. After a reboot, you don't know the on/off status anymore within the ESP. I tried getting the variable from Domoticz, but did not succeed yet. Also setup a MQTT interface and experimented with MQTT Import in ESP, but so far unsuccessfull.
Regards,
Marco
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: ESP8266 dropping WiFi connection
@marcojpolet
That is handled by Domoticz as far as I know.
What happens when you do
Like it is displayed in your dashboard.
Domoticz will update the display.
Or am I overlooking something.
That is handled by Domoticz as far as I know.
What happens when you do
It returns the current state isn't it.
Like it is displayed in your dashboard.
Domoticz will update the display.
Or am I overlooking something.
Bugs bug me.
-
- Posts: 63
- Joined: Thursday 04 February 2016 20:18
- Target OS: -
- Domoticz version:
- Contact:
Re: ESP8266 dropping WiFi connection
Hi HdvW,
Not sure exactly what you mean; Domoticz indeed will keep the current state; but the ESPEasy sw will forget after a reboot.
Regards,
Marco
Not sure exactly what you mean; Domoticz indeed will keep the current state; but the ESPEasy sw will forget after a reboot.
Regards,
Marco
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: ESP8266 dropping WiFi connection
I tested with an ESP reboot.
You're right ESPeasy and Domoticz are not complying after a http://192.168.1.11/control?cmd=GPIO,5,0 or something like that to ESP.
Maybe it is possible to switch with sysfs on ESP8266?
With that communication should be reinitiated again.
There are wise people on this forum, maybe one of them will shine a light on this.
PS In fact I don't mind too much, it sync by itself after a next switch command.
You're right ESPeasy and Domoticz are not complying after a http://192.168.1.11/control?cmd=GPIO,5,0 or something like that to ESP.
Maybe it is possible to switch with sysfs on ESP8266?
With that communication should be reinitiated again.
There are wise people on this forum, maybe one of them will shine a light on this.
PS In fact I don't mind too much, it sync by itself after a next switch command.
Last edited by HvdW on Monday 17 February 2020 11:49, edited 1 time in total.
Bugs bug me.
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: ESP8266 dropping WiFi connection
@hoeby
We're back where we started.
Despite the script my ESP8266 loses connection with the LAN.
The script is so simple, straight and clear, I cannot understand that it doesn't execute properly.
It was doing fine for a while but since a week or so it disconnects from WiFi.
During the day when switch commands are exchanged every 5 minutes everything is running fine.
Durng the night when the thermostat is set to a low temperature and no action is required it loses connection.
I exchanged the ESP8266 for another and another ip address too but behaviour is the same.
Question is that when the script is executing it should reconnect by itself.
How come it doesn't?
I have 2 ESP8266
1 - signal -78 dB Luftdaten which drops connection every now and then, always returns
2 - signal -68 dB Heating switch which drops connection and is lost afterwards, despite the script.
We're back where we started.
Despite the script my ESP8266 loses connection with the LAN.
The script is so simple, straight and clear, I cannot understand that it doesn't execute properly.
It was doing fine for a while but since a week or so it disconnects from WiFi.
During the day when switch commands are exchanged every 5 minutes everything is running fine.
Durng the night when the thermostat is set to a low temperature and no action is required it loses connection.
I exchanged the ESP8266 for another and another ip address too but behaviour is the same.
Question is that when the script is executing it should reconnect by itself.
How come it doesn't?
I have 2 ESP8266
1 - signal -78 dB Luftdaten which drops connection every now and then, always returns
2 - signal -68 dB Heating switch which drops connection and is lost afterwards, despite the script.
Bugs bug me.
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: ESP8266 dropping WiFi connection
Hi
my worst connection is Wifi RSSI: -80 dB
I monitor the connection with the build in Ping from Domoticz.
As you can see , it drops now and then BUT!!!! never uses a reboot or any other help !! It just connects by itself again
and even running a few days without a disconnect.
My 2 cents :
Use the ping option as well as that generates "trafic" to the ESP.
Get an app on your mobile phone and monitor how many Wifi signals you have on your channel and move your Accespoint to a less busy channel.
In my street all channels are busy, so less busy is the only option.
Perhaps bring your ESP 1 meter away from your accespoint and see if it looses the connection as wel. It should never loose the connection from that
"distance".
my worst connection is Wifi RSSI: -80 dB
I monitor the connection with the build in Ping from Domoticz.
As you can see , it drops now and then BUT!!!! never uses a reboot or any other help !! It just connects by itself again
and even running a few days without a disconnect.
My 2 cents :
Use the ping option as well as that generates "trafic" to the ESP.
Get an app on your mobile phone and monitor how many Wifi signals you have on your channel and move your Accespoint to a less busy channel.
In my street all channels are busy, so less busy is the only option.
Perhaps bring your ESP 1 meter away from your accespoint and see if it looses the connection as wel. It should never loose the connection from that
"distance".
Code: Select all
2020-02-18 13:04:01 On
2020-02-18 13:03:00 Off
2020-02-18 10:31:25 On
2020-02-18 10:30:19 Off
2020-02-17 21:07:29 On
2020-02-17 21:06:29 Off
2020-02-16 18:41:31 On
2020-02-16 18:40:20 Off
2020-02-16 16:44:57 On
2020-02-16 16:43:48 Off
2020-02-16 13:33:32 On
2020-02-16 13:32:27 Off
2020-02-16 11:31:11 On
2020-02-16 11:30:04 Off
2020-02-12 20:33:47 On
2020-02-12 20:32:47 Off
2020-02-11 19:41:55 On
2020-02-11 19:40:51 Off
2020-02-11 19:03:12 On
2020-02-11 19:02:07 Off
Re: ESP8266 dropping WiFi connection
Hey guys,
Reading your stories I want to chip in with some relevant information that could help...
Espressif Esp8266 devices are 2.4ghz /20mhz capable with b/g/n capabilities.
To start, keep in mind that WiFi is still a radio signal and as such, it's subject to interference. Especially for the overcrowded 2.4ghz band, where you can find everything from WiFi camera's, Bluetooth, Radar, Zigbee, radio controlled toy cars, wireless doorbells, etc. It's crowded and a bloody mess. And because most esp8266 devices do not have proper antennas, this is sometimes a real problem for these little devices.
Now, if the signal is not the problem, their are still many factors that can influence the signal and stability.
For example:
- Most Soho routers nowadays provide both 2.4ghz and 5ghz. But most of them only use a single antenna or array that has to be shared. So it needs to divide the antenna, kinda like time sharing, depending on the connected devices.
- Modern Soho routers try to 'push' devices to the 5ghz frequency but intermittently disconnect the device very shortly from 2.4ghz, forcing the device to look further and connect with 5ghz. Although the Access point should check if the device in question is 5ghz capable, this solution is far away from perfect.
- Apart from the esp8266, most device can communicate with the wifi router on a larger frequency range then the basic 20ghz range, ranging from a 20mhz to 80mhz wide connection (allowing for greater speeds over 2.4ghz). The wifi router has to throttle back the signal to 20mhz every time it's communicating with the esp8266.
- Did I already mention that most esp8266 devices have a terrible lousy shitty pcb antenna?
- The 802.11N wifi standard that most Soho routers use are still the pre-N standard or their own adaptation of the N standard (gotta love China and copy-paste). Things have changed despite and after the official release of the standard and there are now multiple -N standards/revisions. That does not help, making most 802.11N connections less stable then they are advertised...
So basically, unless you are using the esp8266 in a controlled lab environment, these disconnect things happen...
Especially if you are living in a dense (city) environment and have a lot of WiFi devices connected at the same time.
Want a perfect stable connection?
Try a (certified) network cable connection.
And hope that other network devices are working perfectly as well.
In a perfect world.
On a perfect day.
Where all men are a god... (Although the people on this forum come pretty close to that ).
But to give a few tips:
Try a different dedicated access point that is stable and switch it to the old 802.11 N or even G standard (Linksys WRT54G anyone?! Those where the days!). Don't place it right next to the other access point (at least a meter apart). And use a different frequency if possible. That could help, but it is not a promise (to many factors, WiFi is still a radio signal, subject to ether interference!).
Reading your stories I want to chip in with some relevant information that could help...
Espressif Esp8266 devices are 2.4ghz /20mhz capable with b/g/n capabilities.
To start, keep in mind that WiFi is still a radio signal and as such, it's subject to interference. Especially for the overcrowded 2.4ghz band, where you can find everything from WiFi camera's, Bluetooth, Radar, Zigbee, radio controlled toy cars, wireless doorbells, etc. It's crowded and a bloody mess. And because most esp8266 devices do not have proper antennas, this is sometimes a real problem for these little devices.
Now, if the signal is not the problem, their are still many factors that can influence the signal and stability.
For example:
- Most Soho routers nowadays provide both 2.4ghz and 5ghz. But most of them only use a single antenna or array that has to be shared. So it needs to divide the antenna, kinda like time sharing, depending on the connected devices.
- Modern Soho routers try to 'push' devices to the 5ghz frequency but intermittently disconnect the device very shortly from 2.4ghz, forcing the device to look further and connect with 5ghz. Although the Access point should check if the device in question is 5ghz capable, this solution is far away from perfect.
- Apart from the esp8266, most device can communicate with the wifi router on a larger frequency range then the basic 20ghz range, ranging from a 20mhz to 80mhz wide connection (allowing for greater speeds over 2.4ghz). The wifi router has to throttle back the signal to 20mhz every time it's communicating with the esp8266.
- Did I already mention that most esp8266 devices have a terrible lousy shitty pcb antenna?
- The 802.11N wifi standard that most Soho routers use are still the pre-N standard or their own adaptation of the N standard (gotta love China and copy-paste). Things have changed despite and after the official release of the standard and there are now multiple -N standards/revisions. That does not help, making most 802.11N connections less stable then they are advertised...
So basically, unless you are using the esp8266 in a controlled lab environment, these disconnect things happen...
Especially if you are living in a dense (city) environment and have a lot of WiFi devices connected at the same time.
Want a perfect stable connection?
Try a (certified) network cable connection.
And hope that other network devices are working perfectly as well.
In a perfect world.
On a perfect day.
Where all men are a god... (Although the people on this forum come pretty close to that ).
But to give a few tips:
Try a different dedicated access point that is stable and switch it to the old 802.11 N or even G standard (Linksys WRT54G anyone?! Those where the days!). Don't place it right next to the other access point (at least a meter apart). And use a different frequency if possible. That could help, but it is not a promise (to many factors, WiFi is still a radio signal, subject to ether interference!).
Check these howto's: https://sancla.com
-
- Posts: 63
- Joined: Thursday 04 February 2016 20:18
- Target OS: -
- Domoticz version:
- Contact:
Re: ESP8266 dropping WiFi connection
Another tip: for me it helped to set all access points (I have three) to same SSID, but channels 1, 6 and 11. These don't overlap. Also, use 20Mhz only and only N (but of course, that's my setup, with my house, with my ESP's etc.) No guarantees haha
Regards,
Marco
Regards,
Marco
Who is online
Users browsing this forum: No registered users and 0 guests