Relay switch not working

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

void setup() {
pinMode(6, OUTPUT);
}

void loop() {
digitalWrite(6, HIGH);
delay(3000);
digitalWrite(6, LOW);
delay(3000);
}

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

https://www.parallax.com/sites/default/files/styles/full-size-product/public/27115a.png?itok=rf7_zs6J

Please use code tags (</>-Button).

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.

Or buy a 5V compatible relais module.

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!

lg, couka

How do you have the relay connected

Line should go to common and the lamp wire should go to no

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.

lg, couka

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?

Search for "arduino relay"

lg, couka

That didnt help me at all

I won't explain it to you, I'm sorry. This is a very trivial task and you can easily find tutorials on that.

lg, couka

Hi,
OPs relay.

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.

Thanks... Tom... :slight_smile:

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.

Do we know yet if the OP has a common GND with the relay module ?

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.

Have you measured the coil resistance yet ?

couka:
... Keep your ear away from mains when you try to listen to it!

lg, couka

Post of the Week!

This is the way I connected a relay to my Arduino.

The post explains the details Control AC/DC devices using Arduino | Sony Arouje

As several members mentioned here, never power relay directly from Arduino 5v instead use a separate power source.

If you are doing every thing right, might be the relay module is bad. I tried several Chinese relays and couple of them were faulty ones.

Before you connect AC device, try with some DC device (may be a DC motor) and see whether you can on/off those DC devices.

The arduino is ok with 8.4V on Vin but that's too much for the relay input which should be 5V unless that pin is labeled Vin.

ChrisTenone:
Post of the Week!

Thank you, I guess :smiley:

lg, couka

You don't really think he would put his ear on the mains do you ?
I just assumed you were joking.

I assumed so too, and yes, couka's admonition was funny.

He might as well have said:
" contrary to popular belief , the tonque is not a good substitute for a meter when measuring .mains voltage..."