Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can cause Arduino to continuously restart?

Tags:

arduino

I have an Arduino Uno with a 3g shield and am using a Software Serial port on pin 6, 7 and the usb port for debug. After doing well for days, now my program seems to start over and over again (I see that thanks to a println in the setup function) - I added some code, to be honest. Any suggestion about possible reasons?

like image 473
user1737538 Avatar asked Oct 29 '25 09:10

user1737538


2 Answers

Because you are using pin 6 and 7 with SoftwareSerial, the autoreset on serial connection start does not apply. It would if you use the "standard" 0 and 1 pin which are connected on the USB.

This kind of bug happens in many cases, normally is HW related (attached hardware use too much current, are you using an external charger or power by usb?) or because you are out of ram. Check if you have enough Available Memory

What code did you add? You say you are experienced in C#, so did you remember to clean your garbage? C/C++ does not have a garbage collector that does that for you.

like image 151
Lesto Avatar answered Oct 31 '25 12:10

Lesto


The Arduino has much less memory then you are probably used to, so if are recursively calling a function intentionally or indirectly you could run out of memory.

If you are using a lot of strings it could also use all of your memory.

Can you divide and conquer to determine specifically what routine is causing the reset?

I would start by commenting out half of the main loop and see if it still resets?

like image 21
Jeff Avatar answered Oct 31 '25 13:10

Jeff