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.

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.

Hiya

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.

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.

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).

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.

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 16351 times

Last edited by tlfong01 on Wed Jan 16, 2019 1:27 pm, edited 10 times in total.

........ 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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).

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.

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.

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)!

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.

Thanks a lot for your advice. I used to play with 5V to 12V DC motors and have not had any problems.

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.

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.

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.

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)!

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!!

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.