I have an Arduino Uno I have been messing around with for the last month or so. I thought of a good project to do and it is going to require powering 8 relays, each on a different circuit, therefore requiring power from 8 different pins on the arduino. It also takes 5 volts to power on the relays. So I hooked a relay up to a digital output pin and it wouldn't turn it on. However a PWM output pin at 255 would turn it on. My multimeter shows that the digital pin outputs 1.73 volts while the PWM at 255 outputs 5 volts. So it seems that if I want to power 8 relays, I am going to need the Arduino Mega on account of that board has enough PWM pins. Why is it that the output of the digital pins is 1.73 volts and not 5? Or am I missing something? Thanks guys!
In your sketch, did you include
If not, the pins default to inputs. 1.73V sounds like an input pin with no internal pullup turned on.
In your sketch, did you include
calls to analogWrite set the pin to output.
Why are you powering relays with PWM?
I thought I did the pinMode(pinX, OUTPUT) however not doing that is a stupid mistake I would make.
As for the second reply, I was only using the PWM because I wasn't getting 5 volts from the digital pin which was the voltage required to turn the relay on.
I'll go back and make sure I declared the pinMode today after work. Thanks!
Your relay is taking too much current from the arduino pin and as a consistence it is damaging the pin. You found that by applying a PWM you could get the relay to close. This is because you can get a higher peak current than a sustained current from an arduino output pin. It is still going to kill your arduino but it is higher. I found that I could get currents up to 250mA pulsed from a pin, that is mighty abuse and that is what you are doing. See:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html So drive your relay with a transistor and stop killing your arduino.
Okay, you were right CrossRoads. I actually declared pinMode(relay, HIGH) to begin with. So now I get 5 volts.
As for Grumpy_Mikes comment, the relay now turns on with 5V from the digital pin. Should I still be worried about frying my Arduino? Nominal coil current for my relay is 89.3 mA. I happen to not have an Ammeter with me right now.
Thanks so much guys!
As for Grumpy_Mikes comment, the relay now turns on with 5V from the digital pin. Should I still be worried about frying my Arduino?
Absolute Maximum Current Rating for I/O pins is 40mA, as noted in the datasheet. Also noted in the datasheet is operating at Absolute Maximum will eventually damage the ATmega328.
So if your coil is drawing more than 30mA you can be sure eventually you will destroy the I/O pin.
Nominal coil current for my relay is 89.3 mA.
89.3mA > 30mA
This is making a lot of sense. So is there a safe way to use my current relays or will I need to get relays that draw less current?
goPlayYourGuitar: This is making a lot of sense. So is there a safe way to use my current relays or will I need to get relays that draw less current?
You simply need to use a transistor to switch the relay on and off, the arduino output pin will drive the transistor. Tons of examples around.