Argon blinking red

Hi everyone i am having trouble with my argon once I have flashed the device. It worked fine as long as I was printing the sensors’ value through serial but since when I have tried to publish them on the cloud it started doing as shown in the video.
https://photos.app.goo.gl/CWU8VWPsiixEryeM6

I have already flashed the tinker

It’s very difficult to say what’s going on without seeing your code.
The video is also poor quality so is hard to distinguish if it’s blinking 7, 8 or 9 times
I guessing that is 8 blinks - Out of heap memory
here is some support doc where you can get the explanation on SOS patterns.

UPDATE:
I think I got it is 10 blinks
Assertion failure
Maybe you have SYSTEM_THREAD(ENABLED); and you try to publish before cloud connection occur. It’s good practice to guard you Publish :

if (Particle.connected()) Particle.publish("MyEvent", SensorData,  PRIVATE);

hi every time i flash the firmware that i attach here, my argon blinks red 8 times. Do you know why?

#include "Particle.h"
#include <MQTT.h>
#include <Adafruit_Sensor.h>
#include <Grove_ChainableLED.h>
#include <TCA9548A-RK.h>
#include <Adafruit_MLX90393_SSSA.h>
#include <Adafruit_BNO055_Library_SSSA.h>

/* BNO055
   Connections
   ===========
   Connect SCL to analog 5
   Connect SDA to analog 4
   Connect VDD to 3.3V DC
   Connect GROUND to common ground
*/
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);
/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS (100)
#define TCAADDR 0x70
#define MLX90393_CS 10
#define MAGADDR 0X0C

// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
//                                   id, address
Adafruit_BNO055 bno = Adafruit_BNO055(55,0x28);
Adafruit_MLX90393 sensor1 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor2 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor3 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor4 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor5 = Adafruit_MLX90393();


void tcaselect(uint8_t i)
{
      if (i > 7) return;
     
      Wire.beginTransmission(TCAADDR);
      Wire.write(1 << i);
      Wire.endTransmission();  
}
  

void setup()
{ 
  Serial.begin(9600);
  //Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");
  Wire.begin();
  /* Initialise the sensor */
  /*----------------IMU----------------------*/
  tcaselect(5);
  delay(100);
  
  if(!bno.begin())
  {/* There was a problem detecting the BNO055 ... check your connections */
  Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
  }
  else{
    //Serial.println("  IMU ok");
    }
   bno.setExtCrystalUse(true);
   delay(100);
 
   /*-------------SENSORE 1----------------------*/

    tcaselect(0);
    delay(100);
    if (! sensor1.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 1 found ... check your wiring?");
    
   }
   else{
   //Serial.println("  S1 ok");
    }
    sensor1.setGain(MLX90393_GAIN_5X);
    sensor1.setResolution(MLX90393_X, MLX90393_RES_16);
    sensor1.setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor1.setResolution(MLX90393_Z, MLX90393_RES_16);
    // Set oversampling
    sensor1.setOversampling(MLX90393_OSR_0);

  // Set digital filtering
    sensor1.setFilter(MLX90393_FILTER_5);
   /*---------------SENSORE 2----------------------------------*/
 
    tcaselect(1);
    delay(100);
       if (! sensor2.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 2 found ... check your wiring?");

   }
   else{
  //Serial.println("  S2 ok");
    }
    sensor2.setGain(MLX90393_GAIN_5X);
    sensor2.setResolution(MLX90393_X, MLX90393_RES_16);
    sensor2.setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor2.setResolution(MLX90393_Z, MLX90393_RES_16);
    // Set oversampling
  sensor2.setOversampling(MLX90393_OSR_0);

  // Set digital filtering
  sensor2.setFilter(MLX90393_FILTER_5);
  
  /*-------------SENSORE 3--------------------------*/
     tcaselect(2);
    delay(100);
   if (! sensor3.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 3 found ... check your wiring?");
   }
   else{
   //Serial.println("  S3 ok");
    }
    sensor3.setGain(MLX90393_GAIN_5X);
    sensor3.setResolution(MLX90393_X, MLX90393_RES_16);
    sensor3.setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor3.setResolution(MLX90393_Z, MLX90393_RES_16);
    // Set oversampling
    sensor3.setOversampling(MLX90393_OSR_0);

  // Set digital filtering
    sensor3.setFilter(MLX90393_FILTER_5);
 
    /*-------------SENSORE 4--------------------------*/
     tcaselect(3);
    delay(100);
   if (! sensor4.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 4 found ... check your wiring?");
   }
   else{
    //Serial.println("  S4 ok");
    }
    sensor4.setGain(MLX90393_GAIN_5X);
    sensor4.setResolution(MLX90393_X, MLX90393_RES_16);
    sensor4.setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor4.setResolution(MLX90393_Z, MLX90393_RES_16);
    // Set oversampling
  sensor4.setOversampling(MLX90393_OSR_0);

  // Set digital filtering
  sensor4.setFilter(MLX90393_FILTER_5);

     /*-------------SENSORE 5--------------------------*/
     tcaselect(5);
    delay(100);
   if (! sensor5.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 4 found ... check your wiring?");
   }
   else{
   //Serial.println("  S5 ok");
    }
    sensor5.setGain(MLX90393_GAIN_1X);
    sensor5.setResolution(MLX90393_X, MLX90393_RES_16);
    sensor5.setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor5.setResolution(MLX90393_Z, MLX90393_RES_16);
    // Set oversampling
  sensor5.setOversampling(MLX90393_OSR_0);

  // Set digital filtering
  sensor5.setFilter(MLX90393_FILTER_5);
   
};
/**************************************************************************/
/*
    Arduino loop function, called once 'setup' is complete (your own code
    should go here)
*/
/**************************************************************************/
void loop()
{
  delay(1000);
  tcaselect(5);
  sensors_event_t event; 
  bno.getEvent(&event);
  if(!bno.begin())
  {/* There was a problem detecting the BNO055 ... check your connections */
  Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
  }
  else{
    Serial.println("  IMU ok");
    }
     delay(100);
  

 imu::Vector<3> mag= bno.getVector(Adafruit_BNO055::VECTOR_MAGNETOMETER );
/* Display the quat data */
float Magx,Magy,Magz;
float x1, y1, z1;
float x2, y2, z2;
float x3, y3, z3;
float x4, y4, z4;
float x5, y5, z5;

 Magx=mag.x();
 Magy=mag.y();
 Magz=mag.z();
 delay(200);
 
Particle.publish("MagX: ", String(Magx));
delay(1);
Particle.publish("MagY: ", String(Magy));
delay(1);
Particle.publish("MagZ:",String(Magz));
delay(1);

  // get X Y and Z data at once
     tcaselect(0);
     if (! sensor1.begin_I2C(0x0C)) {          // hardware I2C mode, can pass in address & alt Wire
    Serial.println("No sensor 1 found ... check your wiring?");
    }
    sensor1.readData(&x1, &y1, &z1);
     delay(100);
    Particle.publish("X1: ",String(x1));
    delay(500);
    Particle.publish("Y1: ",String(y1));
    delay(500);
    Particle.publish("Z1: ",String(z1));
    delay(500);
     
  if (sensor1.readData(&x1, &y1, &z1)) {
      Serial.println("  S1 ok");
    
  } else {
      Serial.println("Unable to read XYZ data from the sensor 1.");
  }
  
   tcaselect(1);
   sensor2.readData(&x2, &y2,&z2);
   
   delay(100);
    Particle.publish("X2: ",String(x2));
      delay(500);
    Particle.publish("Y2: ",String(y2));
      delay(500);
    Particle.publish("Z2: ",String(z2));
     delay(500);
   
if (sensor2.readData(&x2, &y2,&z2)) {
     Serial.println("  S2 ok");

  } else {
      Serial.println("Unable to read XYZ data from the sensor 2.");
  }

tcaselect(2);
sensor3.readData(&x3, &y3, &z3);

delay(100);
 Particle.publish("X3: ",String(x3));
     delay(500);
 Particle.publish("Y3: ",String(y3));
     delay(500);
Particle.publish("Z3: ",String(z3));
      delay(500);
      
if (sensor3.readData(&x3, &y3, &z3)) {
      Serial.println("  S3 ok");
    
  } else {
      Serial.println("Unable to read XYZ data from the sensor 3.");
  }

tcaselect(3);
sensor4.readData(&x4, &y4, &z4);
delay(100);
if (sensor4.readData(&x4, &y4, &z4)) {
      Serial.println("  S4 ok");
  } else {
      Serial.println("Unable to read XYZ data from the sensor 4.");
  }

tcaselect(4);
sensor5.readData(&x5, &y5, &z5);

delay(100);
Particle.publish("X5: ",String(x5));
delay(500);
Particle.publish("Y5: ",String(y5));
delay(500);
 Particle.publish("Z5: ",String(z5));
delay(500);

if (sensor5.readData(&x5, &y5, &z5)) {
     Serial.println("  S5 ok");
  } else {
      Serial.println("Unable to read XYZ data from the sensor 5.");
  }
 delay(100);
 
 

}

You should have stuck with your original thread. It is good you posted your firmware but you have, I assume, ignored a helpful response by @dreamER. Please review it and post your code there.

Hey, thank you for the suggestion.
I have now moved it to the same thread so we keep the discussion focused.

There is so much code there, it’s hard to guess what might be wrong. You should start by isolating features. For example, comment out all of the Adafruit_MLX90393 sensor code and only use the Adafruit_BNO055 and see if that works.

Also, you are publishing way too often. You are limited to publishing one event per second and you are far exceeding that. The device won’t crash, but you also won’t see the publishes because they’ll be discarded for exceeding the rate limit.

You should look into using Log.info during debugging.

Hi, Arek mentioned above that this indicates an out of heap, are you calling recursively a function, by any chance?

If it is in deed a heap issue (SOS+8) then I’d try to reduce any use of dynamic memory allocations - including the use of String, particularly over and over inside loop().

You may also want to try whether having a global imu::Vector instance instead of creating and destroying one each iteration of loop() mitigates the issue.

BTW, do you encounter the SOS+8 immediately when starting your device or does it take a while? The latter would suggest an issue with heap fragmentation.

it worked well art the beginning and then started creating the issue. So you suggest to declare the imu:vector at the beginning of the code, outside the loop. I will try. Thank you

1 Like

While at it, I’d also remove the String(...) constructs and also unify as many publishes into a single event.

e.g.

  char msg[128];
  ...
  snprintf(msg, sizeof(msg), "x:%4.1f, y:%4.1f, z:%4.1f", Magx, Magy, Magz);
  Particle.publish("Mag", msg);

BTW, I’d also suggest some code improvements
e.g. use arrays to avoid having to write the same block of code multiple times

const int NUMSENSORS = 5;
Adafruit_MLX90393 sensor[NUMSENSORS];
...
void setup() {
  ...
  for (int s=0; s < NUMSENSORS, s++) {
    tcaselect(s);
    delay(100);
    if (!sensor[s].begin_I2C(0x0C)) {   // hardware I2C mode, can pass in address & alt Wire
      Serial.printlnf("Sensor %d not found ... checked your wiring?", s+1);
    }
    else{
      //Serial.printlnf("  S%d ok", s+1);
    }
    sensor[s].setGain(MLX90393_GAIN_1X);
    sensor[s].setResolution(MLX90393_X, MLX90393_RES_16);
    sensor[s].setResolution(MLX90393_Y, MLX90393_RES_16);
    sensor[s].setResolution(MLX90393_Z, MLX90393_RES_16);
    sensor[s].setOversampling(MLX90393_OSR_0);
    sensor[s].setFilter(MLX90393_FILTER_5);
  }
}

void loop() {
  char msg[128];
  float x, y, z;
  ...
  for (int s=0; s < NUMSENSORS, s++) {
    tcaselect(s);
    if (!sensor[s].begin_I2C(0x0C)) {  // hardware I2C mode, can pass in address & alt Wire
      Serial.println("Sensor %d not found ... check your wiring!", s+1);
      continue; // when sensor isn't found, move on to next one
    }
    if (sensor[s].readData(&x, &y, &z)) {
      snprintf(msg, sizeof(msg), "%d ( %4.1f / %4.1f / 4.1f )", s+1, x, y, z);
      Serial.printlnf("OK - Sensor%s", msg);
      Particle.publish("Sensor", msg);
      delay(1000);    
    } 
    else {
      Serial.printlnf("Unable to read XYZ data from the sensor %d.", s+1);
    }
  }
}

You could even get away with a single publish like this (which would save time and data operations)

imu:Vector<3>   mag;
sensors_event_t event; 

void loop() {
  static uint32_t msLastPublish = 0;
  char            msg[256];
  float           x, y, z;

  if (millis() - msLastPublish < 1000) return; // a better way to keep track of the publishing rate limit
  
  bno.getEvent(&event);
  if(!bno.begin()) { // There was a problem detecting the BNO055 ... check your connections
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    snprintf(msg, sizeof(msg), "Mag ( --.- / --.- / --.- )\r\n");
  }
  else {
    Serial.println("  IMU ok");
    mag = bno.getVector(Adafruit:BNO055:VECTOR_MAGNETOMETER);
    snprintf(msg, sizeof(msg), "Mag (%4.1f / %4.1f / %4.1f )\r\n", max.x, mag.y, mag.z);
  }

  for (int s=0; s < NUMSENSORS, s++) {
    tcaselect(s);
    if (!sensor[s].begin_I2C(0x0C)) {  // hardware I2C mode, can pass in address & alt Wire
      Serial.println("Sensor %d not found ... check your wiring!", s+1);
      continue; // when sensor isn't found, move on to next one
    }
    if (sensor[s].readData(&x, &y, &z)) {
      snprintf(msg, sizeof(msg), "S%s  ( %4.1f / %4.1f / 4.1f )\r\n", msg, s+1, x, y, z);
      Serial.printlnf("OK - Sensor%d ( %4.1f / %4.1f / %4.1f )", s+1, x, y, z);
    } 
    else {
      snprintf(msg, sizeof(msg), "S%s  ( --.- / --.- / --.- )\r\n", msg, s+1);
      Serial.printlnf("Unable to read XYZ data from the sensor %d.", s+1);
    }
  }
  Particle.publish("Sensors", msg);

  msLastPublish = millis();
}
1 Like