Testing Raspberry PI JBtek 8 Channel DC 5V Relay Module
Post ReplyTesting Raspberry PI JBtek 8 Channel DC 5V Relay ModulePosted: Tuesday, May 8, 2018 [15:33:54] - 1
JBtek 8 Channel DC 5V Relay Module software and connectionPosted: Tuesday, May 8, 2018 [18:20:00] - 2
Connecting a module is quite easy: Based on connection writing a Python script: import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # initialized pins pinList = [2, 3, 4, 17, 27, 22, 10, 9] # loop through pins and set GPIOs accordingly for i in pinList: GPIO.setup(i, GPIO.OUT) GPIO.output(i, GPIO.HIGH) # sleep between turning on in the main loop SleepTimeL = 1 try: GPIO.output(2, GPIO.LOW) print "One" time.sleep(SleepTimeL); GPIO.output(3, GPIO.LOW) print "Two" time.sleep(SleepTimeL); GPIO.output(4, GPIO.LOW) print "Three" time.sleep(SleepTimeL); GPIO.output(17, GPIO.LOW) print "Four" time.sleep(SleepTimeL); GPIO.output(27, GPIO.LOW) print "Five" time.sleep(SleepTimeL); GPIO.output(22, GPIO.LOW) print "Six" time.sleep(SleepTimeL); GPIO.output(10, GPIO.LOW) print "Seven" time.sleep(SleepTimeL); GPIO.output(9, GPIO.LOW) print "Eight" time.sleep(SleepTimeL); GPIO.cleanup() print "End of program" # End program cleanly with keyboard except KeyboardInterrupt: print " Quit" # Clean-up GPIO.cleanup() script will lid-up all lights and on exit turn them off. Now write individual scripts for every relay: # turn relay 1 "ON" import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) pinList = [2] for i in pinList: GPIO.setup(i, GPIO.OUT) try: GPIO.output(2, GPIO.LOW) print "turned on" except KeyboardInterrupt: print "Quit" GPIO.cleanup() # turn relay 1 "OFF" import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) pinList = [2] for i in pinList: GPIO.setup(i, GPIO.OUT) try: GPIO.output(2, GPIO.HIGH) print "turned off" except KeyboardInterrupt: print "Quit" GPIO.cleanup() Create ON/OFF scripts for every relay and check them with simple Perl script: @a = (1..8); foreach $i (@a) { print "Relay $i\n"; print "On\n"; `python /home/pi/Desktop/relay/$i.on.py`; sleep(1); print "Off\n"; `python /home/pi/Desktop/relay/$i.off.py`; sleep(1); } ## FOREACH END on video above this Perl script ran remotely. |
Raspberry Pi and relay module frame 3D model file.Posted: Tuesday, May 8, 2018 [18:30:13] - 3
This post is part of the Smart Garden project at: www.codemacs.com/raspberr.. Here is a link to STL file for the Raspberry Pi and relay module frame: www.codemacs.com/download.. Enjoy! |
RE: Testing Raspberry PI JBtek 8 Channel DC 5V Relay ModulePosted: Wednesday, May 9, 2018 [21:42:58] - 4
Posted by:ItweetForStuffPosts: 1 | Any chance you could make a stl that would fit a RPI Zero? Or could you make the original file available? Thanks |
RE: Testing Raspberry PI JBtek 8 Channel DC 5V Relay ModulePosted: Wednesday, May 9, 2018 [21:45:31] - 5
Sure, when I'll get a RPi zero - I'll make one. Cheers |