I have an Uno that loops processing serial commands and reading from a DHT11 sensor. For whatever reason, the device often stops responding. I put an LED on a pin and gave it a blink to see whether the loop is running, and sure enough the loop() stops running (the LED stays ON or OFF, depending on when it froze). I enabled the watchdog at 2 seconds, but it does not reset the device [it still stays frozen, even though wdt_reset() is called at basically the same time as the blinking LED is toggled].

I then tried various combinations of BaudRate=1200 (or 9600), Open(), Close(), DtrEnable=true [on both the Uno and the Mega], yet none of the combinations would make the device reset. The device will reset, however, if I re-upload the sketch using the Arduino IDE. I would like to emulate this resetting functionality from my own program's code. Reading on the official site, it sounds like the Baud=1200 reset feature is available only on certain models (not the Uno or Mega).

My code is by no means simple as I am no beginner when it comes to programming. This is the first time, however, that I have had a finicky unit that freezes all the time (say between 10 minutes and 2 hours into running). I merely want to reset the unit from the PC using code, like the Arduino IDE does. On the other hand, if the watchdog worked correctly, that would be fine as well. At the same time, I am not that experienced with electronic circuits, so making a circuit that would "press" the "reset" pin when the LED stops blinking is not something I am quite ready to do. Plus, I do not want to add a bunch more components if the job can be done through code.

On a side note, the Serial connection appears to be fully functional the whole time. The LED on the unit that indicates receiving from the PC continues to function whenever I send data to the device. I can connect and reconnect without any apparent issues. Plus, the Arduino IDE has no problem uploading new sketches and resetting the device. Naturally, no data is received from the device after it freezes (until it gets reset, of course).

Update 1: I made a simple sketch (see below) that would run for about 20 seconds and then let the WDT watchdog timeout do its thing. Result: (a) Running the code on an Arduino-brand Mega 2560, the device simply resets every 20 seconds and keeps blinking; (b) Running the code on a generic (made in China) Uno R3, at timeout the L light turns on and the device becomes completely unresponsive (not even the reset button or the Arduino IDE can save it); It must be unplugged to reset it. (c) Running the code on an Arduino-brand Uno R3 works as expected, just like on the Mega 2560.

#include <avr/wdt.h>
void setup() {
  pinMode(A5, OUTPUT);
unsigned int LoopCount = 0;
bool TestLED = false;
void loop() {
  if(LoopCount % 300 == 0){
    TestLED = !TestLED;
    digitalWrite(A5, TestLED ? HIGH:LOW);
    if(LoopCount < 20000)

Nevertheless, I still would like if someone could provide a solution in terms of resetting a frozen generic Uno from Serial in .NET code -- not the WDT frozen, but the normal frozen (of unknown origin). I may be the one coding, but I'm unfortunately not the one deciding which units are put into production.

Update 2: I switched the EasyDriver to its own power source, where the only things in common with the stepper and the Arduino were the ground and the two signal wires. The generic Uno board ended up being even more problematic, going into a new freeze mode (after just a minute or two, pretty reliably) where the L light would blink very quickly. I'm not sure whether it had anything to do with toggling of the DtrEnable property, but I decided to stop messing with the generic board for the time being. The name-brand Uno appeared to freeze occasionally or malfunction as well with the original wiring, but the Watchdog did its thing and reset it straight away every time. Also, I tried toggling the RtsEnable property with the generic board, but it didn't seem to make a difference. The board would become unresponsive and unrevivable, even from the Arduino IDE.

Some more background: The reliability problem only really started to surface when I hooked up the DHT11 temperature sensor, even though the freezing would tend to happen only when the stepper motor was running. I have the DHT11 hooked up exactly as advocated by Adafruit, and it tends to read correctly most of the time.

Update 3: I was thinking maybe the SainSmart Mega2560 would be different from the no-name generic I was using. After getting one and hooking it up, I have found it to have the exact same problem. The SainSmart CPU crashes between 5 and 15 minutes into running. The serial chip (or module) keeps going as you can still see the serial lights change when you send to it. However, the on-board reset button does nothing, and the Arduino IDE cannot upload to the device or reset it. Only a power cycle can save it.

  • Uno resets whenever a serial connection is established (which is how the IDE is able to reset it to re-upload your sketch). Disconnect/reconnecting your serial terminal should cause the same reset. It's very strange that the WDT doesn't reset it, though.
    – JRobert
    Dec 3, 2015 at 2:38
  • 1
    Agree with @JRobert - I've never seen a case where the WDT didn't reset the chip except when the chip was permanently fryed. Are you sure you are correctly enabling the WDT and not setting it to interrupt only mode? Posting code would help. The Arduino IDE resets the board by toggling the DTR line on the serial connection. This in turn pulls the RESET pin on the chip low long enough to reset the chip. But if the chip if can reset via the RESET pin, then it almost certainly should also reset on a WDT timeout.
    – bigjosh
    Dec 3, 2015 at 3:28
  • I probably ought to have mentioned that by serial, I meant USB / virtual serial port. Maybe I was mistaking, but I thought the same software commands that work via a conventional serial connection would also work through USB.
    – Michael
    Dec 3, 2015 at 4:25
  • @bigjosh -- the chip still works. I've had it freeze several times. It doesn't freeze when it's just sitting there blinking. It's when I run a stepper motor for a while (like 20 minutes). There's a possibility that it's electrical in nature, which may mean that the CPU is crashing, but nevertheless the Arduino IDE can reset the device when it freezes like this. When you say "toggling the DTR", what do you mean from a coding perspective? I'm currently working with the SerialPort class in .NET. I'll see if I can reset the device under a non-crash condition using the WDT.
    – Michael
    Dec 3, 2015 at 4:32
  • 1
    Stepper motors crash lots of Arduinos! They make lots of inductive noise and pull lots of power. Try connecting the motors and the motor drivers to a completely different power supply that the arduino. Also try filtering any communications lines between the Arduino and the motor drivers. But even though the crashing is caused by motor induced glitches, the WDT should still bring it back to life. Post your WDT enabling code and we will take a look.
    – bigjosh
    Dec 3, 2015 at 4:37

2 Answers 2


You can reset the Uno over the serial link by toggling the DTR line. How you do that depends on what platform and language you are using. There is a capacitor between the line and the reset pin, so the toggle must last a minimum ammount of time. 0.5 seconds works.

This is ok for just a quick fix hack, but probably better in the long run to (1) figure out why the code is crashing, and/or (2) figure out why WDT is not working.

  • I just tried it, and indeed, simply doing [(1) SerialPort.DtrEnable = true; (2) Sleep(1000); (3) SerialPort.DtrEnable = false;] is enough to make it restart an official Arduino Uno R3 via .NET code. I guess the problem is that this particular generic version doesn't respond the same as the name-brand edition. Presumably this is a feature that sometimes doesn't get tested. At the same time, I haven't had the official one freeze yet in this setup, so I cannot say whether it would reset the same after freezing.
    – Michael
    Dec 3, 2015 at 6:38

Since we don't know the nature of the freeze-up, and the clone-board behaves differently than an Arduino-brand board but we don't know how or why, there's not much more we can offer beyond suggesting you recommend a higher quality board to your management. You surely have reason enough to do so.

The last remaining thing I can think of, and it's kludgey work-around (shame on me) is:

You know the board will come back after a power-cycle. Kludge up a 555 timer circuit that powers-down the board for a second or two, and trigger it from the DTR line. This is really a broken fix for a broken board!

If my management or a client was intent on shipping a product built with these, I'd have to speak up about potential damage to the company's reputation - and possible liability, if a failure could have real consequences someone - and if necessary, write my objections to the next three levels above me. This board should not be shipped in a product.

  • Agreed. I did actually pass on the suggestion that the board probably isn't appropriate for this application. Thanks for the extra input.
    – Michael
    Dec 4, 2015 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.