frederikheld / robotrain

Lego® 4558 Metroliner train on steroids

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Motor control NodeMCU drops out of WiFi

frederikheld opened this issue · comments

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

  • check if the dropout is related to the number of MQTT messages sent to the NodeMCU.

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.

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

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

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