Project hangs randomly

Hi guys,

I’ve been working on a rather large project for a while (atmega 328p, 5V). It reads values from several sensors and uploads these values to ThingSpeak using a SIM800L GSM card every 10mins. It is powered by a USB power supply.

It’s working fine for a long time and than suddenly fails sometimes after 10hrs, sometimes after 20hrs or even 30 hrs. Symptoms:

  • no data is uploaded anymore
  • the internal LED flashes very quickly
  • pressing the RESET button does not work
  • A power cycle (remove the power) makes it work again

The most obvious cause would be a memory leak I guess.
What I don’t understand is how the “crash time” can vary so much.

No code so no specific help is possible.
Generally speaking there are a few things that can cause that behavior.
Running out of SRAM memory, like you say, is one.
Another is writing and/or reading from memory you don't own as in beyond the bounds of an array.
Another is using the String class In the small memory space can cause memory fragmentation.

Though not responding to the reset button is puzzling.

Thanks for your reply!
Do you have any idea how can it differ so much in duration?

Post the code, using code tags.

FrankNL:
. . .
Do you have any idea how can it differ so much in duration?

I'll just add to the general suggestions:

  1. I guess that if a hardware reset of your Arduino does not clear the problems, another peripheral (say the gprs/gsm card) is causing the problem.
  2. You are maybe violating the conditions of your plan with Thingspeak, and you are being denied service from time to time.
  3. You are writing to a serial port without first issuing a Serial.begin() command.

But this is all speculation. A schematic in addition to the code you've already been asked for, would be good.

6v6gt:
I'll just add to the general suggestions:

  1. I guess that if a hardware reset of your Arduino does not clear the problems, another peripheral (say the gprs/gsm card) is causing the problem.
  2. You are maybe violating the conditions of your plan with Thingspeak, and you are being denied service from time to time.
  3. You are writing to a serial port without first issuing a Serial.begin() command.

But this is all speculation. A schematic in addition to the code you've already been asked for, would be good.

Hi,
Thanks!
It's not ThingSpeak and not writing to a serial port, so that leaves the SIM800L card.
But how could a SIM card issue hang the arduino itself??

jremington:
Post the code, using code tags.

I'd rather have a more generic discussion first.
What could cause the arduino to hange "beyond reset"?

I think that we have pretty much exhausted all the guesses as to why your code won't work.

“ I'd rather have a more generic discussion first. ”

You are asking for our help then insist on your terms. :o

Good luck with this.


Maybe have a generic look at forum posting rules.

What could cause the arduino to hange "beyond reset"?

Your programming mistakes.

FrankNL:
Hi,
Thanks!
It's not ThingSpeak and not writing to a serial port, so that leaves the SIM800L card.
But how could a SIM card issue hang the arduino itself??

What you have said so far is that a reset of the Arduino does not clear the problem, which implies that something else is blocking activity. Apart from the fact that nothing is getting to ThingSpeak, what, if anything, makes you believe the Arduino itself is hanging ?

Anyway, look here: for a good description of the SIM800L GSM card: https://lastminuteengineers.com/sim800l-gsm-module-arduino-tutorial/

  1. The maximum power requirements exceed what an USB can deliver. It is also not 5volt tolerant.
  2. It has a reset pin which, next time it crashes, you could short to ground as a trouble shooting measure to see if that clears the problem.
  3. You could redesign your circuit so that if the arduino restarts, then the power to the SIM800L is interrupted, forcing it also to restart. This gives you the option of using the watchdog timer to force a complete restart if there is a hang. Use a mosfet to do this.