Relay mysteriously drops out periodically. Adding 5V to USB almost fixes it.

I have a real mystery with my R3 Uno application. It monitors the signals from my house thermostat to determine if the AC compressor is running. If so, it inhibits the running of the water heater, which is also inhibited for times other than between 11AM & 2PM. It functions, with the apparent help of a power kludge . The symptoms are:

  1. If running with 12V to the Uno pwr jack, the water heater relay on Pin4 (NTE R40) drops out every 5 or 6 seconds for a few seconds, then returns to on. This happens even though the sketch has not altered the “HIGH” state.
  2. If 5V is added via the USB jack, the relay does not drop, but the LED driven by Pin3 flickers for about the same time the relay drops out in #1. Other times the LED is on constantly per check of AC running and time of day. Pin3 and Pin4 are controlled in unison by the sketch.

While suspecting a power overload, I wrote a short sketch to cycle the relay and LED on/off (29/1 secs) and try the two power options. No relay drop outs, no LED flicker.

Aside from different logic, the two sketches I’m writing about differ by use of Udp NTP time client code and Serial writing. Otherwise, what else could cause such power or whatever sensitivity?

I considered the Pin4 restriction with the SD card function on the Ethernet shield, but tests using other pins show no difference.

Here are some technical details:
Processor: Arduino Uno R3
Shield: 3rd party Ethernet
12V Supply: reused T-mobile router wall wort rated 12VDC 1.5A
USB 5V supply: Either my laptop or a Nook wall wort rated 5VDC 1.9A
Water heater control: 2-stage relay, NTE-R40 (with protective diode) on Pin4 driving a 24VAC 30A Contactor
Two reed relays for future enhancements on Pins 7&8
T-stat monitoring: Via PS2505 Optoisolator
Best description of the project is the May 7 post at

LiveVerD4MonitorBandDryerDoorX.ino (17.3 KB)

Is the relay driven directly from the pin of the arduino?
This not a good idea, as the pins can only supply 40mA and relays usually consume more than that.
You need to drive the relay coil with a NPN transistor or a N-CH logic level MOSFET.

Tom... :slight_smile:

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks Tom. Yes, the relay is driven directly by the pin. However, because of the 40ma rating of the Arduino, I picked the NTE-40 5/6V relay which has a coil resistance rated at 167 ohms, which is a 30ma load at 5V (double checked with a meter). Simple test scripts & wiring setups do not show the problem on this relay. Those tests did not use the attached Ethernet shield, however.

The circuit diagram is on one of my FaceBook pages at Redirecting...

When power is supplied to both the 12 pin and the USB connector, the relay does not drop out, but an LED on a separate pin that is programmed the same as the relay pin flickers periodically, about as often as the relay drops out when USB power is not supplied.

Thanks for the quick response. I've been checking, but it didn't show up until this time for me.

The relay also hasn't got a kickback diode across.

Are you using a W5100 ethernet shield.
That and the Uno will use 150-200mA.
That could overheat the 5volt regulator if your supply on the DC jack is >9volt.
Put your finger on the regulator (between DC jack and USB jack).

Get a 7.5volt (or 9volt) regulated supply for the DC jack.
Or use a phone charger with USB socket, and plug your USB cable into that.

I would hesitate to use a 30mA relay directly on an Arduino pin.
Three cheap parts could prevent trouble.
A 1k base resistor, A BC547 or similar, and a 1N4148 or 1N4004 diode.

Thanks Leo.

I do use flyback diodes on all of the relays. I’m from the era of vacuum TV picture tubes and the anode voltage was generated using the same physics principle of a quickly collapsing magnet field inducing some pretty high voltages, albeit low current. Sorry for leaving that off, but it was more of a conceptual diagram than a wiring diagram.

I attached a pic of the Ethernet Shield (and the wire-wrapped sideboard). The “brand” looks like MEGA Compatible, but I’m using the standard NTP time retrieval client, so I assume it’s a W5100. I’m not doing anything with the SD slot.

I am feeding it a well regulated 12V (1500ma rating), but have a few 9V wall worts that I can try instead. I’m getting the idea about dissipating heat. I assumed it was a type of switching regulator that turns off/on the current at a rapid rate instead of acting like a resistor and converting the excess power to heat.


ArduinoAndSideboardPic.pdf (651 KB)

I can't see any ground connection in that lot. You need a common ground.

@ Grumpy_Mike
The ground pin next to Aref is used.

And, is the regulator on the Arduino board getting hot?
As said, 12volt on the DC socket and the current draw of the ethernet shield could reset the Arduino.
A couple of relays could be the last drop.
Use a modern switchmode 9volt regulated supply.
500mA should be just ok, 1Amp is perfect.


Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How big is the cap on the output of the opto?

Tom.... :slight_smile:

Good advice gang. I had to order a 9v wall wort, and it eliminated the problem. At 9V, the system draws 210ma when idle, 240ma when the relay that had the problem and its LED are driven and 310ma when all 3 relays and 2 LEDs are driven. The new wall wort is rated at 660ma, so I'm good to go, once I debug the sketch, that is (;-

When I was supplying 12V, I could keep my pinky on the regulators for 4 or 5 secs before it was uncomfortable, so there is not much lea way in our options.

Thank y'all.