Hi, I’m trying to use a PIR motion sensor to control a 12V solenoid valve.
Prototype equipment:
Raspberry Pi Pico W
Dual Channel Relay Pico HAT
Pico Quad Expander Board
PIR Motion Sensor Module
DC 12V power supply
Code:
from machine import Pin
import utime
relay1 = Pin(6, Pin.OUT)
while True:
relay1(1)
print("Relay on")
utime.sleep(3)
relay1(0)
print("Relay off")
utime.sleep(3)
The code runs as expected without the power source connected to the relay hat (without controlling the actual Solenoid). It fails when connecting the 12V power source. This seems to happen when it’s attempting to turn the relay back on.
Output
MPY: soft reboot
Relay on
Relay off
PROBLEM IN THONNY'S BACK-END: Exception while handling 'Run' (ConnectionError: read failed: [Errno 6] Device not configured).
See Thonny's backend.log for more info.
You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.
Process ended with exit code 1.
Unable to connect to /dev/cu.usbmodem2101: [Errno 2] could not open port /dev/cu.usbmodem2101: [Errno 2] No such file or directory: '/dev/cu.usbmodem2101'
Process ended with exit code 1.
Everything works as expected without the Pico Quad Expander Board (using jumper cables). I’ve tried another Pico Quad Expander Board thinking it could be the issue as the first one arrived falling out of the box. Unfortunately, they both have the exact same issue.
Any help is appreciated.