Particle Flashing Red when i run specific code

I am using a kalman filter and when i run this software, my electron flashes red.

Please take a look at the code below at the link:

Can you be more specific about the red flashing error?

https://docs.particle.io/guide/getting-started/modes/photon/#red-flash-sos

There are a number of other red blink codes that may be expressed after the SOS blinks:

Hard fault
Non-maskable interrupt fault
Memory Manager fault
Bus fault
Usage fault
Invalid length
Exit
Out of heap memory
SPI over-run
Assertion failure
Invalid case
Pure virtual call
Stack overflow

The code that i have provided at the link successfully flashes but the electron blinks red after the code is flashed. I put the electron in safe mode and ran another source code that I had working earlier, that worked perfectly fine. It is only when i run this code, the flashing occurs. The library for the Kalman filter can be found on the web IDE, its under “Kalman”.

The question @HEng raised was: What kind of red flashing do you see?

Either you can provide a video or describe the flashing as best you can.
What colors do you see on the lead-up to the red flash?
Is it SOS (or not)?
What number of red flashes do you see between the SOS instances?

@HEng I have attached a video of the issue.

I would start here:

Apparently a divide-by-zero can cause this, among other things.

You should also have the LiPo connected in order to have the radio module supplied with enough peak current to not interfere with the µC.
Most common reason for a Usage Fault is a DIV/0 exception. Check your code for that condition - in your .ino file are several instances where the denominator can potentially become zero.

Another tip for the future is to add “break points” in your code to narrow down where in your code the exception happens.
e.g. via

  ...
  Serial.println("breakpoint 1");
  while(Serial.read() < 0) Particle.process();  // wait here till byte received via serial terminal
  ...
  Serial.println("breakpoint 2");
  while(Serial.read() < 0) Particle.process();  // wait here till byte received via serial terminal
  ...

Thank you both for replies. I will try to see through my code and reply back tomorrow. Thank you

1 Like