1

I've been working on a project for awhile now, and I ran into a problem a week ago I couldn't solve. I'm using an Arduino uno R3.

My project involves the use of 4 relays triggered by the digital pins. Write a HIGH value, relay clicks. Write a LOW value, relay unclicks. Rather simple.

One day, I come back to it to discover it can no longer click the relays. No changes were made to my code that worked previously. The relay light came on, but no click. Could it be that I sent HIGH to 4 at the same time? My theory is that I could've drawn too much power at the same time, weakening it in a way that causes it to not output as much as it did previously.

I tested a relay on a different board and it works perfectly fine.

Juraj
18.3k4 gold badges31 silver badges49 bronze badges
asked Apr 6, 2021 at 5:50
6
  • 1
    how are the relays powered? Commented Apr 6, 2021 at 6:12
  • The relay has 3 pins. 5V in, GND, and signal. It's powered by the board. Reconnecting the signal wire from the PWM pin to the 5V triggered the relay, so it's not a voltage problem or a relay problem. I've also tested many relays Commented Apr 6, 2021 at 8:47
  • 1
    stop calling it PWM pin. it is a digital pin. you don't use PWM to control a relay Commented Apr 6, 2021 at 10:15
  • 3
    Relays need a certain current and Arduino pins can only provide a small amount of current. Normally you don't power the relay coil directly from a pin. Please post a schematics of your wiring, as well as a reference or datasheet for the relay you're using. Commented Apr 6, 2021 at 13:19
  • Are you recommending I use the relay in a different way? I'm unable to provide a visual diagram for my wiring, but it goes like this: 5V power to DC+; GND to DC-; PIN6 to IN1. Commented Apr 7, 2021 at 2:02

1 Answer 1

3

Not knowing the reference of your relay, my answer is generic but should suit your needs.

Relays need 2 things in order to work properly: a sufficient voltage source, and one that can provide enough current.
The Arduino output pins provide 5V on 5V boards or 3.3V on 3.3V boards. BUT, most Arduino GPIO can provide only 20 mA of current. That might not be enough for your relay. The solution here is to use a transistor to drive the relay.
Also, relay coils are inductive loads that generate voltage spikes when current is turned off. That voltage can rise much higher than 5V and damage your Arduino pins and weaken or destroy them. The solution to this problem is to add a flyback diode.

This is what a typical circuit with relay driven by an Arduino looks like:

enter image description here

When the Arduino pin is LOW, the transistor is turned off and no current goes through the relay.
When the Arduino pin turned ON, the transistor turns on fully saturated and the relay coil is energized.
When the Arduino pin is turned LOW, the coil generates a negative voltage and current is allowed to go through the diode, dissipating energy in the relay coil. More information on flyback diodes: https://en.wikipedia.org/wiki/Flyback_diode

answered Apr 7, 2021 at 7:32
6
  • inductive loads generate reverse voltage spike when it is turned OFF Commented Apr 7, 2021 at 8:12
  • Well-spotted, thx. Commented Apr 7, 2021 at 8:13
  • There is another thing: the SUM of currents (driving or sinking), may be a thing. Despite proper operation of one relay, even two, when situation comes to drive all relays this may be too much when all currents add. For ATMEGA328P-PU sum of currents may not exceed 200mA. Recommended lecture: Arduino Uno R3 microprocessor's datasheet (ATMega328P-PU) Commented Apr 7, 2021 at 10:09
  • For 4 relays, the OP would be limited by the per pin current limitation way before being limited by the per chip limitatation. Using a transistor would reduce the current provided by the chip to way below both limits. Commented Apr 7, 2021 at 12:35
  • Post a link to the relay you are using, I do not know if it is a plane relay or a relay module for the arduino. The modules are less then a buck from your favorite china supplier. Commented Apr 7, 2021 at 20:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.