5V Relay current discussion notes

Active today
Viewed 22 times
# import GPIO and datetime
import RPi.GPIO as GPIO
import datetime

# set GPIO numbering mode and define output pins
GPIO.setup(37,GPIO.OUT) #Relay 1
GPIO.setup(35,GPIO.OUT) #Relay 2
GPIO.setup(33,GPIO.OUT) #Relay 3
GPIO.setup(31,GPIO.OUT) #Relay 4
GPIO.setup(32,GPIO.OUT) #Relay 5
GPIO.setup(36,GPIO.OUT) #Relay 6
GPIO.setup(38,GPIO.OUT) #Relay 7
GPIO.setup(40,GPIO.OUT) #Relay 8

# Turn lights on and off based on the time
    while True:
        now = datetime.datetime.now().time()
        if now.hour == 9 and now.minute == 5:

# cleanup the GPIO before finishing :)

I have a separate power supply for the relay with 5v to JD-vcc, GND to GND and vcc to 3.3v on raspberry pi.

print(now)gives me the current system time but nothing on the relay. all i want for now is to switch the relays on and of at specific times. I am new to this any help is appreciated.

 New contributor
  • 1
    thanks for the edit @ Dirk – ela kay 23 hours ago
  • Troubleshooting suggestions: (1) When you do “GPIO.cleanup()” at the very end of code, all GPIO pins you setup earlier as OUTPUT mode will automatically return to INPUT mode, which is the /init/default/reset at power on mode. This “Automatically-return-all-GPIO-pins-to-input-mode-before-exit” is to prevent the always messing up things newbie forgetting to switch off the nuclear reactor and melt down or blow up something. / to continue, … – tlfong01 23 hours ago
  • (2) Your JD-Vcc relay might be of “Low level activate/trigger” type designed for Arduino and might not work with Rpi. You might like to give us the link to your relay, so everybody can check it out. The following two Q&A links give more details: (a) “Rpi cannot activate 5V Relay with optical isolator and JD-Vcc jumper”: raspberrypi.stackexchange.com/questions/95862/… (b) “Rpi GPIO 5V Relay Problem”: raspberrypi.stackexchange.com/questions/99988/…. – tlfong01 23 hours ago
  • 1
    Post a photo of your wiring. – CoderMike 22 hours ago
  • You haven’t specified what module you are using, but it is probably one of the sub-standard devices “designed” for Arduino (like dozens of others). See raspberrypi.stackexchange.com/a/100014/8697 No fiddling with code will make it work. – Milliways 22 hours ago
  • 2
    @tlfong01 thank you for responding. my 5v power supply to the relay board had insufficient current. I switched that out and it solved my problem. – ela kay 22 hours ago
  • I am glad to hear that you have solved the problem yourself. Have a great weekend. Cheers. – tlfong01 19 hours ago
  • 1
    @elakay Please make your comment about the solution an answer and accept it after two days with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo 18 hours ago

In my case the current from my power supply to the relay module was not sufficient at 1.0 amps. I swapped it out with one rated at 2.0 amps and that got my relays switching. Thank you all.

 New contributor
  • Thank you for your answer. Yes, usually a 5V relay switch such as Songle or TongLing has roughly 80mA activation/saturation current. So if ALL 8 relay channel switches are on, the total current might be of the order 1A. (The Rpi GPIO pint current to trigger the relay module (not the relay switch) is only less than 10mA. / to continue, … – tlfong01 53 secs ago   Edit
  • References: (1) “KY019 5V Relay Module Rpi GPIO Signal Current and Relay Swtich Current”: raspberrypi.org/forums/viewtopic.php?f=37&t=77158#p1323061 (2) “Songle/Tongling 5V Relay Switch Activate/Deactivate Current”: raspberrypi.org/forums/… (3) “Songle/Tongling 5V Relay Switch Activate/Deactivate Current”: raspberrypi.org/forums/… – tlfong01 36 secs ago   Edit

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: