I bout yesterday one sainsmart 2 relay board module and i can make it work correctly.
I read some posts on forum but I can't still trigger it correctly.
Connection:
12V positive terminal ---> VCC on relay board
12V negative terminal ---> GND
GND from relay board and GND from arduino are connected together
Arduino PIN 12 ---> IN2 on relay board
5K resistor is set on IN line of relay
jumper is in JD-VCC position
If i connect power source and if I shortly connect pin 12 with IN2, i get clear relay click.
This would be OK but i didn't send any impulse from that pin ( or any other ) so this should not happen. Shortly, if i connect IN and pin 12 relay is in trigger state and always ON
I tested with other pins and the situation is the same.
Relay is all the time ON and i can not control it.
Btw. only pin that i use for testing ( ON / OFF ) relay is pin 12 but like i wrote,
regardless which pin i use, relay is always on, when connected with arduino's PIN.
Well, that 12 V one is really dangerous to use with an Arduino, but with a modicum of luck, you have not managed to fry your Arduino (yet).
Did you say you have a 5k resistor between the Arduino pin 12 and the "IN" terminal on the relay board? That would mitigate the blunder and limit the current on the protection diode of the Arduino to no more than a couple of milliamps. In fact, once the Arduino has booted and set pinMode as OUTPUT, the output driver will protect the protection diode!
OK, now you can use this 12 V relay module with an Arduino (or other microcontroller).
The (12 V) relay supply is connected between "JD-VCC" and "GND" on the relay board. The link between "JD-VCC" and VCC must be removed (in fact should be removed in every case using these modules). VCC must connect to the Arduino 5 V and the Arduino ground should not connect to "GND" on the relay module. The relevant "IN" pin on the board goes directly to the chosen Arduino output pin.
Note that the relay is actuated when the output is written LOW and for that reason, you must digitalWrite the pin HIGH before setting pinMode as OUTPUT to prevent the relay flicking on during setup().
arnix:
VCC must connect to the Arduino 5 V
*** Why ?. It's 12V relay. Please be so kind to elaborate this so i can change the picture and wires.
Look at the diagram in post#5.
The photo diode circuit is connected to VCC and IN.
Ground is not used on the primary side of the opto coupler.
So DON't connect relay ground to Arduino ground.
If you do, you loose opto isolation.
I will repeat what Paul__B already has said, because it seems you didn't read it.
Remove the jumper.
Connect a 12volt supply to JD-VCC and GND (two outside pins of the 3-pin connector).
Connect VCC (from the 4-pin connector) to Arduino's 5volt pin.
Connect the relevant IN pin to an Arduino output pin (no resistor).
Reverse logic. LOW is relay ON, HIGH is relay OFF.
Follow Paul's instructions to avoid chattering during bootup.
Leo..