Bug report: Nicla is disconnecting/crashing after ~30 min of I2C com
lsi8 opened this issue · 3 comments
@giulcioffi
@facchinm
I wanted to post this as an issue under arduino-libraries/Arduino_BHY2Host, as it pertains to your example code referenced by marqdevx in his tutorial, but it seems you've disabled it? I've tested the example located here (Arduino_Pro_Tutorials/examples/Nicla Sense ME as a MKR Shield) and it suffers from the same bug.
@marqdevx
I am trying to get your basic tutorial working for the Nicla and Portenta H7 connected over ESLOV. The bug in your example is that it only works for a little over half an hour before crashing.
I modified your code for debugging purposes:
Arduino_BHY2Host/examples/Accelerometer/Accelerometer_copy.ino:
#include "Arduino.h"
#include "Arduino_BHY2Host.h"
#include <LandoRGBLedPortenta.h>
SensorXYZ accel(SENSOR_ID_ACC);
LandoRGBLedPortenta portentaLeds;
const int MAX_DUPLICATE_READINGS = 10;
String colorToToggle = "white";
int duplicateReadings = 0;
static unsigned long printTime = 0;
static unsigned long startTime = 0;
static String timeToCrash = "";
static String lastAccelReading = "";
void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.println("Serial started!");
portentaLeds.setColor("red");
BHY2Host.begin(false, NICLA_VIA_ESLOV);
Serial.println("BHY2HostSuccess!");
portentaLeds.setColor("green");
accel.begin();
Serial.println("Leaving setup!");
portentaLeds.setColor("blue");
printTime = millis();
startTime = printTime;
}
void loop()
{
BHY2Host.update();
if (millis() - printTime >= 1000) {
printTime = millis();
String accelReading = accel.toString();
if(accelReading == lastAccelReading) {
duplicateReadings++;
if(duplicateReadings == MAX_DUPLICATE_READINGS) {
timeToCrash = " " + String(printTime - startTime) + " ms";
colorToToggle = "red";
}
}
else {
duplicateReadings = 0;
}
Serial.println(String("Acceleration values: ") + String(accelReading) + String(timeToCrash));
portentaLeds.toggleColor(colorToToggle);
lastAccelReading = accelReading;
}
}Arduino_BHY2/examples/App/App_copy.ino:
#include "Nicla_System.h"
#include "Arduino.h"
#include "Arduino_BHY2.h"
void colorCycle(int loops) {
for(int i = 0; i < loops; i++) {
nicla::leds.setColor(red);
delay(1000);
nicla::leds.setColor(green);
delay(1000);
nicla::leds.setColor(blue);
delay(1000);
}
nicla::leds.setColor(off);
}
void setup(){
BHY2.begin(NICLA_I2C, NICLA_VIA_ESLOV);
nicla::leds.begin();
colorCycle(5);
}
void loop(){
// Update and then sleep
nicla::leds.setColor(blue);
BHY2.update(500);
nicla::leds.setColor(off);
}After 1,881,243–2,398,485 ms, the Nicla stops updating…
- The blue led on Nicla stops flashing indicating that the
BHY2.update(500);line in the loop probably caused an exception.
If I reset just the Portenta and relaunch the serial printer, the Portenta halts at the accel.begin(); line in the setup...
it seems you've disabled it?
The reason that was done is arduino-libraries/Arduino_BHY2Host is a mirror of https://github.com/arduino/nicla-sense-me-fw/tree/main/Arduino_BHY2Host. The library is developed exclusively in that repository, so all issues must be tracked there also.
A note should be added to the library readmes to make this mirroring status clear.
@per1234
Oh I was unaware. It seems, however, that my issue might get more attention here, as the only open issue (of 2 total) at arduino-libraries/Arduino_BHY2Host has been left open w/o response since May 28th 😂
Speaking of that linked issue, do you think that I could be having a similar increase in current draw over time leading to some kind of automatic damage-preventative shutdown?
Moved to arduino/nicla-sense-me-fw#42. Thanks @lsi8!

