import RPi.GPIO as GPIO import time def mist(): GPIO.setmode(GPIO.BCM) # setup and switing on relay GPIO.setup(4, GPIO.OUT, initial=GPIO.LOW) # sleep for 30 second time.sleep(30) # off relay GPIO.output(4, GPIO.HIGH) # clean up all GPIO.cleanup() if __name__ == "__main__": mist()
what I am trying to do that to on 4 channel relay module for 30 seconds.
Problems that I am facing
- Even if I set out put pin to
GPIO.HIGHit won't switch on. (I think my relay is ACTIVE LOW, so I set initial=GPIO.LOW for switching on)
- I set time.sleep for 30 seconds but relay switch off after 2 or 10 seconds
Why this happening, I am new to python and Rasberry pi
The problem was 1-Wire Interface option was switched on. GPIO4 is the default for 1-wire. If that is activated in /boot/config.txt it may interfere with other hardware connected to that pin
dirk pointed out the issue.