Dam_Fr
Posts: 6
Joined: Sun Feb 08, 2015 6:45 pm

Raspberry Pi + relay GPIO dont work

Mon Jan 28, 2019 11:54 pm

Hello,

I am trying to use my low cost aliexpress relay to power a 220V motor
Image

I use webiopi to control GPIO
Image

My "Raspberry Pi 3 Model B Plus Rev 1.3" is powered with a standard wall charger (3A)
I plug VCC on +5V pin of Rpi
I plug GND to 0V on Rpi
I plug IN to PIN 40 of the GPIO (mode output)

Whatever I put on PIN 40 "0" or "1", the relay stay ON (motor running)
But If I put PIN 40 mode to INPUT mode instead of OUTPUT mode, the relay switch and I get the motor off.

Why it's not working when mode is output on the PIN ?

Some experiments Vcc on +5V and GND on 0V, IN is the relay IN PIN that I had try to connect on raspberry Pi PIN :

Code: Select all

|     IN            | Vcc (mA) | IN  (mA) | Switch status |
| Not plug          |   3.0 mA |      N/A |           OFF |
| Pin 40 mode in    |   3.0 mA |   0.0 mA |           OFF |
| Pin 40 mode out 0 |  67.0 mA |  -4.0 mA |            ON |
| Pin 40 mode out 1 |  63.0 mA |  -0.7 mA |            ON |
| Plug on 0V        |  70.0 mA |   4.0 mA |            ON |
| Plug on 5V        |   3.0 mA |   0.0 mA |           OFF |

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 1:46 am

Dam_Fr wrote:
Mon Jan 28, 2019 11:54 pm
I put PIN "0" or "1", relay stay ON, ...
If I put PIN mode to INPUT mode instead of OUTPUT mode, the relay off, ...
Why it's not working when mode is output on the PIN ?

Relay always On either GPIO outputs Low or High, Off only if GPIO set to input

The For Arduino Only Relay Spec
The low trigger on relay is designed for Arduino whose output Low is similar to Rpi, but its output High is about 4V, much higher than Rpi's output about 3V.

The Problem
1. Both Arduino Low or Rpi Low can switch the Low trigger On Relay. No Problem.
2a. Now the problem. Arduino's High of 4V switches off the relay, which is designed to switch off by 4V or above.
2b. But Rpi's High is only 3V. The Relay doesn't like it, therefore does nothing.


.....In short, Rpi GPIO High is not high enough to switch off the relay.

Get Around and Risks
1a. To switch off relay, set Rpi GPIO pin to input put mode
1b. Risk 1 - The Arduino guys would LOL the stupidity of Rpi guys,
1c. Risk 2 - Less than 5% chance (my guess only) that Rpi ages faster, or gets fried sooner or later.
2a. / to continue, ...

Solutions
1. Throw away the Arduino only relay, buy a High trigger one instead.
2. Shift up the Rpi 3V3 GPIO signals to 5V0, problem would disappear.


Relay JinJa Question
Why a relay is called a relay?

References
AliExpress 5V 1 Channel Relay Low Level Tirgger for Arduino
https://fr.aliexpress.com/item/Free-Shi ... 6c37UrcD2j
...
Attachments
for_arduino_only_2019jan2901.jpg
for_arduino_only_2019jan2901.jpg (80.46 KiB) Viewed 2819 times
Last edited by tlfong01 on Tue Jan 29, 2019 3:23 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

PhatFil
Posts: 1233
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 2:17 am

while i have not used the relay listed, it looks like one i have used with a 3.3v arduino, the 5v vcc input is used to switch the relay and an onboard transistor uses the 3.3v in signal to switch the 5v vcc feed to power the relay coil, so the relay will use more than 5ma but only 5ma from the gpio is needed to switch the transistor ->the relay. ** I think**

I suspect that if you use a resistor to pull your gpio to ground you may have success as if not pulled down to ground the floating voltage of the not high gpio pin may still have the oomph required to keep the transistor and therefore the relay switched on.. ??

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 6:07 am

PhatFil wrote:
Tue Jan 29, 2019 2:17 am
the relay ... looks like one i have used with a 3.3v arduino, the 5v vcc input is used to switch the relay and an on board transistor uses the 3.3v in signal to switch the 5v vcc feed to power the relay coil, so the relay will use more than 5ma but only 5ma from the gpio is needed to switch the transistor ->the relay. ** I think**

Get around for Arduino Only Relay - Part 1

I agree. Let me use the 5V high level trigger relay module KY019 as an example.

KY019 High Trigger Relay Module Spec
https://www.raspberrypi.org/forums/view ... 8#p1323061

KY019 High Trigger Relay Module Schematic
https://www.raspberrypi.org/forums/view ... 5#p1325269

1. Rpi GPIO High signal of about 3V at the input terminal of the module drives the PNP BJT SS8050, with a current of about 5mA .

2. SS8050 amplifies the 5mA current to about 50mA and switches on the Songle 5V relay.

3. Songle relay NO terminal is now closed, passing 5/12/24/110/220V DC/AC current of up to 10A to turn on fan, heater etc, ...


So far so good, it is only the mirror image twin sister of KY019, Low level trigger, using PNP BJT, that causes all the trouble, and make so many miserable Rpi relay newbies weeping in the dark, ... :mrgreen:

To continue next post.
Last edited by tlfong01 on Tue Jan 29, 2019 12:43 pm, 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: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 7:35 am

tlfong01 wrote:
Tue Jan 29, 2019 6:07 am
This post seems duplicated by my careless mistake. My apologies.
Last edited by tlfong01 on Tue Jan 29, 2019 8:49 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: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 7:39 am

tlfong01 wrote:
Tue Jan 29, 2019 6:07 am
Get around for Arduino Only Relay - Part 1
So far so good, it is only the mirror image twin sister of KY019, Low level trigger, using PNP BJT, that causes all the trouble, and make so many Rpi relay newbies weeping in the dark, ... :mrgreen:

Get around for Arduino Only Relay - Part 2

Now let us compare the twin sisters, one pretty NPN, another ugly PNP.

Arduino GPIO High vs Rpi GPIO High
https://www.raspberrypi.org/forums/view ... 0#p1328320

Arduino Only Low level trigger relays
https://www.raspberrypi.org/forums/view ... 5#p1331732

To continue next post.
...
Attachments
pnp_low_trig_relay_2019jan2903.jpg
pnp_low_trig_relay_2019jan2903.jpg (190.17 KiB) Viewed 2733 times
Last edited by tlfong01 on Tue Jan 29, 2019 9:29 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

Dam_Fr
Posts: 6
Joined: Sun Feb 08, 2015 6:45 pm

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 8:24 am

Hi, Thanks for your quick answer.

I love your risks, especially the LOL from Arduino users.

About solution,
1. Throw away the Arduino only relay, buy a High trigger one instead.
Done :)
Is this one better ? (1 Channel)
Image

But meanwhile, I would like to explore the :
2. Shift up the Rpi 3V3 GPIO signals to 5V0, problem would disappear.
I have some 3.3K and 10K resistances, I must connect a 10k resistance between GPIO PIN 40 and 5V ?

If I understand, PhatFil, you suggest the opposit ?
I suspect that if you use a resistor to pull your gpio to ground you may have success as if not pulled down to ground the floating voltage of the not high gpio pin may still have the oomph required to keep the transistor and therefore the relay switched on.. ??
I must connect a 10k resistance between GPIO PIN 40 and GND ?

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 8:35 am

Dam_Fr wrote:
Mon Jan 28, 2019 11:54 pm
I am trying to use my low cost aliexpress relay to power a 220V motor
What is the specification of your motor? Because you might need a other relay for this task.

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 8:40 am

Dam_Fr wrote:
Tue Jan 29, 2019 8:24 am
1. Throw away the Arduino only relay, buy a High trigger one instead.
Done :)
Is this one better?
https://ae01.alicdn.com/kf/HTB1DZYVa6rg ... -Haute.jpg

Jumper Select High/Low Trigger Relay

Yes, much better.

Jumper Select High Low Trigghet Test Results 1/2
https://www.raspberrypi.org/forums/view ... 5#p1330108

Jumper Select High Low Trigghet Test Results 2/2
https://www.raspberrypi.org/forums/view ... 5#p1330476
I am an electronics and smart home hobbyist.

Dam_Fr
Posts: 6
Joined: Sun Feb 08, 2015 6:45 pm

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 9:41 am

Brandon92 wrote:
Tue Jan 29, 2019 8:35 am
Dam_Fr wrote:
Mon Jan 28, 2019 11:54 pm
I am trying to use my low cost aliexpress relay to power a 220V motor
What is the specification of your motor? Because you might need a other relay for this task.
I don't know, this is a bath tub 500W balneotherapy Pump.
But the relay works fine when On or OFF, my issue is on trigger

Dam_Fr
Posts: 6
Joined: Sun Feb 08, 2015 6:45 pm

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 9:45 am

@tlfong01
Any advise on :

But meanwhile, I would like to explore the :

2. Shift up the Rpi 3V3 GPIO signals to 5V0, problem would disappear.

I have some 3.3K and 10K resistances, I must connect a 10k resistance between GPIO PIN 40 and 5V ?

If I understand, PhatFil, you suggest the opposit ?

I suspect that if you use a resistor to pull your gpio to ground you may have success as if not pulled down to ground the floating voltage of the not high gpio pin may still have the oomph required to keep the transistor and therefore the relay switched on.. ??

I must connect a 10k resistance between GPIO PIN 40 and GND ?

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 12:52 pm

Dam_Fr wrote:
Tue Jan 29, 2019 9:45 am
@tlfong01
Any advise on :
But meanwhile, I would like to explore the :
2. Shift up the Rpi 3V3 GPIO signals to 5V0, problem would disappear.

Logical Level Conversion / Up Shifting Experiments

You might like to read my following blog like posts:

Logical Level Converter Review
https://www.raspberrypi.org/forums/view ... 0#p1328090

Level Converter Using HCT125
https://www.raspberrypi.org/forums/view ... 0#p1328094

Arduino GPIO High vs Rpi GPIO High
https://www.raspberrypi.org/forums/view ... 0#p1328320

Level Converter using HC03
https://www.raspberrypi.org/forums/view ... 0#p1328320

Level Converter using 2N2222
https://www.raspberrypi.org/forums/view ... 0#p1328573

Level Converter Using HC03 + HC04
https://www.raspberrypi.org/forums/view ... 0#p1328588

Level Converter Using ULN2803 and UDN2981
https://www.raspberrypi.org/forums/view ... 0#p1328604

Level Converter Using TSX0104E
https://www.raspberrypi.org/forums/view ... 0#p1328676

TSX0104 + MCP23017 to control relay schematic
https://www.raspberrypi.org/forums/view ... 0#p1343814

TSX0104 + MCP23017 + ULN2803 to control relay schematic
https://www.raspberrypi.org/forums/view ... i][/color]
I am an electronics and smart home hobbyist.

PhatFil
Posts: 1233
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 1:04 pm

Dam_Fr wrote:
Tue Jan 29, 2019 8:24 am
.
.
.
I have some 3.3K and 10K resistances, I must connect a 10k resistance between GPIO PIN 40 and 5V ?

If I understand, PhatFil, you suggest the opposit ?
I suspect that if you use a resistor to pull your gpio to ground you may have success as if not pulled down to ground the floating voltage of the not high gpio pin may still have the oomph required to keep the transistor and therefore the relay switched on.. ??
I must connect a 10k resistance between GPIO PIN 40 and GND ?
I think so...that should pull the Off (LOW) to the 0v ground level, as otherwise it could float at a nominally +ve voltage. when not On (High)

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 1:32 pm

Dam_Fr wrote:
Tue Jan 29, 2019 8:24 am
I have some 3.3K and 10K resistances, I must connect a 10k resistance between GPIO PIN 40 and 5V ?

Connecting GPIO pin through 10k to 5V

Let me see. Rpi is a weak guy, its GPIO pins are not 5V tolerant, which means 5V is fatal.

So I guess your Pin 40 would melt down in 0.1 sec. There is 10% chance that you might smell plastic burning, and with a little bit of luck, you can also see white smoke.

There is 50% chance that only the Pin 40 circuit is damaged, all the rest is still working OK. Since you don't need that many GPIO pins anyway, it is worth doing the experiment. :mrgreen:
I am an electronics and smart home hobbyist.

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

Re: Raspberry Pi + relay GPIO dont work

Tue Jan 29, 2019 2:29 pm

tlfong01 wrote:
Tue Jan 29, 2019 1:32 pm
There is 50% chance that only the Pin 40 circuit is damaged, all the rest is still working OK.
There is a very good chance that the rest of the chip will be damaged as the damage will slowly spread across the chip even after the bad voltage has been removed.

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

Re: Raspberry Pi + relay GPIO dont work

Wed Jan 30, 2019 3:44 am

tlfong01 wrote:
Tue Jan 29, 2019 7:39 am
tlfong01 wrote:
Tue Jan 29, 2019 6:07 am
Get around for Arduino Only Relay - Part 1
So far so good, it is only the mirror image twin sister of KY019, Low level trigger, using PNP BJT, that causes all the trouble, and make so many Rpi relay newbies weeping in the dark, ... :mrgreen:
Get around for Arduino Only Relay - Part 2
Now let us compare the twin sisters, one pretty NPN, another ugly PNP.

PNP and NPN Mirror Image - The Good, the Bad, and the Ugly Relays

Once upon a time (2018june) when I was a relay newbie, I googled wildly and learned why some Arduino relays won't work for Rpi, and how the scary "latch up" thing might kill a Rpi (I learnt it the hard way, frying one Rpi3B+ by over voltage) .

I also followed the experts on using ULN2803 to shift up the Rpi GPIO signals, MCP23017 for scalability (controlling 128 relays) and flexibility (using real time clock and sensors), ...

References
CONNECTING A 5V RELAY BOARD Postby geoffr » 2012-Aug-22 Wed 7:39 pm
https://www.raspberrypi.org/forums/view ... or#p156286

[PNP and NPN Relay Mirroring] RE: CONNECTING A 5V RELAY BOARD Postby kaos » 2012-Aug-23 Thu 1:48 am
https://www.raspberrypi.org/forums/view ... or#p156286

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

[A lightning transistor reference, for those that feel about to drown in acronyms:
There are two basic types of bipolar transistors (which leaves out FET's and a few other types that I won't cover here); NPN and PNP. PNP transistors go into conduction when a negative voltage of about 0.7V (for silicon transistors) is applied to base, relative to emitter. When that happens, current can flow from emitter to collector. NPN transitors are the same, except polarities are exchanged; they go into conduction when base is positive in relation to emitter, and the main current flow is from collector to emitter. The maximum collector current that will flow is a multiple of the base current. This multiple is known as hfe. It varies from one transistor type to an other, but is commonly about 100 to 200 for small signal transistors. Besides this, there is of course a maximum collector current and power that the transistor can handle. In schematics, the emitter and collector connections are the angled lines on one side of the symbol, while the base is the lone connection on the other side. The emitter is marked with an arrow. The direction of the arrow tells us whether it is an NPN or PNP transistor; it points outwards in an NPN symbol, but inwards is a PNP symbol.]

Best regards, Kári.


The Good, the Bad and the Ugly - The Danish National Symphony Orchestra (Live) 17,915,739 views
https://www.youtube.com/watch?v=KkM71JPHfjk
...
Attachments
good_and_ugly_relay_2019jan3001.jpg
good_and_ugly_relay_2019jan3001.jpg (134.32 KiB) Viewed 2648 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: Raspberry Pi + relay GPIO dont work

Wed Jan 30, 2019 6:41 am

tlfong01 wrote:
Wed Jan 30, 2019 3:44 am
PNP and NPN Mirror Image
RE: CONNECTING A 5V RELAY BOARD Postby kaos » 2012-Aug-23 Thu 1:48 am
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, ...
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 ... then chances are it will work with the Raspi's 3.3V signals, even if it is designed for 5V.
A lightning transistor reference, for those that feel about to drown in acronyms


Making Arduino High Trigger Relay Rpi Friendly - Part n

@kaos gives a lightning BJT transistor reference for the newbies. But I hope to know more about the basics, like BJT and CMOS, what is a P-N junction, what is going on at the junction, how does the BJTs inside a CMOS thing (Rpi) causes the latch up and fry its GPIO pin, etc, ... So I googled a youtube about transistors.

The video needs prerequisite knowledge of middle school physics which I am OK. So I watched it twice, ... :mrgreen:


Transistors, How do they work? - Patreon, 2016, 7 minutes, 4,287,136 views, 2,390 comments
https://www.youtube.com/watch?v=7ukDKVHnac4
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: Raspberry Pi + relay GPIO dont work

Wed Jan 30, 2019 9:06 am

tlfong01 wrote:
Tue Jan 29, 2019 12:52 pm
Dam_Fr wrote:
Tue Jan 29, 2019 9:45 am
@tlfong01
Any advise on :
But meanwhile, I would like to explore the :
2. Shift up the Rpi 3V3 GPIO signals to 5V0, problem would disappear.
Logical Level Conversion / Up Shifting Experiments
You might like to read my following blog like posts:

TXB0108 Logical Level Converter Studies Notes

I just started a side project on level shifter TXB0108. I have been playing with TSX0102 and TXS0104 and found them more or less OK. Now I wish to scale up my I2C devices to more than 128. So I need to consider a 1 to 8 demultiplexing level converter.

I am casually writing random notes here and hope to group them into a journal of entries in a dedicated blogging site to be set up later.

AdaFruit 8-channel Bi-directional Logic Level Converter - TXB0108 PRODUCT ID: 395 $8.00
https://www.adafruit.com/product/395

TXB08 Datasheet
https://cdn-shop.adafruit.com/datasheets/txb0108.pdf

TXS08 Application Notes
https://cdn-shop.adafruit.com/datasheet ... ppnote.pdf

DESCRIPTION

Because the Arduino (and Basic Stamp) are 5V devices, and most modern sensors, displays, flash cards and modes are 3.3V-only, many makers find that they need to perform level shifting/conversion to protect the 3.3V device from 5V.

Although one can use resistors to make a divider, for high speed transfers, the resistors can add a lot of slew and cause havoc that is tough to debug. For that reason, we like using 4050/74LVX245 series and similar logic to perform proper level shifting. Only problem is that they are only good in one direction which can be a problem for some specialty bi-diectional interfaces and also makes wiring a little hairy.

That's where this lovely chip, the TXB0108 bi-directional level converter comes in! This chip perform bidirectional level shifting from pretty much any voltage to any voltage and will auto-detect the direction. Only thing that doesn't work well with this chip is i2c (because it uses strong pullups which confuse auto-direction sensor). If you need to use pullups, you can but they should be at least 50K ohm - the ones internal to AVRs/Arduino are about 100K ohm so those are OK! Its a little more luxurious than a 74LVX245 but if you just don't want to worry about directional pins this is a life saver!

Since this chip is a special bi-directional level shifter it does not have strong output pins that can drive LEDs or long cables, it's meant to sit on a breadboard between two logic chips! If you do not need instant bi-directional support, we suggest the 74LVX245 as below which has strong output drive.

This breakout saves you from having to solder the very fine pitch packages that this chip comes with. We also add 0.1uF caps onto both sides and a 10K pull-up resistor on the output enable pin so you can use it right out of the box!

TECHNICAL DETAILS

TXB0108 Datasheet
TXB0108 App note detailing how it works!

EagleCAD PCB files on GitHub
Fritzing object in Adafruit Fritzing library
I am an electronics and smart home hobbyist.

Dam_Fr
Posts: 6
Joined: Sun Feb 08, 2015 6:45 pm

Re: Raspberry Pi + relay GPIO dont work

Wed Jan 30, 2019 12:58 pm

Thanks everyone for your help.

I had buy the new relay.
I had try the relay with an arduino nano and it's 100% OK.

So now, I had to choose between :
1 - Wait for delivery
2 - Buy a digital level converter
3 - Find a way to make rpi give order to arduino nano.
4 - Test PhatFil solution (pull down)

Thanks tlfong01 for all the documentation, hard to read and understand all those lines :-) But anyway thanks a lot for your help.

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

Re: Raspberry Pi + relay GPIO dont work

Wed Jan 30, 2019 2:34 pm

Dam_Fr wrote:
Wed Jan 30, 2019 12:58 pm
a. Buy a digital level converter
b. Test PhatFil solution (pull down)
c. tlfong01 documentation hard to read and understand all those lines

a. If your new relay is working OK, then you can use your Arduino program to complete you project.

b. If you have a long term plan to learn Rpi, there is no hurry. Rpi is a very complicated thing. Eat the elephant one bite at a time.

c. My notes on relays is based on my 6 hobbyist month's experience. So even you wish to catch up, you need 6 months.

You may like to set up a humble goal, such as how to modify the Arduino only relay to make it Rpi compatible. This is what I am trying to show.

My aim is to explain what is the problem, and how to solve it. My objective is problem based learning - find a problem, try to solve it, and learn from trials and errors.

And if your new relay is compatible with Rpi, there is no hurry to try any complicated level converter. You can just start small, try using a transistor 2N2222 to do the job.
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: Raspberry Pi + relay GPIO dont work

Fri Feb 01, 2019 3:49 am

Dam_Fr wrote:
Wed Jan 30, 2019 12:58 pm
Test PhatFil solution (pull down), ...
Thanks tlfong01 for all the documentation, hard to read and understand all those lines, ...

"Am I to refuse to eat because I do not fully understand the mechanism of digestion?" - Oliver Heaviside
https://en.wikiquote.org/wiki/Oliver_Heaviside

Well, life is short, so you don't have time to try to understand everything. What I have been trying is pretending to know a little bit more than most guys, thus gaining more respect than I deserve, and that is my way making a living, ...

Coming back to the get around to convert a non rpi friendly relay to become rpi friendly, you only need to understand a little bit of basic electronics, such as the forward bias voltage of a diode is roughly 1V, and if you have a little bit of soldering skills, then you can pretend to be a relay saviour, bringing joy to the world of miserable Rpi relay newbies (weeping in the dark), ... :mrgreen:


Shorting LED to Shift Rpi GPIO Signal from 3V to 5V, well, sort of
viewtopic.php?t=217027#p1334760

Pull down LED voltage
https://www.raspberrypi.org/forums/view ... 5#p1400957

The Great Pretender - Freddie Mercury 17,026,580 views
https://www.youtube.com/watch?v=mLRjFWDGs1g

/ to continue, .....
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: Raspberry Pi + relay GPIO dont work

Fri Feb 01, 2019 6:06 am

tlfong01 wrote:
Fri Feb 01, 2019 3:49 am
Coming back to the get around to convert a non rpi friendly relay
and a little bit of soldering skills

Low Level Trigger Relay Get Around Notes Part n

https://penzu.com/p/6cb14afb
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: Raspberry Pi + relay GPIO dont work

Fri Feb 01, 2019 6:51 am

Duplicated post by mistake. Will delete later. My apologies.
Last edited by tlfong01 on Fri Feb 01, 2019 8:37 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: Raspberry Pi + relay GPIO dont work

Fri Feb 01, 2019 6:52 am

tlfong01 wrote:
Fri Feb 01, 2019 6:06 am
tlfong01 wrote:
Fri Feb 01, 2019 3:49 am
Coming back to the get around to convert a non rpi friendly relay
and a little bit of soldering skills

Low Level Trigger Relay Get Around Notes Part n

https://penzu.com/p/6cb14afb

Update 2019feb01hkt1448

I checked the High Level trigger off level, then shorted the status LED, and checked again. Trigger level is still around 4.2V, almost no change at all.

Conclusion

Total failure, my guess is wrong!

https://penzu.com/p/6cb14afb

What a bad experiment results to start my weekend! I am giving up and now returning to the more interesting experiment - ECG!

ECG Experiment
https://www.raspberrypi.org/forums/view ... 5#p1423837
...
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: Raspberry Pi + relay GPIO dont work

Sat Feb 02, 2019 2:18 am

tlfong01 wrote:
Fri Feb 01, 2019 6:52 am
I checked the High Level trigger off level, then shorted the status LED, and checked again. Trigger level is still around 4.2V, almost no change at all.
Conclusion
Total failure, my guess is wrong!
What a bad experiment results to start my weekend!


Second Trial

I found that changing PNP SS8550's biasing resistor value from 1k to 50k makes the relay on/off trigger levels 0.25V and 3.01V, therefore marginally compatible to Rpi. But the preformance would not be stable. So I think it is a better idea to shift up Rpi's GPIO signals.

https://penzu.com/p/3c989c45 (penzu journal entry with a bigger picture)
...
Attachments
relay_trig_lvl_vs_r2_2019feb0201.jpg
relay_trig_lvl_vs_r2_2019feb0201.jpg (106.18 KiB) Viewed 2455 times
I am an electronics and smart home hobbyist.

Return to “Other”