frederikheld / robotrain

Lego® 4558 Metroliner train on steroids
GNU General Public License v3.0
1 stars 0 forks source link

Motor control NodeMCU drops out of WiFi #25

Open frederikheld opened 4 years ago

frederikheld commented 4 years ago

If the train is powered on for a certain time, the NodeMCU is not available via MQTT anymore as it drops out form WiFi. This can happen after an hour, after a couple of hours, sometimes not at all through the whole day.

You can mitigate the bug by resetting the NodeMCU or by unpowering the train and then powering up again.

Possible Reasons

Arduino Sketch has memory leaks

I read about ways the library can leak memory in https://github.com/knolleary/pubsubclient.

I would appreciate help on that as I'm not firm with memory management in C

Other possible issues with the Arduino Sketch

NodeMCU is overheated

With all the electronis inside, the train gets pretty warm. Active ventilation might fix the issue.

frederikheld commented 3 years ago

No, not yet unfortunately. I didn't dig deeper on that one yet. If you find a solution, I'd be happy about a comment or PR ;-)

Chetan-99 commented 3 years ago

Hey, the issue is resolved. So I made a function for reconnecting to a wifi like : reconnectWifi() -> normal function that we initialize in setup()

Now in loo(), apply a check for the wifi connection: if ( WiFi.status() != WL_CONNECTED){ reconnectWifi(); }

Working flawlessly. Never experienced disconnection after this. Good Luck

frederikheld commented 3 years ago

Awesome, thank you very much for sharing with me! I'll look into it as soon as I am working on this project again :-) This should fix the issue for me as well :-)