Hello,
What is the most simple way to make Relay Module KY-019 5V work with GPIO?
http://okystar.en.alibaba.com/product/1 ... duino.html
This relay is working fine while it is operating in room temperature, but if I put it in sealed box together with RPi after some time it stops working. My guess is that 3.3v is not enough to switch it on while hotter environment makes resistance in board higher. I am planing to assemble many of these so I need as simple as possible solution.
Re: Relay Module KY-019 5V
use the Pi pins to trigger a transitor to switch the relay via 5v


Doug.
Building Management Systems Engineer.
Building Management Systems Engineer.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Relay Module KY-019 5V
without a schematic, it is impossible to say what the issue is.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Re: Relay Module KY-019 5V
Hiyajasajona wrote:Hello,
What is the most simple way to make Relay Module KY-019 5V work with GPIO?
http://okystar.en.alibaba.com/product/1 ... duino.html
This relay is working fine while it is operating in room temperature, but if I put it in sealed box together with RPi after some time it stops working. My guess is that 3.3v is not enough to switch it on while hotter environment makes resistance in board higher. I am planing to assemble many of these so I need as simple as possible solution.
I dont know. But you ask the question about getting a relay to work, and then say it works.
Then when you change the parameters it stops working.
If it is in a sealed box, then perhaps the power supply (batteries) runs low.
Also the LED is not needed in a sealed box, so remove it.
Most relays work from 0.8 to 1.1 of their voltage. That is 4v to 5.5v. But to ensure that range they will usually pull in at 0.6x and hold in down to 0.5x.
Re: Relay Module KY-019 5V
Thanks for responses. I solved this problem by connecting relay power supply to 5V RPi pin. Hope there will be no problem in long run that power supply for relay board is 5V and control is 3.3V
Re: Relay Module KY-019 5V
Looking at the specs, it does clearly state '3.5 V-12V to TTL control signal'. Expecting it to switch reliably at 3.3V is expecting it to reliably work out of spec if I'm interpreting the data correctly. It's often difficult to interpret specs when they're not written in correct English.
Pi4B 2GB Rev1.4 Mini-PC/Media Centre: ARM=2.25GHz @1.1v, Core=600MHz, GPU=850MHz. Raspberry Pi OS with KODI on 128GB Sandisk Extreme Pro A2 microSD card in Integral card reader in USB3.0 port (138MB/s read). Geekworm P173 case with copper shim on SOC.
Re: Relay Module KY-019 5V
GTR2Fan wrote:Looking at the specs, it does clearly state '3.5 V-12V to TTL control signal'. Expecting it to switch reliably at 3.3V is expecting it to reliably work out of spec if I'm interpreting the data correctly. It's often difficult to interpret specs when they're not written in correct English.
Hi
Actually there are several variations within that same designation.
It is a 5v Songle relay.
Some suppliers have placed it onto a PCB and added an optocoupler.
1. 5V relay
2. can be use for MCU
3. TTL control signal is 5V-12V
4. It can control AC or DC.can connect to 220VAC loader
5. one OP and one ON
6. power apply indicator
7. control indicator
OR
1, the new 5V Relay Module
2, can be used as microcontroller development board module can be used as home appliance control
3,5 V-12V to TTL control signal
4, the control signal DC or AC, 220V AC load can be controlled.
5, there is a normally open and one normally closed contact
6, a power indicator light
7, a control indicator, pull off, disconnect does not shine
8, transistor drive to increase the relay coil control pins high impedance.
9, the control pin has a pull-down circuit to prevent malfunction relay vacant
Note the 3rd line where it is looking like 3.5 v (3,5) but is actually 5v for the TTL value range.
So you pays your money and takes your choice (chance).
Re: Relay Module KY-019 5V
Ah. Thanks. I'd corrected it as I thought it was just one of the umpteen typos in that description.johndough wrote:Note the 3rd line where it is looking like 3.5 v (3,5) but is actually 5v for the TTL value range.
So you pays your money and takes your choice (chance).

Pi4B 2GB Rev1.4 Mini-PC/Media Centre: ARM=2.25GHz @1.1v, Core=600MHz, GPU=850MHz. Raspberry Pi OS with KODI on 128GB Sandisk Extreme Pro A2 microSD card in Integral card reader in USB3.0 port (138MB/s read). Geekworm P173 case with copper shim on SOC.
Re: Relay Module KY-019 5V
5V Relay KY019 Specification
I bought a KY019 relay module some weeks ago. I could not find the specification (Errata - the shop does provide a spec, but placed below some irrelevant promotion ads, so I missed it) so I used an adjustable voltage regulator as input signal, and two multi-meters to measure the parameters.
I found the relay
1. activates at input Vin > 2.5V, driving current about Iin ~= 4mA, coil current Ic = 50 ~70mA, and
2. deactivates at Vin < 2.2V, coil current Ic < 40mA.
3. So I think the Rpi's 3.3V logic GPIO signals can directly drive the module.
But Rpi's 3.3V or 5V power with 50mA max (Errata - should be much more than that, see update below), from the 26/40 pin connector should not be used to power the relay, which takes 70mA+ to operate.
A separate 5V power supply should be used (Errata -
4. OK to use the 5V power pin of the 40-pin GPIO block connector
to power the module, and the grounds of the Rpi and Relay powers should be connected together.
My measurements are summarized below.
Update 1
My 3V3/5V rail current limit is out of date. I read recently that only early models of Rpi has the 50mA limit for 3V3. For Rpi3, both 3V3 and 5V power current limit is up to 1A, but I have not found any official Rpi documentation confirming this.
Update 2 - 2019jan14hkt2106
5. Hysteresis characteristic
Case 1. If relay is already activated by Vin > 2.5V, now decreasing Vin to just below 2.5V will not deactivate it. Only when Vin decreases to the lower threshold of 2.2V, then it will deactivate.
Case 2. Now if the relay is already deactivated by Vin < 2.2V, now increasing Vin to just above 2.2V will not activate it. Only when Vin increases to the upper threshold of 2.5V, then it wil activate.
This hysteresis thing is usually taught in the middle school physics subject of electricity and magnetism.
...
I bought a KY019 relay module some weeks ago. I could not find the specification (Errata - the shop does provide a spec, but placed below some irrelevant promotion ads, so I missed it) so I used an adjustable voltage regulator as input signal, and two multi-meters to measure the parameters.
I found the relay
1. activates at input Vin > 2.5V, driving current about Iin ~= 4mA, coil current Ic = 50 ~70mA, and
2. deactivates at Vin < 2.2V, coil current Ic < 40mA.
3. So I think the Rpi's 3.3V logic GPIO signals can directly drive the module.
But Rpi's 3.3V or 5V power with 50mA max (Errata - should be much more than that, see update below), from the 26/40 pin connector should not be used to power the relay, which takes 70mA+ to operate.
A separate 5V power supply should be used (Errata -
4. OK to use the 5V power pin of the 40-pin GPIO block connector
to power the module, and the grounds of the Rpi and Relay powers should be connected together.
My measurements are summarized below.
Update 1
My 3V3/5V rail current limit is out of date. I read recently that only early models of Rpi has the 50mA limit for 3V3. For Rpi3, both 3V3 and 5V power current limit is up to 1A, but I have not found any official Rpi documentation confirming this.
Update 2 - 2019jan14hkt2106
5. Hysteresis characteristic
Case 1. If relay is already activated by Vin > 2.5V, now decreasing Vin to just below 2.5V will not deactivate it. Only when Vin decreases to the lower threshold of 2.2V, then it will deactivate.
Case 2. Now if the relay is already deactivated by Vin < 2.2V, now increasing Vin to just above 2.2V will not activate it. Only when Vin increases to the upper threshold of 2.5V, then it wil activate.
This hysteresis thing is usually taught in the middle school physics subject of electricity and magnetism.
...
- Attachments
-
- KY019 spec
- ky019_spec_2018jun0201.jpg (228.32 KiB) Viewed 21624 times
Last edited by tlfong01 on Wed Jan 16, 2019 1:27 pm, edited 10 times in total.
I am an electronics and smart home hobbyist.
Re: Relay Module KY-019 5V
The 3V3 rail is not limited to 50mA. That is for GPIO and the 3V3 rail is not GPIO. The spec is not published that I have found. The RPi3B has a 1A regulator so the current available = (1A - whatever the RPi uses). I am guessing 2 or 300mA or more.tlfong01 wrote: ↑Sat Jun 02, 2018 2:10 pm........ But Rpi's 3.3V or 5V power with 50mA max, from the 26/40 pin connector should not be used to power the relay, which takes 70mA+ to operate.
A separate 5V power supply should be used to power the module, and the grounds of the Rpi and Relay powers should be connected together.
When the RPi is powered via the micro USB port then 5V power is limited by the polyfuse to 2.6A total. There is plenty power available to run many 5V relays. I have seen YT of 8 or 16 channel relays running.
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.
Re: Relay Module KY-019 5V
Thanks a lot for pointing out my careless mistake on the 3V3/5V rail current limit. So I added an errata and update to my answer.klricks wrote: ↑Sat Jun 02, 2018 2:52 pmThe 3V3 rail is not limited to 50mA. That is for GPIO and the 3V3 rail is not GPIO. The spec is not published that I have found. The RPi3B has a 1A regulator so the current available = (1A - whatever the RPi uses). I am guessing 2 or 300mA or more.
When the RPi is powered via the micro USB port then 5V power is limited by the polyfuse to 2.6A total. There is plenty power available to run many 5V relays. I have seen YT of 8 or 16 channel relays running.
I also saw the YT showing 16 relays taking power from the 5V power pin of GPIO 40pin block and cycling on/off continuously. But that is a bit misleading, because when cycling through 16 relays, each GPIO only works for one cycle and have 15 cycles time to cool down. And cycling means only one relay is activated at a time. If N relays are activated at the same time, then the total coil operating current of 70mA * N might overload and damage the Rpi's 5V rail power circuit, or shorten it working life.
I am an electronics and smart home hobbyist.
Re: Relay Module KY-019 5V
Yes, I agree with GTR2Fan that the spec is translated badly. I am not sure if the original spec in Chinese is correct. So as johndough says, you pays your money and you takes your choice (chance).johndough wrote: ↑Sat May 17, 2014 10:06 am. . . Actually there are several variations within that same designation.GTR2Fan wrote:. . . the specs, it does clearly state '3.5 V-12V to TTL control signal'. ... It's often difficult to interpret specs when they're not written in correct English.
1. 5V relay
2. can be use for MCU
3. TTL control signal is 5V-12V
. . .
Note the 3rd line where it is looking like 3.5 v (3,5) but is actually 5v for the TTL value range.
So you pays your money and takes your choice (chance).
Anyway, I found another spec in Chinese as attached, and I did a quick and dirty translation:
0. Relay coil drive voltage is 5V; control input voltage level is also 5V or lower;
1. Output capability: 250VAC-10A, 125VAC-10A, 30VDC-10A, 28VDC-10A;
2. Easy to use, 6 output connectors;
3. Input can be directly driven by single board computer I/O port or digital circuit, High level to operate, Low level to release;
4. Working voltage 5V, operating current about 70mA per channel, with relay status indicator LED;
5. All SMD components used, most reasonable driving circuit design, using 8050 transistor to drive relay;
6. Has fixed screws for easy installation, circuit board dimension: 1.8cm * 4.0cm * 1.9cm, weight 15g.
- Attachments
-
- KY0109 spec in Chinese
- ky019_spec_2018jun 0301s.jpg (92.6 KiB) Viewed 21577 times
I am an electronics and smart home hobbyist.
Re: Relay Module KY-019 5V
So I found the schematic, though 4 years too late!Richard-TX wrote: ↑Thu May 15, 2014 1:48 pmwithout a schematic, it is impossible to say what the issue is.
http://tinkbox.ph/sites/tinkbox.ph/file ... KY-019.pdf
- Attachments
-
- KY-019 schematic
- ky019_schematic_2018jun0501.jpg (52.9 KiB) Viewed 21510 times
I am an electronics and smart home hobbyist.
Re: Relay Module KY-019 5V
I was not sure if there was a typo mistake. I read Wikipedia on TTL to learn more. I found that in the mid 60s, there were a couple of transistor logic circuit designs, with different Vcc levels, from 5V to 14V. It was only when Texas Instruments 's design became popular then 5V Vcc became standard. But there were other manufacturers setting other standards. I guess 12V at that time and until now is also popular. Wikipedia also mentions about Low-voltage TTL (LVTTL) for 3.3-volt power supplies and memory interfacing.GTR2Fan wrote: ↑Fri May 16, 2014 11:25 amLooking at the specs, it does clearly state '3.5 V-12V to TTL control signal'. Expecting it to switch reliably at 3.3V is expecting it to reliably work out of spec if I'm interpreting the data correctly. It's often difficult to interpret specs when they're not written in correct English.
Update: This reminds me in those were the PC days, there were 3 power supplies, 12V (I forgot for what, perhaps for fan), 5V for logic, and 3.3V for RAM.
So I guess KY-019's "3.5V-12V to TTL" though may not be correct English, its technical meaning still makes sense. Since 3.5V TTL should have some noise/safety of perhaps 0.5V, so Rpi's 3.3 logic signal can drive the relay without a problem.
Last edited by tlfong01 on Mon Jun 11, 2018 3:04 am, edited 1 time in total.
I am an electronics and smart home hobbyist.
- Z80 Refugee
- Posts: 359
- Joined: Sun Feb 09, 2014 1:53 pm
Re: Relay Module KY-019 5V
That schematic is poor. For one thing: if the transistor were fitted the way it is shown, the circuit wouldn't work. Without specifying the transistor type (what, exactly, is an "8050"?), it is not possible to verify the component values appropriate for the application, but in any case the indicator LED in the base drive makes it unsuitable for the RPi's 3.3V (nominal) output.
Contrary to naive expectation, transistors are not switches. The do not simply provide a current path if you give them a voltage on the base terminal. If you give them enough base drive and limit the amount of current you need, then yes they can act like a switch - but actually what is happening (to the next level of approximation) is that the current in at the base multiplied by the current gain of the transistor (hfe) limits the current from collector to emitter. So if you want 8mA from the RPi output to push 40mA through the relay coil (say), you need a transistor with a current gain of 50 (bare minimum).
To adapt this for operation with the RPi, my minimum recommendation is to short out the LED (with the transistor the right way around).
5V coil relays are quite current-hungry (similar relays need similar power to switch them, so a coil designed for 5V needs 2.4 times the amount of current a 12V coil would need), so a I would prefer to use 12V coil relays if possible (if there is a 12V supply available).
I have written much more on this kind of thing here: viewtopic.php?f=34&t=207597
Last edited by Z80 Refugee on Tue Jun 05, 2018 9:53 am, edited 2 times in total.
Military and Automotive Electronics Design Engineer (retired)
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
-
- Posts: 34
- Joined: Thu May 31, 2018 3:33 pm
- Location: UK
Re: Relay Module KY-019 5V
A word of caution with relays used to switch mains power.
If they don't include opto-coupling insulation (and maybe even if they say they do) I would strongly suggest that they should be controlled through an opto-coupler and not directly a GPIO or transistor.
If they don't include opto-coupling insulation (and maybe even if they say they do) I would strongly suggest that they should be controlled through an opto-coupler and not directly a GPIO or transistor.
- Z80 Refugee
- Posts: 359
- Joined: Sun Feb 09, 2014 1:53 pm
Re: Relay Module KY-019 5V
Opto-isolation adds an extra level of safety, but should not be necessary as the relay coil is already isolated from the switching contacts. The most important thing about switching mains is to ensure the relay is mains-rated. If the relay is not mains-rated, it is not safe to switch mains regardless of any further isolation (although having isolation may prevent you finding out the relay isn't suitable the hard way!). Adding isolation where it is not necessary increases complication and therefore reduces reliability.GuruMeditation wrote: ↑Tue Jun 05, 2018 8:52 amA word of caution with relays used to switch mains power.
If they don't include opto-coupling insulation (and maybe even if they say they do) I would strongly suggest that they should be controlled through an opto-coupler and not directly a GPIO or transistor.
The "naked" GPIO output is not suitable to drive a relay at all, and always requires some form of buffering.
The proper advice is not to play with mains circuits unless you really understand what you are doing, and use properly rated and verified components suitable for the application. Don't trust cheap Far East imports for safety-critical applications - and mains interfacing is safety critical.
Military and Automotive Electronics Design Engineer (retired)
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
Re: Relay Module KY-019 5V
Apart from that isolation these type of boards usually have bare contacts, and tracks on the switch contacts very close to other tracks on the board so be very careful!!
Re: Relay Module KY-019 5V
The schematic is indeed weird, and the transistor should be inverted. I have redrawn the schematic as attached below.Z80 Refugee wrote: ↑Tue Jun 05, 2018 7:52 am
That schematic is poor. For one thing: if the transistor were fitted the way it is shown, the circuit wouldn't work.
(with the transistor the right way around). ...
References
About Tinkbox and KY-019 schematic
http://tinkbox.ph/about
http://tinkbox.ph/sites/tinkbox.ph/file ... KY-019.pdf
Fairchild SS8050 NPN Epitaxial Silicon Transistor
http://www.onsemi.com/pub/Collateral/SS8050-D.pdf
Taitron SMD General Purpose Transistor (NPN) MMBT8050
https://www.taitroncomponents.com/catal ... BT8050.pdf
- Attachments
-
- ky019_schematic_2018jun0502.jpg (108.7 KiB) Viewed 21397 times
I am an electronics and smart home hobbyist.
Re: Relay Module KY-019 5V
Thanks a lot for your advice. I used to play with 5V to 12V DC motors and have not had any problems.GuruMeditation wrote: ↑Tue Jun 05, 2018 8:52 amA word of caution with relays used to switch mains power.
If they don't include opto-coupling insulation (and maybe even if they say they do) I would strongly suggest that they should be controlled through an opto-coupler and not directly a GPIO or transistor.
I know 220VAC is very different and dangerous. I still remember some years ago I got a terrible electric shock when carelessly fixing a mains socket without switching off mains.
So this time I think I will go very slowly. My initial plan is as below.
Transistor directly driving relay module.
1. Test DC 5V, 12V, up to 1A resistive load.
2. Test DC 5V, 12V DC toy motor.
3. Test AC 6V, 12V LED lamp.
4. Test AC 6V, 12V very low power induction motor.
I will use 220VAc to 6VAc x 2, 12VAc x 2 transformers to get the low voltage AC. The primary and secondary windings are insulated from each other, so there should be little risk of getting an electric shock.
With optocoupler relay module.
5. Test AC 220V LED lamp.
6. Test AC 220V fan.
I have no experience at all in 3 to 6. So need to google much to learn how to do it, and the precautions.
I am an electronics and smart home hobbyist.
- Z80 Refugee
- Posts: 359
- Joined: Sun Feb 09, 2014 1:53 pm
Re: Relay Module KY-019 5V
This time you have the LED the wrong way around.
Military and Automotive Electronics Design Engineer (retired)
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
- Z80 Refugee
- Posts: 359
- Joined: Sun Feb 09, 2014 1:53 pm
Re: Relay Module KY-019 5V
Just because a relay has a mains voltage printed on it as contact rating, doesn't mean it meets European/British directives for electrical safety. And even if the relay itself meets the safety requirements, it doesn't mean the circuit board does. If a relay board has exposed tracks instead of being housed in an enclosure of some kind, it is not suitable.
Military and Automotive Electronics Design Engineer (retired)
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
- Z80 Refugee
- Posts: 359
- Joined: Sun Feb 09, 2014 1:53 pm
Re: Relay Module KY-019 5V
Google results will tell you everything, and the opposite, in equal measure. The difficulty is separating the wheat from the chaff.
Military and Automotive Electronics Design Engineer (retired)
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!
Re: Relay Module KY-019 5V
Many thanks for your advice. I was not aware of the bare contacts. I looked closely at the PCB and found that the relay connectors COM/NO/NC indeed have bare contacts at the bottom side of the PCB. So I need to be very careful in handling if I connect them to the 220VAC mains.
I was neither aware of the PCB trace risk. Now I worry that if the 220VAC traces are too close to the transistor, and if the traces are over heated under heavy loading, the copper traces might short circuit, with the result that 220VAC goes to the Rpi!. I need to check if there is such a possibility.
I once thought about playing with a free PCB design program called EAGLE. But I found the learning curve too steep for a casual electronics hobbyist, so I gave up, after reading a few pages of the very thick manual. Anyway, I have read the sparkfun tutorial on PCB to update my common knowledge.
SparkFun PCB Basics Tutorial
https://learn.sparkfun.com/tutorials/pcb-basics
- Attachments
-
- ky010901
- ky012_400_2018jun0601.jpg (40.3 KiB) Viewed 21327 times
I am an electronics and smart home hobbyist.
- DougieLawson
- Posts: 42636
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Relay Module KY-019 5V
Use the relay on your RPi to switch 24V. Run that in a long cable to where you want to switch the mains load. Have the mains relay in a safe box away from danger.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.