The example below is only one way how to set up the Relay Module.
In this examples we have connected a PICO to the BEVRLink Manager PICO V2 with BEVRLink 8 Channel Relay V1 12V. With this relay module board you need the BEVRLink Power Supply 12V 2A.
Optional for a safe setup we recommend to use case for both the manager and relay boards: BEVRLink Cases
Set up CircuitPython
- Download latest CircuitPython Firmware
- Hold BOOTSEL while plugging the PICO in to your PC
- A USB Drive called RPI-RP2 should appear on your computer
- Drag and drop the downloaded UF2 to the Drive
- The board will automatically flash it self and reboot removing the drive
- You will get a new USB Drive attached called CIRCUITPY that will hold your code and files
- First download the library for MCP23008
- Unzip and copy the folder adafruit_mcp230xx to the lib folder on the PICO
- Write the code in a code.py file
import time import board import busio import digitalio from adafruit_mcp230xx.mcp23008 import MCP23008 # Initialize the I2C bus: i2cbus = busio.I2C(scl=board.GP1, sda=board.GP0) # Create an instance of either the MCP23008 or MCP23017 class depending on # which chip you're using: r1 = MCP23008(i2cbus, 0x20) # Address of relay card 1 r2 = MCP23008(i2cbus, 0x21) # Address of relay expansion card # Make a list of all the pins r1_pins =  for pin in range(0, 8): r1_pins.append(r1.get_pin(pin)) r2_pins =  for pin in range(0, 8): r2_pins.append(r2.get_pin(pin)) # Set all the pins to output for pin in r1_pins: pin.direction = digitalio.Direction.OUTPUT for pin in r2_pins: pin.direction = digitalio.Direction.OUTPUT while True: # Loop # Turn on each relay for one second for pin in r1_pins: pin.value = True # turn LED on! time.sleep(1) # wait 0.1 seconds pin.value = False # turn LED off time.sleep(1) # wait 0.1 seconds for pin in r2_pins: pin.value = True # turn LED on! time.sleep(1) # wait 0.1 seconds pin.value = False # turn LED off time.sleep(1) # wait 0.1 seconds
Copy the code file code.py to the USB drive CIRCUITPY.
The code should autorun as soon as it saved on the drive, otherwise open a serial connection to the Pico shell and check for errors