Raspberry Pi Relay

From ElectroDragon Wiki
(Redirected from RPI relay shield)

How to use

  • Make sure your RPI has IIC installed, see RPI_Hardware IIC section
  • Plug the board on RPI 26P connector directly
  • Test the board by running following command: for MCP23008, default IIC address is 0x20, you can see the image on RPI page.
sudo i2cdetect -y 1
  • Copy code: Make a new py file, paste the following code and chmod it for excute right
nano relay.py
chmod +x relay.py
  • If the demo code can not run properly, change the line value 5,8 to 1,4 at "for x in range(5,8):"
  • Relay and relevant LEDs will on and off in turns when running this demo code


Schematic

RPI relay shield.png
  • See shematic on the right

Jumpers and Toggle switch

  • Left jumper to select VCC on either 5V or 3v3, please keep it at 5V for relay use.
  • Right jumper for CD pins of ULN2803, keep it on as default.
  • Toggle switch from top to bottom are A2, A1, A0 and NC.