MaxPrive
Posts: 18
Joined: Mon Oct 03, 2016 12:05 am

[HELP] One channel relay voltage problem

Mon Oct 03, 2016 12:52 am

I have a problem with relay serve. I've used simple code on python for switching GPIO output 0/1 but the relay do only one operation - close and doesn't switch back.

The relay is connected to 5V = VCC, Ground = GND and GPIO 23 = INN.

When i messure the voltage on VCC and INN on startup its about 0.6volts. When i run the script and setup the pin and make the output LOW(relay ON) the voltage goes to 4,75 volt and the relay is turning on but when i set te output to HIGH(relay OFF) nothing happend and the voltage is about 1.5v volt.

When i switch the board to 3.3v everything worked fine but its 5v relay why do i have to connect it to 3.3v to get it working?

Can someone help me out ? :?: :?:

My code is:

Code: Select all

import RPi.GPIO as GPIO
import time

RELAY_PIN = 23
GPIO.setmode(GPIO.BCM)
GPIO.setup(RELAY_PIN, GPIO.OUT)
 
print 'Relay ON'
GPIO.output(RELAY_PIN, GPIO.LOW)

time.sleep(2)

print 'Relay OFF'
GPIO.output(RELAY_PIN, GPIO.HIGH)
Relay board is:
Image

broe23
Posts: 903
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 1:35 am

Post the manufacturer and model of that board, along with the diagram for the relay. There should be a latching circuit to allow you to decide if it is open or closed when powered down. What brand of multi-meter are you using to take your readings? There are Digital meters that you can dump the readings to a computer via USB.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

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

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 9:08 am

You should normally take your voltage measurements with reference to GND, not VCC. It is much less confusing.

The relay may be 5V, but the Pi GPIOs are 3V3. Obviously 3V3 (High) is not enough to release the relay when it's on a 5V supply.

Be thankful that it works at 3V3 -- however, I would be cautious about driving a relay from the Pi's 3V3, there is not much spare current available (which model Pi?).
A better solution would be to wire a transistor to switch from the GPIO, and then drive the relay board connected to 5V. Ask again if you need a circuit.
Signature retired

MaxPrive
Posts: 18
Joined: Mon Oct 03, 2016 12:05 am

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 11:58 am

broe23 wrote:Post the manufacturer and model of that board, along with the diagram for the relay. There should be a latching circuit to allow you to decide if it is open or closed when powered down. What brand of multi-meter are you using to take your readings? There are Digital meters that you can dump the readings to a computer via USB.
I am using a "VOLTCRAFT green multimeter VC150"

Image

MaxPrive
Posts: 18
Joined: Mon Oct 03, 2016 12:05 am

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 12:11 pm

davidcoton wrote:You should normally take your voltage measurements with reference to GND, not VCC. It is much less confusing.

The relay may be 5V, but the Pi GPIOs are 3V3. Obviously 3V3 (High) is not enough to release the relay when it's on a 5V supply.

Be thankful that it works at 3V3 -- however, I would be cautious about driving a relay from the Pi's 3V3, there is not much spare current available (which model Pi?).
A better solution would be to wire a transistor to switch from the GPIO, and then drive the relay board connected to 5V. Ask again if you need a circuit.
Thanks for your message. I'm using a raspberry pi 2 model B. When i take my voltage measurements with reference to GND the voltage is 0v. When i set the GPIO to high i measure 3.3v then when i set the GPIO to LOW i measure 0v. I have enough 3.3v power pins so thats not the problem but i wanne know whey he don't switch on te 5v power pin. Can you send me a circuit? I have all kind of transistors but which one and how do i have to connect him between the GPIO wire and the relay. and which way :)

Sorry for my bad english haha. im dutch :D

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

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 2:16 pm

MaxPrive wrote: but i wanne know whey he don't switch on te 5v power pin.
The Pi's SOC runs at 3V3 and below, switching 5V requires an external circuit.
Your relay has (I think) a PNP switching transistor relative to VCC, so pulling IN to 3V3 with a 5V relay supply looks like a LOW, not a HIGH.
MaxPrive wrote:Can you send me a circuit? I have all kind of transistors but which one and how do i have to connect him between the GPIO wire and the relay. and which way :)
interface.jpg
interface.jpg (40.98 KiB) Viewed 2139 times
MaxPrive wrote:Sorry for my bad english haha. im dutch :D
NP. Your English beats my Dutch 100%.
Signature retired

User avatar
faramon
Posts: 123
Joined: Sat Jun 11, 2016 8:36 am
Location: Croatia

Re: [HELP] One channel relay voltage problem

Mon Oct 03, 2016 2:43 pm

Hi,

I have connected my Relay with similar as on the picture (sheme) and for a three months I do not have problem with the Relay, It works perfect. See my post:
viewtopic.php?f=63&t=151148&p=992304&hi ... on#p992304

Faramon

crazyelectronicsguy
Posts: 1
Joined: Sat Oct 22, 2016 6:01 pm

Re: [HELP] One channel relay voltage problem

Sat Oct 22, 2016 6:12 pm

Most of the relay modules have an on-board power transistor to provide the current required for Turning ON the relay so you don't have to worry about adding transistor for driving the relay. But if you are interested in making your own relay driver circuit then check the link http://www.dnatechindia.com/Tutorial/80 ... oller.html you can use the same circuit for Interfacing relay to Raspberry Pi

User avatar
faramon
Posts: 123
Joined: Sat Jun 11, 2016 8:36 am
Location: Croatia

Re: [HELP] One channel relay voltage problem

Sun Oct 23, 2016 6:09 pm

Whay I put transistor between relay IN and raspberry pi GPIO OUT?!?!
I found that relay IN normaly put signal out and because of fear of burnout GPIO, I rather manage the circuit through the Transistor.
I know about PULL DOWN and PULL UP but if GPIO purpose is to push 3,3 V OUT from PIN then I think is normally to PUT signal OUT rather then receive the 3,3 V to get ZERO in potential difference.

Faramon

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

Re: [HELP] One channel relay voltage problem

Sun Oct 23, 2016 9:31 pm

crazyelectronicsguy wrote:Most of the relay modules have an on-board power transistor to provide the current required for Turning ON the relay so you don't have to worry about adding transistor for driving the relay.
That is true if the on-(relay)board transistor is an NPN type, referenced to ground. However some boards apparently use PNP transistors referenced to the relay supply. This will not matter with a 3V3 relay supply (note that the input will be active LOW), but with a 5V relay supply the Pi's GPIO high at 3V3 will still look like an ON signal to the transistor. So in this case an extra external transistor is needed as shown in my post above.
Signature retired

Return to “General discussion”