Connect a 12V/220V Relay to Arduino

Hello guys ,
I have a relay ( SKU : 19-RLY-00001 ) from http://grobotronics.com/relay-module-1-channel.html?currency=USD&sl=en and i would like to help me with the connections on both sides !
Which cable i connect in each hole and i have to program it as a digital switch ?
Like :

 if (that) 
{switchstate == LOW 
}
else
{switchstate == HIGH
}

?

Thank you in advance

There is no mention of a driver transistor for the relay. You cannot connect a relay directly to the Arduino pins unless you want to risk damaging the Arduino.

To connect the output of the relay to control you load, you need to use the normally open contacts only. These are used as a simple switch in series between the power and the load with the other side of the load going back to the other side of the power.

YOU HAVE NOT MENTIONED WHAT YOU ARE GOING TO CONTROL SO PLEASE READ THE FOLLOWING.

MAINS POWER IS LETHAL. UNLESS YOU KNOW WHAT YOU ARE DOING, DON'T DO IT.

IF YOU INSIST ON DOING IT, TRY THE SWITCHING ON A LOW VOLTAGE FIRST (Use a battery and LED with a resistor)

REMEMBER THAT THE BOTTOM OF THE BOARD WILL ALSO BE LIVE ON THE PCB TRACKS.

Weedpharma

Ok i understand and thank you for your concern !
I ensure you that we have taken all the right precautions !!!!
I did found this The MicroController and Embedded System Store

And the user manual as an attachment !

I want to connect arduino to relay and get lights on or lights of in a lamp in the first place !

Why i can't connect the relay pins directly to arduino ?

Thank you in advance!

27115-Single-Relay-Board-Guide-v1.0.pdf (92.9 KB)

A clearer picture shows a transistor (Q1) so it looks like the board can be connected directly.

If there is no driver transistor, the coil current or back EMF can damage the output.

Weedpharma

Super easy.

On the Arduino side:

S = your digital output pin

  • = 5v from your Arduino
  • = ground

On the other side you have NC & NO. That stands for "normally open" and "normally closed," so if you wire your output up so that you're on the N.O. side, when you say switchState = HIGH, the contacts close and you connect a circuit (like turning on a light). Then, if you wire it so that the two wires are on the N.C. side, when you say switchState = HIGH, you make a open the circuit, and turn whatever you had connected to the relay off.

The spec sheet on the relay pretty well tells how to use it. One thing that immediately caught my eye and that is that it requires 85ma so you cannot drive it directly from an Arduino board.

That 85mA would be from the supply, not through the IO pin.

Weedpharma

Power to the relay should come from an external source, should not power it from your Arduino.

Both Relay module and Arduino should have a common ground.

A digital output from your Arduino should connect to 'S' pin, if input to S is high then Relay will get activated, low will deactivate it.

Attached the fritzing diagram shows how to connect a Relay to Arduino. In the diagram I used a 3.7v battery as a power source, you should connect a 12v source. Also I connected the power directly to Arduino VIN. You can use a USB to power it, if used USB then connect only GND to input DC GND.