0

This 3.3v .relay, link to the the >>> Datasheet

As the title mentions works fine until I try to switch it off the second time round, I see the red LED turning on (it looks a touch dim)

Tapping the relay housing(lightly) triggers the relay Stuck relay then!

But why only after the second attempt and never on the first power off ?

EDIT: I looked at the datasheet thinking it needs a bit more voltage, but max is 3.9v!

import RPi.GPIO as GPIO
#from time import sleep
pin =2
# Set up input pin
# set bcm pin mode 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.OUT)
#  turn on relay in revese mode so sety pin to low
state = GPIO.input(pin)
if state:
 print('on')
 GPIO.output(pin, GPIO.LOW) 
else:
 print('off')
 GPIO.output(pin, GPIO.HIGH) 
5
  • 1
    Try a different GPIO. GPIO 2 and 3 have hard-wired pull-ups to 3V3.
    – joan
    Feb 18, 2021 at 18:41
  • @joan, good idea I shall try that in a mo n reply back
    – fuzzybear
    Feb 18, 2021 at 19:25
  • This code doesn't make much sense. "Set up input pin…GPIO.setup(pin, GPIO.OUT)"
    – Milliways
    Feb 18, 2021 at 23:30
  • @joan, thanks for the suggestion same issue
    – fuzzybear
    Feb 19, 2021 at 0:04
  • Hi @Milliways care to elaborate?
    – fuzzybear
    Feb 19, 2021 at 0:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.