HELP! , Relay module always on
Posted: Wed Jan 10, 2018 5:35 pm
To test a Relay Module SRD-5VDC -SL-C with my Raspberry Pi3 , I run this litte script just to test, but from the beginning the relay stay activated and do not stop until I clean the GPIO.. Can someone give me a solution to this , My goal is to us a relay to run a heater when a temperature sensor give a determinate reading, so I need to put On and OFF the relay in function of the remperature read.
VCC pin in conected to GPIO 5v (4 on board)
Gnd to GROUND (9 on board
and In1 to pin 17 (11 on board)
Thanks in advance.
VCC pin in conected to GPIO 5v (4 on board)
Gnd to GROUND (9 on board
and In1 to pin 17 (11 on board)
Thanks in advance.
Code: Select all
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
RelayPin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(RelayPin, GPIO.OUT)
GPIO.output(RelayPin, GPIO.HIGH)
print " starting on 5 seconds"
time.sleep(5)
print '...relay on'
GPIO.output(RelayPin, GPIO.LOW)
time.sleep(10)
print '...relay off'
GPIO.output(RelayPin, GPIO.HIGH)
time.sleep(10)
GPIO.cleanup()