lsi8
December 7, 2021, 12:12pm
1
I am trying to get this basic tutorial working for the Nicla and Portenta H7 connected over ESLOV. The bug in the example is that it only works for a little over half an hour before crashing.
I modified their code for debugging purposes:
nicla-sense-me-fw/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;
}
}
nicla-sense-me-fw/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,741,691–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...
Anyone know how I can resolve this?
in0
December 7, 2021, 2:26pm
2
In order to make all relevant information available to all who are interested in this subject, I'll share a link to the related report here:
opened 09:37AM - 07 Dec 21 UTC
bug
<!--
************************************** WARNING **********************… ****************
The ciarcom bot parses this header automatically. Any deviation from the
template may cause the bot to automatically correct this header or may result in a
warning message, requesting updates.
PLEASE ENSURE ALL SECTIONS OF THIS TEMPLATE ARE FILLED IN AND THAT THERE ARE
NO OTHER CHANGES TO THE TEMPLATE.
Only bugs should be raised here as issues. Questions or enhancements should instead be raised on
our forums:
https://forums.mbed.com/ .
*************************************************************************************
-->
### Description of defect
I first reported [this](https://github.com/arduino-libraries/Arduino_Pro_Tutorials/issues/21#issue-1073045588) bug at [arduino-libraries/Arduino_Pro_Tutorials](https://github.com/arduino-libraries/Arduino_Pro_Tutorials) but I was told by @per1234 that it should also be tracked here.
@marqdevx
I am trying to get your basic [tutorial](https://docs.arduino.cc/tutorials/nicla-sense-me/use-as-mkr-shield#troubleshooting) 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 (technically, @giulcioffi & @polldo 's code) for debugging purposes:
**[nicla-sense-me-fw/Arduino_BHY2Host/examples/Accelerometer/Accelerometer_copy.ino](https://github.com/arduino/nicla-sense-me-fw/blob/e8956b952ad1734745cbc2cf530e9c3ce1777aa4/Arduino_BHY2Host/examples/Accelerometer/Accelerometer.ino):**
```cpp
#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;
}
}
```
**[nicla-sense-me-fw/Arduino_BHY2/examples/App/App_copy.ino](https://github.com/arduino/nicla-sense-me-fw/blob/e8956b952ad1734745cbc2cf530e9c3ce1777aa4/Arduino_BHY2/examples/App/App.ino):**
```cpp
#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.
<img width="689" alt="Pasted Graphic" src="https://user-images.githubusercontent.com/54215289/144988031-ba9a2f3f-48d6-44dd-ad13-ccb4fe1a9513.png">
If I reset just the Portenta and relaunch the serial printer, the Portenta halts at the `accel.begin();` line in the setup...
<img width="691" alt="Pasted Graphic 1" src="https://user-images.githubusercontent.com/54215289/144988310-20de4f21-7a90-4233-be45-72e22cd89e69.png">
#### Target(s) affected by this defect ?
Refer to bug description.
#### Toolchain(s) (name and version) displaying this defect ?
Refer to code.
#### What version of Mbed-os are you using (tag or sha) ?
Most recent versions required by the linked code as of today (12/7/2021).
#### What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
Most recent versions required by the linked code as of today (12/7/2021).
#### How is this defect reproduced ?
By running the linked code and waiting over 30 min.
Thank you @lsi8
1 Like
system
Closed
June 5, 2022, 2:27pm
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.