Uncategorized

relay loading notes

5V Relay module working but LED not turning on – How to wire?

Ask QuestionAsked yesterdayActive todayViewed 35 times0

I’m trying to control a relay from Raspberry Pi that will switch an LED on/off. The relay is working (lightning up and clicking), but the LED doesn’t turn on.

Here is how I wired everything:

VCC – 5V

IN2 – GPIO pin 19

GND – GND

NC – GND

COM2 – 9V Battery Positive side

I’m aware that the way I wired NC and COM are probably wrong and I would like to know how I should wire the LED side so that it can be controlled from the relay and Raspberry Pi

Thanksledrelayshareedit  follow  close 2flag asked yesterdaypatriciajlim1911 bronze badge

  • 1Welcome and nice to meet you. (1) Your wiring list seems not complete. (2) It is not clear why there is a “COM2”. Do you have a dual relay module with two relays on board, so you have COM1 and COM2? (2) I am using a random relay as an example, so your relay might not match my wiring diagram. (3) It would be nice if you can show us a photo or a link to your relay. Please feel free to ask us any newbie questions. Have a great project! Cheers. – tlfong01 yesterday   
  • I noticed you don’t mention resistors. You claim to have just “wired everything”. If that’s the case, you might have burnt out the LED. Providing exact product ids (or a webpage, at least) would greatly help. – MaxDZ8 6 mins ago

add a comment

1 Answer

ActiveOldestVotes1

Question

(1) How to use Rpi to control a relay to switch on/off a LED?

(2) How to wire the NC and COM terminals of the relay?


ky012


Answer

Introduction

Let us use the following example and look closely at the very right side of the schematic, the relay switch with the COM, NO, and NC terminals:


relay and led

Part A – How to wire the COM and NO terminals

(1) COM (Common) – The COM terminal connects to the power source, eg +5V, +6V, +9V, +12V of a battery.

(2) NO – (Normally Open) – The NO terminal connects to the load, ie the LED, with a series protecting resistor, usually 4k7 to 1k2.

(3) Grd – (Ground) The ground terminal connects to the other end of the load.

(4) NC (Normally Open) – The NC terminal is not used, ie, left open or disconnected.


Part B – How to protect the LED using a series resistor to limit LED current

(1) It is important to connect a protective resistor in series with the LED, otherwise too much current would flow through the LED and fry it.

(2) Usually an ordinary LED needs 5mA ~ 20mA to turn on. The value of the protective series resistor can be calculated as below:

(a) Vcc = Voltage to power the LED, supposing 9V,

(b) V = voltage across the LED, supposing 0.4V,

(a) Ir = current flowing through the resistor and LED, supposing 10mA,

(c) Vr = voltage across the protective resistor, = 9V – 0.4V = 8.6V,

(d) R = value of resistor = Vr / Ir (Ohm’s Law) = 8.6V / 10mA ~= 860Ω

So you need a 860Ω resistor to protect the LED. Usually you don’t need to be that precise, because all values of components and power etc are only rough numbers, so a resistor of 512Ω to 1kΩ should be good enough.


Part C – How to troubleshoot the relay module

(a) Using a jumper wire connecting Ground and 3V3 as input signal to relay module

You don’t need to use any python program to test your relay. You only need a jumper wire and test by hand to make sure if the relay is basically working. The procedure is summaized below.

(i) Connect one end of jumper to IN terminal of relay module.

(ii) Hold the other end of the jumper wire by hand, and touch/connect it to Rpi ground. Now you are inputting a Ground (0V, Logically Low level) signal to the relay module. If you hear a click sound, then you now know that a Low signal can trigger/turn on the relay switch. If you don’t hear any click sound, then it might mean that your relay module is High level (3v3) triggered, and you can try step (iii) below to continue the test.

(iii) Now repeat (ii) above, but this connect jumper end to Rpi 3V3, and see if you hear the click sound. If yes, then it means your relay is High level triggered.

(iv) You can repeatedly touch the jumper to Ground and 3V3 to make sure if it is High or Low signal that triggers the relay.

Notes

(1) In (ii) or (iii) step above, if you hear a click sound that means the relay switch is turned on, and you now remove the jumper wire from Ground or Vcc, you should hear another click sound, which means the relay’s triggerable signal is removed, and the relay switch is turned off. Again you can repeatedly connect and remove the trigger signal to hear relay repeatedly clicking, meaning it is repeatedly switch on and off.


Part D – How to connect an external power source to COM

relay cct 1

(b) Using a Rpi Thonny python and GPIO pin as input signal to relay module

/ to continue, …


References

(1) Amazon Relay Modules

(2) AliExpress Relay Modules

(3) Relay – Wikipedia

(4) Electrical Relay – Electronics Tutorials

(5) Electromechanical Relays – All About Circuits


shareeditdeleteflagedited 6 hours agoanswered yesterdaytlfong013,29733 gold badges77 silver badges2121 bronze badges

  • 1Thanks for the detailed answer. So in conclusion, in order to connect the relay to the LED and control it from the RPi… do I need an external power source or I connect the LED directly to the Pi? Disclaimer that I’m not an engineer and I’m just learning all of this on my own. – patriciajlim 7 hours ago 
  • @patriciajlim, Ah, there is confusion here. My schematic indicates that COM is connected to 5V, becasue it is handy to get 5V power from Rpi. But if you are going to use 9V to light the LED, then you can connect your external 9V battery to COM. BTW, I am going to add a more newbie friendly schematic in Part C. You might might to ask more newbie questions referring to this schematic. Happy experimenting. Cheers. – tlfong01 6 hours ago   

add a commentAdd Another Answer

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.