I'm building a control box to provide logical control of power outlets.

I'm using a 4 channel 5V optically isolated relay system to control 4 separate outlets.

To use optical isolation you connect arduino +5V to the VCC line, and logic inputs to the 4 channels of the relay unit, and connect a separate +5V supply to run the coils of the relays.

To energize one of the relays, you pull that control line LOW. To de-energize the coil, you drive the line HIGH.

If I power on the relay but leave the Arduino unpowered, all the relay coils energize.

Do Arduino pins float when it is powered down, or are they grounded?

Could I wire a pullup resistor to the inputs? And how would I do that without losing optical isolation? If I connect my pullup resistors to the +5V for the relays, the relay's +5 is connected to the Arduino's logic lines. If I instead use the Arudino's +5 rail, then when the Arduino is powered down, it's +5V line is dead.

  • Did you remove the jumper between VCC to JD-VCC? – Gerben Jan 28 '19 at 16:09
  • PS why do you want optical isolation? The relays already provide galvanic isolation. – Gerben Jan 28 '19 at 16:11
  • Yes, I removed the jumper so the 2 +5v supplies are isolated. – Duncan C Jan 28 '19 at 20:49
  • connect the opto-isolator LED between two of the digital pins ..... if the pins float or if the pins are both the same level then the opto-isolator will not activate – jsotola Jan 29 '19 at 7:23
  • You mean use one of the Arduino pins as the VCC for the Arduino, and the other as the logic input? Then use the pin connected to VCC as a power switch? I like it. It still doesn't protect the Arduino from +5 coming into it's logic lines while the Arduino is unpowered however. – Duncan C Jan 29 '19 at 14:45

The pins have input protection diodes that clamp the pins to Vcc and Gnd. If a pin gets to >VCC +0.5V the positive diode clamp conducts and Vcc is powered via the internal Vcc bus, and if a pin get to < -0.5V the negative diode clamp conducts. With Vcc = 0V, the pin could act as if it were a low, but more generally folks see the chip acting like it was phantom powered and attempting to run code with perhaps unpredictable results. That's why the datasheet says to not drive the pins when th chip is unpowered. If the clamp current becomes too much, the diode can blow, and either just the one pin is impacted, or the whole chip dies and it will feel warm/hot to the touch when powered up.

So don't power up the relays without also powering up the Arduino.

  • the circuit is wired only to Arduino VCC and pin on the LED side of the optocoupler i.stack.imgur.com/14WTN.jpg – Juraj Jan 28 '19 at 15:31
  • Hmm, that doesn't seem like the Opto could be turning on its output transistor then. Some relay boards have a jumper that connects the VCCs together. If you measure pins 1 and 4, is 1 low and 4 high? – CrossRoads Jan 28 '19 at 15:42
  • My goal is to not power the relay without powering the Arduino. However, it would be bad if the AC power is on and the relay's power supply is "lit" but the Arduino's power supply fails or the Arduino fails to power up. In that case my outlets would all be turned on. – Duncan C Jan 28 '19 at 18:31
  • I have my project built so I can plug a computer into the Arduino's USB, in which case it draws it's power from USB and the relay is powered from a separate supply. – Duncan C Jan 28 '19 at 18:36
  • That would work. Or use a 5V wallwart into the USB connector to keep the Arduino powered, if you don't need PC connectivity all the time. – CrossRoads Jan 28 '19 at 19:25

As it turns out my question was a bit of an X/Y problem. I wanted to know what the pins on the Arduino do when the board is unpowered, because I was feeding +5V into the VCC input on my relay board when the Arduino was unpowered, and having the relay control lines connected to Arduino pins.

If you remove the jumper on my relay board, it has a VCC line that ONLY powers the logic level inputs to the relay control optical isolators and a JVCC line that drives the relay coils. (The VCC line might also power the optical isolators and the other CMOS circuitry on the board, I'm not sure.)

I have my Arduino wired to a USB input that is driven by a regulated AC power supply when it's running stand-alone, and from my computer when it's being programmed. Sometimes I forget to plug the AC powered USB cable into the Arduino when I switch to running it stand-alone off of AC, and in those cases the relay lines tend to energize when I don't want to, and I end up driving +5V into the Arduino's relay control GPIO lines, which is not a good idea.

The simple answer is to connect the +5V line from the Arduino to the VCC pin on the relay board. Then when the relay's JVCC is powered but the Arduino is not, the VCC line to the relay and the control lines to the relay are all unpowered, so the relay is off.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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