Page 1 of 1

GPIO pin turns on, then auto turns off

Posted: Fri Oct 04, 2019 9:22 pm
by mattg31
I am trying to troubleshoot an issue with a GPIO pin turning off automatically. Any advice would be greatly appreciated.

I have GPIO pin 4 connected to a relay: https://www.digikey.ca/products/en?keyw ... 11042-5-ND

My code is:

Code: Select all

	import RPi.GPIO as GPIO
	
	GPIO.setmode(GPIO.BCM)
	GPIO.setwarnings(False)
	GPIO.setup(4,GPIO.OUT)
	GPIO.output(4,GPIO.HIGH)
When I run this, I can hear the relay click on, then in about 1 or 2 seconds it clicks off. I put a voltmeter to confirm that it does in fact go high, then goes low automatically. Is it possible it is being overloaded or something?
Wiring diagram here: https://imgur.com/HOTH5Qq

Re: GPIO pin turns on, then auto turns off

Posted: Fri Oct 04, 2019 9:25 pm
by joan
Most likely reason is you have a 1-wire bus running on GPIO4.

Check in /boot/config.txt.

Re: GPIO pin turns on, then auto turns off

Posted: Fri Oct 04, 2019 9:32 pm
by mattg31
Most likely reason is you have a 1-wire bus running on GPIO4.
Ahh @joan you are amazing. Thank you! I would not have found that on my own...

Re: GPIO pin turns on, then auto turns off

Posted: Fri Oct 04, 2019 10:07 pm
by Andyroo
You may find this site handy https://pinout.xyz/

As well as having a handy graphic you can print it shows what pins are used for each interface and what actual pins are used by each board. The latter is handy if the HAT covers all the pins but you feel up to soldering to the back of the Pi board for a connection not used by the HAT.