Relay control using Raspberry Pi and Bash Shell
Remote control of AC Power to devices using rpi and a single relay module. This repo has bash shell scripts used to control relays via GPIO's pins on the 40 pin header of a Raspberry PI 3B or 4B.
singlerelay.sh
tested with RPI3B and RPI4B and Digital Data Logger Controllable Four Outlet Power Relay Module version 2 from Adafruit https://www.adafruit.com/product/2935 RPI3B header Pin 23/GPIO 11 as control output and RPI3B header pin 25 as ground.
Note that this relay module powers it's own relay and only needs signal pins from the RPI
quadrelay.sh and testquadrelay.sh
tested with RPI3B and a four relay module "DZS Elec 5V 4 Channel Relay Optocoupler Isolation Module Red Board 3-5V High and 0-1.5V Low Level Triggered Load AC 0-250V / DC 0-30V 10A SCM IO Control" at https://smile.amazon.com/dp/B07BDJJTLZ?ref=ppx_yo2ov_dt_b_product_details&th=1
relay control gpio:
RPI gpio 11 pin 23 to Relay Module IN1
RPI gpio 9 pin 21 to Relay Module IN2
RPI gpio 10 pin 19 to Relay Module IN3
RPI gpio 22 pin 15 to Relay Module IN4
RPI GND on Pin 6 to Relay Module DC-
Note that the RPI cannot provide sufficient current on it's own to power more than one relay activated at a time. For my testing I provided separate power to the relay from a second USB charging port. USB 5V to Relay Module DC+ and USB GND to Relay Module DC-
Quad relay wiring diagram is below:
Adding buttons to allow local control of relays
Button control gpio connections:
RPI gpio 23 pin 16 to Switch 1 Normally Open Pin
RPI gpio 24 pin 18 to Switch 2 Normally Open Pin
RPI GND pin 20 to Switch 1-4 Common Pin
RPI gpio 25 pin 22 to Switch 1 Normally Open Pin
RPI gpio 8 pin 24 to Switch 1 Normally Open Pin
To Do:
- Generate Schematic
Stretch Goals:
- Create complete RPI control solution in a box/1U rack shelf
- AC Plugs with individual power control via RPI and Relay Board
- Network connectivity via RPI Ethernet/Wifi
- USB/Serial port connections to monitor device console ports during power on
- USB/Etehrnet ports for additional ethernet conenctivity for remote port mirroring/capture or routing
- Additional USB hub to expand USB port connections
- Power supply tha can power the RPI, Relays and USB Hub
- Safe Power down switch for RPI
- Cable Management
Extra Strech Goal
- Remote KVM for computers connected to the Relays