So I am trying to control the lamp in my living room with my arduino uno. So to make sure i didn't fry my arduino i used a single relay module. So to make sure i didn't ruin my lamp cord i got an extension cord. I then separated the two sections of the cord and cut one of them in half. I took one end of the cut cord and put it into the 'COM' socket of the relay. I took the other part of the cut wire and put it into the 'NO' socket. I then plugged the the lamp into the end of the extension cord. After that i hooked up the relay board to the arduino uno. the 'S' pin(which is signal pin) to pin 6 of the arduino board. I wired the '+' pin to 5v and the "-" pin to ground. After that I uploaded this sketch to the arduino board
After i did that i gave the board a 9v battery source and let the program run. This is supposed to make the lamp turn on/off but it doesnt, even though the light on the relay flashes on and off when its supposed to and the lamp's switch is in the on position as well. Why is this not working? Please help me out. This is what the relay looks like
Is there anything else between relais and arduino? You can't drive a relais directly by the I/O-Pins. The available current is too low and the back EMF of the coil is likely to fry your arduino.
You need a transistor, a resistor and a diode to do that.
If you are using such a module it should work. Can you hear the relais clicking when it switches? Keep your ear away from mains when you try to listen to it!
Qdeathstar:
Line should go to common and the lamp wire should go to no
I think that's about what he did. I don't see a problem there.
Sharpchain:
I took one end of the cut cord and put it into the 'COM' socket of the relay. I took the other part of the cut wire and put it into the 'NO' socket.
The relay i showed in the picture is about the same as one in your link right? and no i dont hear any clicking when it turns on/off. Also if my relay is not the one you were talking about, how high ohm resistor should i apply and to which pin do i apply it to? and to which pins do i apply the diod and the transistor to?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
A picture of your connections will help.
Can you hear the relay operating when the LED comes ON?
We need to see the connections between the relay and the arduino, as well as your power connections for the lamp.
Here's a link to your relay board. It already has the required driver circuit (transistor, diode, resistor) and an indicator led. However, it does not have opto-isolation.
The relay has 3 terminals to use for load switching. Note which terminals are Normally Closed (NC), Normally Open (NO) and Common (COM). There are white silkscreen labels (partially obstructed by the terminal block) that identify the NO and NC terminals (the NC is at the "Keyes_SRly" side, the COM is the middle terminal).
To switch the load, usually only the COM and NO terminals are used ... if you're using the NC and NO terminals, nothing will happen.
Please refer to Tom's reply so we can get more information.
Perhaps the 9V battery cooked the coil ... it's only a 5V coil on the relay.
Did you hook it up as in the "Quick-Start Circuit" here?
The relay module would require about 80-90mA ... does your Arduino have enough reserve current available?
If your powering the Arduino's with 12V, there may not be enough reserve current available ... you may need a separate 5V power source for the relay module.
If you're powering the UNO through USB, the only way to guarantee 500mA available is to use a USB hub with power adapter connected, otherwise the USB port might be limited to 100mA or some other value.
My recommendation is to just try a separate 5V power source for the relay module and see if it works.