Hi all,

I have a strange problem with my project that causes my Arduino to freeze after a while. First of all a few details regarding my project:

Arduino Uno + Ethernet Shield + DHT sensor + 2Relay used to post and receives data from/to an apache server.

So here is the problem: In the sketch im using a lot of Serial.println statements (for debugging purposes). Now that the project has finished I did not remove the println statements. If I connect the Arduino to my PC's usb port the system runs smoothly non stop (for more than a week so far). If i power the arduino using a usb adapter (similar to the one used for my mobile phone) the system halts after a while (from 20-30 minutes to...three four hours). I tried various things like different adapters (from 0.5 to 2mah all 5v), or changing the wiring, etc. Nothing has worked so far so Im starting to believe that it is caused my the Serial.print statement. I havent tried yet removing all those lines, will do so soon, however....isnt that strange? What is difference between powering the arduino using the usb port and a usb adapter in terms of the Serial.println command?

Regards Chris

I have no clue what could be different. If I understand serial transmission correctly, data is always sent regardless of the other side is listening or even not present. There are many bad USB adapters out there :-( Did you use a good one? Did you add additional filtering? If you can afford to sacrifice a USB cable, try this: carefully cut the data lines (the green and white wire) inside the cable and connect your Arduino to your computer as before. This way you are effectively only using the computer's power. If it works, the problem is with your USB adapter, if it doesn't the problem is indeed with serial.print.

You can easily turn off all the Serial prints in your code by adding these lines somewhere above your setup():

#define DEBUG true  //set to true for debug output, false for no debug ouput
#define Serial if(DEBUG)Serial

I can be useful to leave the debug output in your code in case you need it later for troubleshooting. This system allows you to turn them on/off without adding a lot of extra code to your sketch and the Serial prints don't use any memory when they're turned off.

As far as I know, there is no reason that Serial.print/ln will halt / crash the system.

How do you power your relays? Do you use a separate power supply for them in both scenarios? Or is the same power supply used for relay and Arduino if you don't use the USB?

Need help again! There is a strange problem with my project. It runs smoothly when the arduino is connected to my usb port, but when I connect it on a usb power adapter it hangs after a while. What causes that? So far i have tested the following:

  • Removed any powerwiring to the two RELAYS
  • Remove all the println code
  • Changed the size of the char arrays to 5 and changed all values to null on the begining of the loop
  • Tried various usb power adapters from 0.8mah to 2mah and also a 12v power adapter.

I changed arduino's (i tested the sketch on both a genuino uno and an arduino uno). Ive reached a deadend and although the code is complicated im sure it is a hardware related or a power supply issue.

Any suggestions are welcome!!!

p.s When I power up the arduino from a usb port it works ok. However no input/output is connected on the RELAYS.

just a shameless plug but i have built a hud for my arduino -> php -> mysql -> HTML/PHP/Javascript Thing.... you can see the hud in action with live data here: Link

Problem solved. I used a 12v power supply.

@bitaris, stop cross-posting. Thread locked.