fliphess / esp8266_p1meter

dsmr 4.2 P1 meter to mqtt using esp8266 nodemcu
GNU General Public License v3.0
69 stars 114 forks source link

Auto reconnect to WiFi #5

Open WhoSayIn opened 4 years ago

WhoSayIn commented 4 years ago

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?

WhoSayIn commented 4 years ago

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?

HanSyt commented 4 years ago

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).

WhoSayIn commented 4 years ago

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.

WhoSayIn commented 4 years ago

I created the fork [0]

Main differences from this repository;

Feel free to use it.

[0] - https://github.com/WhoSayIn/esp8266_dsmr2mqtt

WhoSayIn commented 4 years ago

Ah, I also use D5 pin, as it was easier to do the setup compared to D2 :)

HanSyt commented 4 years ago

esp8266_p1meter.zip

Added some meter readings, maybe you can use them in your fork.

WhoSayIn commented 4 years ago

@HanSyt thanks!

Do you mind telling what they mean? Like the difference in between DELIVERY and CONSUMPTION?

Also L1, L2 and L3? :)

WhoSayIn commented 4 years ago

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

schumi2004 commented 3 years ago

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.