I have a small hobby motor (5v) mounted with a hobby fan that is connected to Normally Open on the Relay (pic) and 5V Wall Power supply (via a barrel/terminal block adapter.)
On the input side, the relay connections are:
- VCC to Pi Pico 3.3V/pin 36
- GND to GND
- input pin to GPIO 15
Everything works well with this code:
import time
time.sleep(2)
import machine
from machine import Pin
#pi pico
#led = Pin(25, Pin.OUT)
#pi pico w
led = machine.Pin("LED", machine.Pin.OUT)
print('sleep before turn off led')
time.sleep(2)
led.off()
print('sleep before turn on led')
time.sleep(2)
led.on()
from machine import Pin
relay = Pin(15, Pin.OUT)
relay_sleep=5
count=0
while True:
print('sleep before turn on relay')
time.sleep(relay_sleep)
relay.value(0)
print('sleep before turn off led')
time.sleep(relay_sleep)
relay.value(1)
count+=1
print(count)
But if I make one change and put the relay connected to pin 40 (5 volts out) instead of pin 36 on the pico, the fan turns on but it never turns off. The relay does not appear to even try to change (multi-meter confirms no voltage change).
Is this expected?
EDIT:
- Replacing the 5V relay with a 3V relay and all is well.
- I also replaced the relay with a transistor a la https://github.com/jouellnyc/pico_thermostat, which is what I wanted in the first place (OLED/temp probe), but I tried it all out with the 5V relay first and got curious and followed this little rabbit hole ... :)