Photon Crashes After Setup Function

Hi Everyone,
I have been working on a school project using 2 Photon devices to monitor water pressure and toggle a water pump. I was having no issues with the project before, but for reasons I cannot understand, my code will only execute until the end of void setup, then it will crash the Photon’s firmware and blink the red SOS message (10 red blinks in between meaning “Assertion Failure”). Then after a few seconds, the photon will restart and run the program from the beginning. I have had this problem about a month or so now, and I cannot figure it out. Any information about why this is happening would be extremely helpful! My photon is currently running version 1.5.2 and runs other programs just fine. Here is a video link (iCloud Mail Drop link) showing the error happening.
and Here is a link to my code in GitHub

My code compiles just fine. So far I have tried using a different photon board and resetting my photon to factory settings.

Please let me know if I can provide any other information.
Sincerely,
Andrew Brown

When seeing an SOS panic it’s always good to also state the number of slow red blinks between the two SOS signals - this will offer some hint for potential causes.

The video shows it’s and SOS+10 (assertion failure)
https://docs.particle.io/tutorials/device-os/led/photon/#red-flash-sos

These are the more obscure kind of errors as they often indicate some branch in the device OS that wasn’t actually meant to be executed.

1 Like

Thank you! I have updated the original post! It blinks red 10 times between the SOS messages.

After the display shows DONE! there is some time before the SOS+10 happens.
Can you add some debug statements (e.g. on LCD or via Serial.print()) to better locate the code line that may be causing the panic?

1 Like

Yes, I will do this a bit later today, thank you so much for your quick responses. I really appreciate it:)

Hey @andrewb1230 -

Welcome to the Particle forum, I see @ScruffR is helping out, which means you are in good hands.

EDIT: See next post.

Regards,
Friedl.

1 Like

Hi @andrewb1230 -

ok… I spent more time going through your code trying to debug. I don’t have all the hardware required, but I put several digitalWrite checks to see whether I can fin out where things go wrong i.e.:

        digitalWrite(D7, HIGH);
        delay(200);
        digitalWrite(D7, LOW);
        delay(200);

Ok, so what I have found is that if I comment out all your LCD code, the sketch seems to run smoothly and keep running. As soon as I implement the LCD code, it passes through void setup(); but never enters void loop();. This seems to correspond to your video.

Here is a link to the code that seems to be runnign smoothly with two ‘debug checks’ on D7 LED. First one in void setup(); (fast blinking LED) and then slower blinking LED when void loop(); is executing .

If it was me, would see whether the pumps are being controlled as intended without the LCD code present and monitor your events in Particle Cloud. If this is indeed the case, the bug is somewhere in the LCD code.

I| a not sure what the cause is, but at least it is a start :wink:

Regards Friedl.

2 Likes

Hi @friedl_1977,

Thank you so much for going through my code and figuring that out! I will use that knowledge to try and troubleshoot further and find a solution. @ScruffR I am going to do some testing over the next few days and see what I can figure out.

Thank you both so much for helping me!
-Andrew Brown

1 Like

I have seen one point that may cause issues when reworking your code some time in the future
You have defined const int numData = 30 but here you are using 30 as literal.
The issue will arise if you ever decided to change numData to something less than 30 which would result in a hard fault.

You also seem to be using an always uninitialised takeDataDelayTime in your loop() - I can’t imagine this is intentional.
I guess you’d rather want this

  static unsigned long takeDataDelayTime = 0;

BTW, we also advise against the use of String and rather opt for C-strings (aka character arrays).
And the comment here is not correct

 int interval = (6 * 1000);     // Interval between readings (First number is minutes)

The first number is seconds not minutes

1 Like

I will look bit further today. Good luck!!