PhracturedBlue / ESP8266MQTTMesh

Self-assembling Mesh network built around the MQTT protocol supporting OTA
GNU General Public License v3.0
267 stars 79 forks source link

Scanning WiFi #54

Open shajek opened 6 years ago

shajek commented 6 years ago

hellou, i try to figure out how detect unsuccesfull scanning. My problem in my battery application is, when wifi is not connected then node try connect forever and battery drain so much, because MQTT broker handle sleeping. I cannot access your private variables, than i asking you, what you recommend to detect scanning cycles .... I want to pass 1-2 scan of WiFi than deepsleep for a while. Thank you

simone1999 commented 5 years ago

hi, the ESP8266MQTTMesh code is never blocking, so you can execute your Functions (setup and loop) while the Libary is scanning for WIFI. Also you have the function mesh.connected() which you can use to detect if the Connection has suceedet, so my advice would be to deepsleep the esp if a certain Time has pased in which no Connection has been made. Youst save the time at the Beginning of your programm in a Variable and look in every loop if connection is not there and a certain Time has passed.