User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Jun 06, 2018 7:03 am

DougieLawson wrote:
Wed Jun 06, 2018 5:38 am
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.
Thanks for your suggestion. Actually I googled a similar idea a week ago, as summarized below.

... The fan may be a much more difficult load than the lights - but if switching the relay makes it go wrong only if it's the fan that is switched then it is probably something to do with the characteristics of the fan/regulator combination.

I should mention that you need to be very very careful using the Sainsmart board to switch mains voltages - you must be very careful with your wiring and make sure things are in a box and firmly screwed down ...


So I bought a box and started assembling things.
Attachments
box_2018jun0601.jpg
safety box
box_2018jun0601.jpg (45.3 KiB) Viewed 2830 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Jun 06, 2018 7:23 am

Z80 Refugee wrote:
Tue Jun 05, 2018 7:52 am

...

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).
Yes, I checked the relay coil datasheet and found that the Songle or Tongling relay needs 50~70mA to operate. One thing I don't understand is that many Amazon relay ads say the following:

"... Each driver needs 15~20mA"

I guess their spec refers to the old type of smaller relays with 20mA drive, 30VDC 5A capability. When they changed a bigger relay, they didn't bother to change the spec, ... I see that is the way Amazon goes, ...

On choosing 5V or 12V relay, I agree the 12V coil current is about half smaller, so the driving transistor loads lighter, and therefore lives longer. But there are no other advantages.

I first thought that if the coil current is smaller, then the arcing or kick back is smaller, so a not to powerful fly back diode can be used. But on second thought, the energy stored in the coil is the same, so we still need the same powerful diode, only lower current, but higher voltage.
Attachments
songle_relay_600_2018jun0601.jpg
Songle relay
songle_relay_600_2018jun0601.jpg (53.77 KiB) Viewed 2826 times
Last edited by tlfong01 on Mon Jun 11, 2018 3:11 am, edited 6 times in total.
I am an electronics and smart home hobbyist.

GuruMeditation
Posts: 34
Joined: Thu May 31, 2018 3:33 pm
Location: UK

Re: Relay Module KY-019 5V

Wed Jun 06, 2018 7:24 am

Make sure that the box is earthed ;)

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Jun 06, 2018 2:07 pm

GuruMeditation wrote:
Wed Jun 06, 2018 7:24 am
Make sure that the box is earthed ;)
Ah yes, grounding or earthing the box is first and foremost. I made a short ground wire and screwed two ends OK. But I found two problems.

1. My aluminium box is anodized, meaning the surface is not a conductor, so the box is like a plastic box and there is no risk of electrical shock. But the rough edges are not anodizing and so is conducting. I googled but could not find any good advice for earthing this kind of chassis. Anyway, I just grinded away the surface and fastened the screws.

2. The other problem is that I never understood how the earth thing works. So for a peaceful mind, I need to search Stack Exchange for a good explanation.

How grounding works to prevent electrical shock - Electronics Stack Exchange
https://electronics.stackexchange.com/q ... ical-shock
earth_2018_600_jun0601.jpg
earthing the box
earth_2018_600_jun0601.jpg (30.94 KiB) Viewed 2793 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Jun 07, 2018 1:32 pm

jasajona wrote:
Wed May 14, 2014 7:24 am
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
OkStar seems to have replaced KY-109 by OKY3011

https://okystar.en.alibaba.com/product/ ... 740aT0riyN

But the spec is as poor as the old model. It says the following weird spec for the control signal:

3,5V-12V a TTL control signal

I found a couple of KY019 modules selling in amazon with different brand names. I noticed one shop has the following spec for input control signal. Another shop just say that the control signal is "High"

TTL control signal is 5V-12V

And I found their new KY019 has an optocoupler EL817C on board. So my KY019 schematic is out of date. Perhaps I should also update my board with an optocoupler and perhaps call it KY019OP.
Last edited by tlfong01 on Fri Jun 08, 2018 12:54 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Jun 07, 2018 2:59 pm

Z80 Refugee wrote:
Tue Jun 05, 2018 10:45 pm
tlfong01 wrote:
Tue Jun 05, 2018 2:07 pm
The schematic is indeed weird, and the transistor should be inverted. I have redrawn the schematic as attached below.
This time you have the LED the wrong way around.
Thanks for pointing out my careless mistake. I have made the correction, and also tried to calculate the biasing resistor value, but found it difficult to make optimum calculations. Perhaps I need to use Excel what-if equations. Or just use brute force trial and error.

I just opened an imgur.com account and am trying to upload 1MB big image files.
BrqPjyB[1].jpg
NB0109v02
BrqPjyB[1].jpg (90.51 KiB) Viewed 2742 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 2:59 am

johndough wrote:
Sat May 17, 2014 10:06 am

Actually there are several variations within that same designation.
Yes, I googled to find that okstar is itself a factory. I guess they were once OEM and manufactured KY-019 for joy-it which sells the Keyes KY0xx series of a big variety of DIY kits. I think Okstar still OEMs KY019 relay, under different brand names, for a couple of amazon and alibaba shops, but they also have their own brand name relays now.

Okstar relays
https://okystar.en.alibaba.com/productg ... 5338ffztx0

joy-it KY019 5V Relais Module
http://sensorkit.en.joy-it.net/index.ph ... ais_module

joy-it Sensor Kit X40
http://sensorkit.en.joy-it.net/index.ph ... =Main_Page

I googled joy-it and found their documentation very good. They even have example programs for both Arduino and Raspberry Pi. Though they do not have an spec of the input signal, but I think that means their KY-019 is compatible to both Arduino and Raspberry Pi.

joy-it has the following good warning for the beginners.

!!!!! Caution [by Joy-it] !!!!!

Working with voltages over 30V and a main voltage (230V) can harm your body or kill you.
We advise you not to work with higher valtages unless you have the needed experience.

!!!!! Caution !!!!!


And below is joy-it's Rpi example program.

Code: Select all

The program imitates a direction indicator - it switchs the status of the output terminals in a specific time period.

Code example Raspberry Pi

http://sensorkit.en.joy-it.net/index.php?title=KY-019_5V_Relais_module

# Needed modules will be imported and configured
import RPi.GPIO as GPIO
import time
 
GPIO.setmode(GPIO.BCM)
# Declaration of the break between the changes of the relay status (in seconds)
delayTime = 1
 
# Declaration of the input pin which is connected with the sensor. Additional to that, the pullup resistor will be activated.
RELAIS_PIN = 21
GPIO.setup(RELAIS_PIN, GPIO.OUT)
GPIO.output(RELAIS_PIN, False)
 
print "Sensor-test [press ctrl+c to end]"
 
# Main program loop
try:
        while True:
            GPIO.output(RELAIS_PIN, True) # NO is now connected through
            time.sleep(delayTime)
            GPIO.output(RELAIS_PIN, False) # NC is now connected through
            time.sleep(delayTime)[color=#BF00FF][/color]
 
# Scavenging work after the end of the program
except KeyboardInterrupt:
        GPIO.cleanup()

To start, enter the command:

sudo python KY-019_RPi_Relais.py
One thing I don't understand is why they use the word "relais" instead of "relay". I have never heard of "relais" before!

In the program, there is a typo mistake, "sensor" should read relay module.

Another thing is the phrase "the pullup resistor will be activated", I guess it is also a typo. If the relais pin is setup to output mode, the pull up resistor should not be activated (but I am only 50% sure!)

Update
One laughable thing about joy-it is that their do give good warning on AC mains, and even sample programs for Arduino and Rpi, but they don't provide the most important thing: spec for the input signal (High or Low trigger etc)!
Last edited by tlfong01 on Mon Jun 11, 2018 3:18 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 5:41 am

tlfong01 wrote:
Thu Jun 07, 2018 2:59 pm

I ... tried to calculate the biasing resistor value, but found it difficult to make optimum calculations. Perhaps I need to use Excel what-if equations. Or just use brute force trial and error.
I guess I have not learned enough about NPN BJT driving a relay. So I am reading the following tutorials a second time, before trying to do the same homework of 2N2222 biasing.

Relay Switch Circuit - electronics tutorials
https://www.electronics-tutorials.ws/bl ... rcuit.html

Design a sustainable realy driving ciccuit using BJT [2N2222] - Instructables
http://www.instructables.com/id/Design- ... t-Using-B/

Using Relays and Relay Boards with the Raspberry Pi [2N222] - Gaven MacDonald
https://www.youtube.com/watch?v=b6ZagKRnRdM
Attachments
FySkGs2[1].jpg
FySkGs2[1].jpg (36.31 KiB) Viewed 2047 times
Last edited by tlfong01 on Sun Jul 01, 2018 5:27 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

User avatar
rpdom
Posts: 15228
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 5:55 am

I believe "relais" is French for "relay".

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 6:16 am

rpdom wrote:
Fri Jun 08, 2018 5:55 am
I believe "relais" is French for "relay".
Thanks a lot. Actually I googled "relais" before but could not find anything related to "relay". Just now I googled again and found it in wiktionary.

relais

https://en.wiktionary.org/wiki/relais

(electronics) relay (electromechanical device)

So the English language has been contaminated by French!
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 6:54 am

tlfong01 wrote:
Fri Jun 08, 2018 5:41 am

I guess I have not learned enough about NPN BJT driving a relay. So I am reading the following tutorials a second time, before trying to do the same homework of 2N2222 biasing. ...
I googled around raspberry pi forum and found the following discussion clarifying my mind about the differences of using PNP and NPN BJT to drive a relay. The important point is the following:

If an Arduino relay board uses PNP BJT to drive the relay (Low level trigger), then very likely there will be a problem with Rpi using the board (Rpi High level not high enough).

But if the Arduino relay board uses NPN BJT to drive the relay (High level trigger), then there will not be any problem for Rpi (no problem of Rpi Low not Low enough).


So my suggestion to Rpi rely beginners is the following: If you are going to buy a Low level trigger PNP (no optocoupler) relay board, DON'T! You should buy a high trigger NPN one.

Connecting a 5V relay board

viewtopic.php?p=169319
kaos wrote:
Wed Aug 22, 2012 5:48 pm

I suspect that this particular board might give problems, if connected directly to the GPIO. Note that this board is "inverted"; an input has to be pulled low to allow current to pass from emitter to base in the (PNP type) transistor, which again allows current to flow from emitter to collector and on to relay and LED. If Vcc on the relay board is connected to 5V and the input to a Raspi GPIO pin, even with the pin pulled high (to 3.3V), enough current might flow through base on the transistor and the clamping diode in the Raspi SOC, that the transistor turns on and the relay operates.

If, on the other hand, Vcc is connected to 3.3V, you get rid of this problem, but the 5V relay may not operate at all at 3.3V, and besides, will probably overload the 3.3V supply on the Raspi.

If you can find (or make) a relay board with a schematic that is a mirror image of this one; that is, uses NPN type transistors with emitter tied to ground, and the relay connected between Vcc and collector of the transistor, then chances are it will work with the Raspi's 3.3V signals, even if it is designed for 5V.

A transistor buffer could of course also solve these problems, but then again you could also use the same transistor buffer to drive the relays directly ;)
The other import thing I learnt in the same discussion topic is about MCP23017. I agree with user-id 32082 that

it is a good idea to use MCP23017, the extra work will pay off later.
geoffr wrote:
Sun Sep 09, 2012 1:38 pm

... I agree - the approach I am taking is more complex, but it has greater longer-term expansion potential. Given how cheap the MCP23017 is, it is not a major thing adding another one. I ultimately also plan to expose the I2C bus via a header on my board, allowing me to just add a daughter board later. I may want to add some AD converters later on - and there are readily available chips with I2C interfaces to do this. That is the stage where all the extra work will pay off.

Driving Relays using MCP23017 - DougieLawson 2017may18
viewtopic.php?p=1164047#p1164164
The way I drive relays is to use an MCP23008 or MCP23017 I²C chip as they are safe at 5V. Programming those I²C chips is trivial.
Last edited by tlfong01 on Fri Jun 15, 2018 2:46 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Jun 08, 2018 7:32 am

tlfong01 wrote:
Fri Jun 08, 2018 6:54 am

The other important thing I learnt in the same discussion topic is about MCP23017. I agree with user-id 32082 that

it is a good idea to use MCP23017, the extra work will pay off later.
geoffr wrote:
Sun Sep 09, 2012 1:38 pm

... I agree - the approach I am taking is more complex, but it has greater longer-term expansion potential. Given how cheap the MCP23017 is, it is not a major thing adding another one. I ultimately also plan to expose the I2C bus via a header on my board, allowing me to just add a daughter board later. I may want to add some AD converters later on - and there are readily available chips with I2C interfaces to do this. That is the stage where all the extra work will pay off.
geoffr wrote:
Sun Sep 09, 2012 12:57 pm
I've given up on the idea of using the GPIOs directly, and will give the I2C bus a bash. My current thinking is still to use a ULN2803 to drive relays. - In the attached diagram I have only got as far as the indicator LEDs for each output. I plan to use the other 8 lines from the MCP23017 as inputs. I will use a separate 5V supply to the Pi once I am driving relays, although at the prototyping stage, I will first test just with LEDs while I work on the I2C stuff.

This approach also allows me to create a lot more GPIOs, and I won't have to deal with the confusion caused by the crazy GPIO allocation on P1 - I only need to take pins from P1 through onto my relay board.

Using I2C, assuming I get it working, will have the added bonus that I can integrate a real time clock into my board.
Attachments
uCwk7tz[1].jpg
uCwk7tz[1].jpg (97.97 KiB) Viewed 2651 times
Last edited by tlfong01 on Mon Jun 11, 2018 3:20 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jun 09, 2018 2:59 am

tlfong01 wrote:
Fri Jun 08, 2018 6:54 am

I googled around raspberry pi forum and found the following discussion clarifying my mind about the differences of using PNP and NPN BJT to drive a relay. The important point is the following:

If an Arduino relay board uses PNP BJT to drive the relay (Low level trigger), then very likely there will be a problem with Rpi using the board (Rpi High level not high enough).

But if the Arduino relay board uses NPN BJT to drive the relay (High level trigger), then there will not be any problem for Rpi (no problem of Rpi Low not Low enough).


Connecting a 5V relay board

viewtopic.php?p=169319
kaos wrote:
Wed Aug 22, 2012 5:48 pm

I suspect that this particular board [Note 1] might give problems, if connected directly to the GPIO. ...

If you can find (or make) a relay board with a schematic that is a mirror image of this one; that is, uses NPN type transistors with emitter tied to ground, and the relay connected between Vcc and collector of the transistor, then chances are it will work with the Raspi's 3.3V signals, even if it is designed for 5V. ...

Note 1 - The board referred is http://www.elecfreaks.com/store/8-chann ... p-268.html. This 4 year old link is already broken. I guess a similar board is the following:

5V Low Level Trigger One 1 Channel Relay Module DC AC 220V Interface Relay Board Shield LED Indicator for Arduino
https://www.aliexpress.com/item/5V-Low- ... 27376.html

I also found the following interesting:

Common Pitfalls for Beginners #25 Problems with relay modules - mahjongg, Forum Moderator 2017oct22
viewtopic.php?f=91&t=83372&p=1225448#p1225448

Summary

... raspberry pi has had difficulties getting it working,
... main reason: modules designed to work with Arduino that uses 5V signal
... designers not considered with [rpi] 3.3V signal
... nor do the sellers of these modules care.
... typical sainsmart relay module contains an opto-isolator wired to be "active low",
... problems with this design;
... normally the opto-isolator is powered with 5V, input is expected to either go to 0V or 5V.
... but if put 3V3 on the input pin, ... the armature keeps stuck [problem: relay always on].
... one could program the GPIO input pin so becomes high-ohmic [set GPIO to input mode = high impedance], [relay will be off]
... downfall of approach is that there might appear a voltage on the GPIO larger than 4V,
... might cause the dreaded "latch up" phenomenon as the GPIO's of a PI are NOT 5V TOLERANT!
... see https://en.wikipedia.org/wiki/Latch-up for an explanation
... maybe the two diodes (LED's) might prevent latchup in practice, so it might work, but your mileage might vary!
... obvious solution would be to lower then Vcc voltage to 3.3V, but but GPIO 3.3Volt not enough to light up the two LED's
... this renders these relay modules very hard to use with a 3.3V based system like Rpi.
... problem exacerbated by sellers, especially on e-bay almost never let you see the schematics.
... one solution would be short out the indicator LED, but that means soldering ( a skill that anyone calling himself an
... electronic engineer cannot go without by the way, and its not as hard as it looks, just mind not to touch any of the metal of the soldering
... iron during use). (Note 1)
... best solution use another transistor to turn on and off the LED current. (Note 2)
... or simply buy a better suitable relay board, something simple without an opto-isolator like this: (Note 3)

Note 1 - I am an electronics hobbyist, and I hate SMDs, not to mention soldering them. See the two video/article below.

Are Electronics Hobbyists Useless?
https://www.youtube.com/watch?time_cont ... iXFhKUa1BU

Electronics Still Thrives as a Hobby – Lou Frenzel | May 17, 2018
Most electronic hobbyists hate surface-mount devices (SMD). - A survey report
http://www.electronicdesign.com/analog/ ... ives-hobby

Note 2 - I found the following thread useful for the best solution mentioned above. I think the NPN transistor in open collector mode is actually a 3.3V to 5V logical level converter and digital buffer.

Sainsmart relay Fri Oct 05, 2012
[urlhttps://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19222][/url]

Note 3 - mahjongg's schematic of the recommended relay module is a bit complicated. So I removed the not very relevant details and attach the simplified version below.
5bRaJT9[1].jpg
ky-019 type d v0.1
5bRaJT9[1].jpg (49.34 KiB) Viewed 2595 times
Last edited by tlfong01 on Tue Jun 12, 2018 12:58 am, edited 6 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jun 09, 2018 4:47 am

Z80 Refugee wrote:
Tue Jun 05, 2018 10:49 pm
gordon77 wrote:
Tue Jun 05, 2018 11:25 am
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!!
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.
Yes, I think all the PCBs of the relay modules we can buy from Amazon or AliExpress are only for hobbists, not for industry. I once worried if the Songle relay used in most of the 5V relay modules are reliable. So I google Farnell.

Songle relay from Farnell
http://www.farnell.com/datasheets/25489 ... 8TEALw_wcB

I noticed that Songle datasheet says they are ISO9002. I don't know exactly what ISO9002 means, except that it is sort of a quality assurance standard for industrial applications. So I guess they are at least OK for hobbyists to play with ACV200.

I once skimmed through the very thick AutoDesk EAGLE manual also the following tutorial to know the basics of PCB traces and safety etc. I found them very boring and so I gave up. But I would always remind myself that the relay boards I am playing are perhaps OK for my home automation projects, and are not at all up to industrial standards.

The Top 10 PCB Routing Tips for Beginners
https://www.autodesk.com/products/eagle ... beginners/
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sun Jun 10, 2018 3:17 am

DougieLawson wrote:
Wed Jun 06, 2018 5:38 am
... Run that in a long cable to where you want to switch the mains load. ...
DougieLawson wrote:
Sat May 20, 2017 5:26 pm
...The MCP23008 or MCP23017 is a good working alternative to wiring up your own transistors.
I read about using I2C MCP23017, then I can place the relays far far away, perhaps 100 meters, as described by the post below

Maximum-i2c-bus-length
https://electronics.stackexchange.com/q ... bus-length
I work for a company making USB sensors. Most of them are based on I2C sensor chips, those devices can be split in two, so you can install the CPU part in one place and the sensor part in another. We conducted quite a lot of tests on the I2C connection between the device CPU and the I2C sensors. At 100 kHz, with a good error recovery protocol, 25m can be easily reached using basic wires. We were even able to reach 100m once with CAT5 cable.

I also read other posts using MCP23017 and ULN2803. But I could not find any follow up posts. I guess this approach is very difficult, for sure not for beginners.
geoffr wrote:
Sun Sep 09, 2012 12:57 pm
... given up on the idea of using the GPIOs directly, and will give the I2C bus a bash.
... still to use a ULN2803 to drive relays.
... use the other 8 lines from the MCP23017 as inputs.
... allows me to create a lot more GPIOs, and I won't have to deal with the confusion caused by the crazy GPIO allocation on [rpi]
... have the added bonus that I can integrate a real time clock into my board.
aogriffiths wrote:
Thu May 15, 2014 9:50 am
I'm working on a Raspberry Pi [MCP23017 + ULN2308] based heating control system but I'm hoping my approach could be used for a variety of sense / control scenarios (e.g. light, water moisture, heating etc).
Last edited by tlfong01 on Mon Jun 11, 2018 3:31 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sun Jun 10, 2018 1:19 pm

tlfong01 wrote:
Sat Jun 09, 2018 4:47 am

Songle relay from Farnell
http://www.farnell.com/datasheets/25489 ... 8TEALw_wcB
I have made a summary of the Songle and TongLing relay spec. Then I will study the hysteresis characteristic of KY-019 with TongLing relay.

Update
One thing I found surprising is that the spec is tighter than I thought. For example, spec says that the minimum release voltage and current is 0.25V/0.5V and 3.5mA/7mA, actually the real values are much higher (12mA to release)

Relay spec summary
https://i.imgur.com/2SO6U6r.jpg

Songle Relay Spec
https://i.imgur.com/S8lZRmk.jpg

TongLing Relay Spec
https://i.imgur.com/1ZjI01C.jpg

Songle PNP BJT Relay Module Hysteresis
https://i.imgur.com/Hv2v0hu.jpg
I am an electronics and smart home hobbyist.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Relay Module KY-019 5V

Mon Jun 11, 2018 8:54 am

tlfong01 wrote:
Sun Jun 10, 2018 1:19 pm
One thing I found surprising is that the spec is tighter than I thought. For example, spec says that the minimum release voltage and current is 0.25V/0.5V and 3.5mA/7mA, actually the real values are much higher (12mA to release)
Nothing wrong with that. The quoted values are those where the manufacturer guarantees the relay will drop out. As long as it drops out (as you reduce the current) at currents no lower than the specification, it has met its specification.

This is why design is by analysis of published data rather than by trial and error: if, by experiment, you decide to have a "relay off" current of 10mA (for example), it may well work with the relay you have on your test bench but there is no certainty it will work with all relays from all batches that are supplied.
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)!

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Mon Jun 11, 2018 2:48 pm

tlfong01 wrote:
Sun Jun 10, 2018 1:19 pm

I have made a summary of the Songle and TongLing relay spec. Then I will study the hysteresis characteristic of KY-019 with TongLing relay.
I checked KY-109 again and found the Vin values for relay on and off are 2.2V and 2.4V. Since both Rpi and Arduino High signals are above 2.4V and Low signals below 2.2V. So this NPN BJT as front end driver is compatible to both Rpi, Arduino, and even 12V TTL.
Attachments
KYp3EO5[1].jpg
KYp3EO5[1].jpg (92.07 KiB) Viewed 2431 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 8:01 am

tlfong01 wrote:
Mon Jun 11, 2018 2:48 pm
I checked KY-109 again and found the Vin values for relay on and off are 2.2V and 2.4V. Since both Rpi and Arduino High signals are above 2.4V and Low signals below 2.2V. So this NPN BJT as front end driver is compatible to both Rpi, Arduino, and even 12V TTL.
Now I am taking pictures for future reference. I am having difficulty uploading two or more images. So I am still trying.
The attachment G7vhS4p[1].jpg is no longer available
Attachments
G7vhS4p[1].jpg
ky019 testing 1
G7vhS4p[1].jpg (140.21 KiB) Viewed 2390 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 8:27 am

Z80 Refugee wrote:
Mon Jun 11, 2018 8:54 am
Nothing wrong with that. The quoted values are those where the manufacturer guarantees the relay will drop out. As long as it drops out (as you reduce the current) at currents no lower than the specification, it has met its specification.

This is why design is by analysis of published data rather than by trial and error: if, by experiment, you decide to have a "relay off" current of 10mA (for example), it may well work with the relay you have on your test bench but there is no certainty it will work with all relays from all batches that are supplied.
Thanks a lot for your advice. When I casually read Songle's spec the first time, I did not pay any attention to words "max" and "min". Now I understand these words are critical when engineers design mission critical things. But even for hobbyists, trying to control a 220VAC induction cooker, guaranteeing switching on and off is still very important.

So I am not doing any engineering design by analysis, but sort of "hobbyist troubleshooting by analysis".

I have finished testing the KY-019 by hand. I measured the real relay operate and drop out currents and compared with the spec's max and min values. I found there is a "big" safety margin for the 3.3V Rpi Low signal to switch off the 5V relay designed for Arduino. So I can now sleep well without worrying that my induction cooker forgets to switch off.
Attachments
6u4NZmz[1].jpg
6u4NZmz[1].jpg (36.89 KiB) Viewed 2369 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 2:00 pm

gordon77 wrote:
Tue Jun 05, 2018 11:25 am
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!!
I just found one relay module which has a physical grove (laser cut, I think) "isolating" the coil traces from the relay switch contact traces which may connect 220VAC. This is the safest PCB I have found. Relay module spec mentions another safe feature:

* Relay will not operate if the input signal is disconnected. *
XplVqZs[1].jpg
grovy pcb
XplVqZs[1].jpg (102.84 KiB) Viewed 2350 times
I am an electronics and smart home hobbyist.

User avatar
DougieLawson
Posts: 36173
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 2:11 pm

It's not safe unless it's in a suitable box. The soldered contacts and screw terminals will be live when connected to the 240V mains.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 3:16 pm

DougieLawson wrote:
Tue Jun 12, 2018 2:11 pm
It's not safe unless it's in a suitable box. The soldered contacts and screw terminals will be live when connected to the 240V mains.
Ah yes, so I am making the box below.

viewtopic.php?f=63&t=77158&start=25#p1324582

viewtopic.php?f=63&t=77158&start=25#p1324744

After reading the EE guys discussing about how to earth a box, and some more goggle reading, I now understand that I don't need to use a wire as thick as possible, because if only a few mA of 220VAC leakage current passing through my body, the earth leakage detector in my home will notice it and activate the mains circuit breaker, and save my life.
I am an electronics and smart home hobbyist.

User avatar
davidcoton
Posts: 4153
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Relay Module KY-019 5V

Tue Jun 12, 2018 3:48 pm

tlfong01 wrote:
Tue Jun 12, 2018 3:16 pm
I now understand that I don't need to use a wire as thick as possible, because if only a few mA of 220VAC leakage current passing through my body, the earth leakage detector in my home will notice it and activate the mains circuit breaker, and save my life.
And what happens if someone takes you project and connects it to a circuit wherer there is no "earth leakage detector" (more correctly the RCD -- Residual Current Device), or where it has failed?
Safety with mains electricity is all about multiple layers of safety. Earth wires must be able to carry enough current for long enough to blow the MCB or fuse, not the RCD.
Signature retired

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Jun 13, 2018 7:34 am

tlfong01 wrote:
Tue Jun 12, 2018 8:27 am

I have finished testing the KY-019 by hand. I measured the real relay operate and drop out currents and compared with the spec's max and min values. I found there is a "big" safety margin for the 3.3V Rpi Low signal to switch off the 5V relay designed for Arduino.
I also tested KY019 with Optocoupler and High/Low level selection, with the following results.

Select High Level Trigger, Von = 1.8V, Voff = 1.5V
Select Low Level Trigger, Von = 3.2V, Voff = 3.5V
The attachment qdEuYXl[1].jpg is no longer available
qdEuYXl[1].jpg
KY019-1
qdEuYXl[1].jpg (52.36 KiB) Viewed 2284 times
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”