arduino-libraries / ArduinoIoTCloud

https://app.arduino.cc
Other
111 stars 78 forks source link

MKRNB1500 + Arduino IoT Cloud Connection Issues #274

Open Brennan-Richards opened 3 years ago

Brennan-Richards commented 3 years ago

Board I am using: MKR NB 1500

Sensors: multiple IC sensors for physical environment readings

Power source: LiPo battery pack via on-board JST port

Other libraries: Arduino LowPower for SAMD

My problem is that I cannot get the board to maintain a connection consistently with the Arduino IoT cloud. I’m attempting to use the LowPower library to save power, but putting the board into sleep mode tends to disrupt the connection. I disabled sleep mode and the connection was maintained for a few hours last night, however it also seems to have been disrupted. I’ve also disabled the watchdog at this point because the code in my loop runs sometimes longer than the ~16 second timer, and a reset is undesirable.

I am looking to deploy the modules ‘in the field’ over extended periods. Is there a way I can ensure that my board stays connected, and to re-establish a connection to the Arduino IoT Cloud in the case that it disconnects? (I am exploring subscribing to the DISCONNECT event which triggers a callback that runs the ArduinoCloud.begin() method, thoughts on this?)

Thanks in advance and best regards, Brennan.

Brennan-Richards commented 3 years ago

Hi all, I can see that some of the contributors to this Arduino IoT Cloud library have also worked on this issue through this library: https://github.com/arduino-libraries/Arduino_ConnectionHandler/blob/master/src/Arduino_ConnectionHandler.cpp. Is this a recommended inclusion?

Brennan-Richards commented 3 years ago

Update: I've re-enabled the watchdog timer, and the board maintained connection for three hours (with resets, even though that's not best case for me) and still in the end ultimately lost connection permanently although the Arduino MKR NB 1500 board and circuit are certainly still powered up and running. They have not moved from the same spot at any point.

Anyone else experiencing this or similar?

Best, Brennan

Brennan-Richards commented 3 years ago

Bump... Is anyone else experiencing similar problems?

Is it a hardware problem? There seems to be a lot of fussing with the SARA R4 modem on board going on in an attempt to improve connection reliability.

Is it a network problem? My hope is that these problems will start to disappear as the LTE-M/NB-IoT are cultivated.

Any help or general discussion is welcomed please.

aentinger commented 3 years ago

because the code in my loop runs sometimes longer than the ~16 second

Instead of disabling the watchdog I'd suggest to strategically sprinkle your loop with a couple of watchdog_reset(); calls. Also as of right now Low Power/Deep Sleep is not supported by the Arduino IoT Cloud firmware stack.

jsword commented 3 years ago

I experienced a similar issue with my MKR WiFi 1010. Using a similar setup and LowPower it would run for a few hours and then freeze. After a LOT of debugging I discovered a memory leak every time ArduinoCloud.begin() was called. Eventually your board just runs out of memory and stops. I have currently worked around it by monitoring memory and triggering a reset whenever it gets down to 1/3 free.

Free memory init: 13419 ArduinoCloud.begin Free memory post-init: 12915 ... Free memory init: 12635 ArduinoCloud.begin Free memory post-init: 12131 .... Free memory init: 11851 ArduinoCloud.begin Free memory post-init: 11347

aentinger commented 3 years ago

Hey @jsword :wave: You really should be calling ArduinoCloud.begin() only once. As I wrote above, low power sleep isn't currently supported in the framework.

jsword commented 3 years ago

Sorry @aentinger I’m a bit of a newbie. 🤷‍♂️ Is there any supported way to conserve power since I’m running a solar/battery powered system? Is there a way to look up the cross framework support/compatibility that I might have missed?

DigitalLivestock commented 2 months ago

Greetings! Has support been added for Low Power/Deep Sleep within the Arduino IoT Cloud firmware stack yet? I'm still experiencing the same issues as mentioned by @Brennan-Richards . Best regards