Auto reconnect to WiFi
WhoSayIn opened this issue · 9 comments
Hi,
I manage to have my setup yesterday and it worked fine until what it seems like around afternoon, then the WiFi connection dropped. (my meter is just outside of my apartment)
I even restarted my router while I was at the office but it didn't connect back so I didn't have data until I got back home, unplugged the esp and plugged it back.
Now it works fine but it most probably gonna happen again. Not really experienced in this but is it possible to put a control in the loop method, so if it's not connected to WiFi, it would reconnect?
Stopped working around 4 in the morning again :) Probably the signal is not very strong as the meter is in a cabinet outside the apartment. But when it works, it works just fine.
How was your experience?
I have the same experience here. I think it would be handy if an option is build in to restore the connection.
However, sometimes it stays connected for days, sometimes it drops. Even sometimes after a couple of hours it reconnects (according to grafana data).
Now I'm running a much more simplified version of this code with ability to reconnect and not to send data when it reads 0 (it happened only once in a while)
I think at this point creating a fork would make more sense. Gonna post a link soon.
I created the fork [0]
Main differences from this repository;
- Much more simplified. Not using WifiManager, flash the LED on ESP etc.
- Reconnects to WIFI when the connection drops.
- Does not send the 0 values (it happened only once in a while randomly, then the graphs looked weird. Keep in mind that in my setup I only record consumption_low_tarif, consumption_high_tarif, actual_consumption, gas_meter_m3. In your case maybe it would be useful to record the 0 values)
Feel free to use it.
Ah, I also use D5 pin, as it was easier to do the setup compared to D2 :)
Added some meter readings, maybe you can use them in your fork.
@HanSyt thanks!
Do you mind telling what they mean? Like the difference in between DELIVERY
and CONSUMPTION
?
Also L1, L2 and L3? :)
Oh, I haven't had seen your fork [0] btw! I see some improvements over there!
[0] https://github.com/HanSyt/esp8266_p1meter/commits/master
I have added this to the loop function, works perfect so far.
// * Gets called when WiFi connection is lost
if (WiFi.status() == WL_DISCONNECTED){
logger->println("Lost WiFi Connection! Restarting...");
ESP.restart();
}
note: I'm using this repo https://github.com/Diechel/esp8266_p1meter so you need to replace logger-> with Serial.