Skip to content

RPI Shell Script to Control Relay Boards via RPI GPIO Pins

License

Notifications You must be signed in to change notification settings

Distant-One/RPIShellRelayControl

Repository files navigation

RPIShellRelayControl

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

2935-13



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-

71x5CobURnL AC_SX679

Quad relay wiring diagram is below: quadrelaywiring

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:

  1. Generate Schematic

Stretch Goals:

  1. Create complete RPI control solution in a box/1U rack shelf
  2. AC Plugs with individual power control via RPI and Relay Board
  3. Network connectivity via RPI Ethernet/Wifi
  4. USB/Serial port connections to monitor device console ports during power on
  5. USB/Etehrnet ports for additional ethernet conenctivity for remote port mirroring/capture or routing
  6. Additional USB hub to expand USB port connections
  7. Power supply tha can power the RPI, Relays and USB Hub
  8. Safe Power down switch for RPI
  9. Cable Management

Extra Strech Goal

  1. Remote KVM for computers connected to the Relays

About

RPI Shell Script to Control Relay Boards via RPI GPIO Pins

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published