enter image description here Above is relay I'm using and everything works as expected using diagram below.

I will add 1n4148 diode on IN line for safety and will connect VCC to power supply before Pi. enter image description here

  1. Can I use ground (GND) for relay from Pi or should I connect to power supply ground before Pi?
  2. Do I need to add anything else for relay to work safely and reliably? I know people recommend having resistor and transistor on IN line too, but are these necessary in this particular type of relay? Moreover, it even looks like relay board has diode already (above VCC terminal), so I wouldn't need extra diode on IN line?

I understand such a question can sound silly for electrical engineer, but I'm software engineer venturing in electrical world and need some guidance. Thank you.


I am interpreting the picture of the printed circuit board of the relay module with accompanying notes as follows:

  • the board includes a transistor and a diode - and while it is impossible to tell from the image without looking at the wiring and/or schematics - it is reasonable to believe this is the freewheel diode you're refering to. Conclusion here: no additional diode is needed.

  • the pin labelled "IN" reads "This module is low-level trigger, the voltage value between 0-1.2V". So pulling this pin low (think connecting to GND or setting an output GPIO pin to LOW) will trigger the relay. Setting the GPIO pin HIGH (and thus outputting a voltage greater than 1.2 V) will untrigger the relay. No additional components needed in connecting "IN" to a GPIO pin of the Pi1.

  • the pin labelled "GND" should be connected to the Pi (which is of course connected the the Pi's PSU and thus the PSU's GND). No large currents here, nothing to worry.

  • the pin labelled "VCC" reads "Operation VCC: This voltage is consistent with the operating voltage on the relay". Connect this to the 5V rail of the Pi's GPIO connector.

Have a look at this excellent arcticle and my answer to another question.

1 Usually a series resistor (in the range of 1..10 kOhm) between the GPIO output pin and the base of the transistor (supposedly connected somehow to the "IN" pin) would be the way to go. From the trace on the board it would seem that the middle resistor (1 kOhm) is attached to the "IN" pin serving exactly this purpose. You could easily check this with an Ohmmeter or following the traces on the board. If it does - no need for any external components.

  • 1
    I've tested components on board and can confirm it has: - three 102 resistors rated and measured at 1 kohm, - one 2TY transistor, - one diode without markings. Thank you very much for your answer, I hope this topic will be helpful for others too. – goodevil Oct 4 '17 at 17:28
  • FYI - If you'd care to weigh in on this, would like to have your feedback. – Seamus Nov 24 '20 at 19:34

The Relay module in your picture is what so called Relay shield specific designed for directly interfacing with micro controller such as Raspberry Pi or Arduino, the board already consists of the protection diode and switching transistor and active/disabled LED indicator.

You can connect 5v, GND, and GPIO directly to VCC, GND, and IN at the shield.

To test it out before you applying high voltage source to the Relay, connect an AAA battery (Positive) to the anode of LED, and the cathode of the LED to the NO of the Relay. The COM of the relay connect to the negative of the AAA battery. When you activate the GPIO through program, the COM and NO should formed a closed circuit between the LED and the AAA battery. The green LED on the Relay Shield should also turned on indicating that the GPIO pin is pulled to low.

  • I'll already tested wiring and relay using LED before posting. Thank you for the answer. As Ghanima was a bit more explicit I've marked his answer as accepted. – goodevil Oct 4 '17 at 17:34

Be careful... the switch side of a relay should be labelled line and load (NC or NO) so the com on the switch side is the Line and either NC or NO is the load. This may be obvious to some but the test described in the comments using positive on one terminal and neg on COM would not work with AC (line/neutral).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.