I’m working on some very simple code running on a Nano 33
IoT BLE, writing data to the serial port every 500ms. However the MBed OS reliably crashes after 362s from being powered up, when it flashes its error code (4 x long, 4 x short flashes).
The code itself is very simple; just a loop which reads data from an I2C temperature sensor and prints it to the console:
float read_sensor(unsigned char whichSensor)
Serial.print("Cannot read from device ");
float c = tempsensor.readTempC();
It runs fine for just over 300 seconds, but then stops every time, in just the same place
I’m at a loss as to what to try next!
Edit: I should have added that I’ve just updated both the Arduino IDE and the mbed board definitions to the latest available
If it is crashing at exactly the same time each time that sounds a lot like an overflow of some kind such as trying to write outside the bounds of an array.
However, there are also some oddities in your code, specifically with the fact you keep running a begin function over and over again which should normally either start at the beginning of your code (in setup()), or occur under certain circumstances. I am assuming based on the name you have given the temperature sensor that you are using a pair of sensors which are something like the Adafruit ADT7410 temperature sensors.
If that is the case then the way you are reading the temperature is odd, I am assuming that at the start of your code you have something like this:
Adafruit_ADT7410 tempsensor = Adafruit_ADT7410();
What this is doing is uses what is called a class (Adafruit_ADT7410), which is basically the blueprint for the sensor, to create an object (tempsensor) which you can refer to later and use to run functions from the sensor library. The advantage of that is that you call make multiple versions of them:
Adafruit_ADT7410 tempsensor_1 = Adafruit_ADT7410();
Adafruit_ADT7410 tempsensor_2 = Adafruit_ADT7410();
Then you can run both at the same time but using two different address:
Then finally you can just read them in your main code:
Now I am not sure if that will fix the crashing but my gut is telling me that running tempsensor.begin(whichSensor) over and over isn't a good idea.
Hope that helps,
I'm working on some very simple code running on a Nano 33 IoT, writing data to the serial port every 500ms. However the MBed OS reliably crashes after 362s from being powered up, when it flashes its error code (4 x long, 4 x short flashes).
Edit: I should have added that I've just updated both the Arduino IDE and the mbed board definitions to the latest available
Is your board really a Nano 33 IoT, or is it the Nano 33 BLE? The reason I ask is that you mention "Mbed" a couple times, but the Nano 33 IoT doesn't use Mbed OS by default (it might be possible to do it, but not so much while staying within the Arduino framework).
This may be relevant information, even if for no other reason than determining which forum board the post should be under.
Huge thanks to you both!
Matt - you were spot on; I'm kicking myself as looking at the code now it's obvious that my original approach wasn't the correct one. Very much appreciate your input!
Pert - you're quite right - my apologies. I managed to post this in the wrong forum in my haste to solve the problem!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.