[Solved] GPIO Pins Defaulting to High State
After an update to the raspberry Pi 4 last week using sudo apt update then upgrade, my system is exhibiting two strange behaviors. For clarity I'll describe one here and the other in a second post. Now the GPIO pin 17 is registering high (boolean true) no mater if 3.3v or 0v is sent to the pin. Before the problem started GPIO 17 would show 0 on the graph when no voltage was sent to pin 17; and it would show 1 when 3.3v was sent to the pin.
Today the voltages were tested to verify 3.3v when the water valve is open and 0v being sent when the water valve is closed. This has worked for many months. Now for some reason GPIO17 always shows 1 no matter if 0v or 3.3v is sent to the pin.
Any ideas are appreciated.
Does your circuit limit the current being sunk into your GPIO pin so as to not exceed its capacity? What you describe is indicative of damaged hardware.
The water valve is a 12v circuit. To monitor the circuit on/off state the 12v line is connected to the Raspberry Pi via a voltage regulator and resistor that steps the power down to 3.3v. The 3.3v line is connected to GPIO 17. The voltage was tested yesterday. Manually moving the water sensor out of the tank to simulate a low water condition caused the voltage to go from near 0 (it was a very small micro volt value) to 3.3v. The water valve opened. Moving the sensor back into the water caused the voltage to drop back to 0 and the valve closed. However the raspberry gpio state for pin 17 remained high.
I’ll replace the raspberry pi 4 with a new one on Monday and retest. Thanks for the suggestion.
But what is the actual circuit (with resistor values)? What you describe doesn't indicate how much current is being sunk. Replacing the Pi may not solve the issue, but merely damage another Pi. Alternatively, you can just change to a different pin, however determining if the circuit is safe for the pin should be done before switching pins.
Thanks for double checking this diagram for me. The attached file is a simple schematic of the water level circuit. The following is a description of the water flow logic.
1. There is a 12v 5ma power supply that powers the water level circuit.
2. The 12v is connected to GEYA GRL8-01 relay and to a L7805 Voltage Regulator.
3. The L7805 reduces the voltage to 5.5v for two water sensors (indicated by not shown on the drawing). These two identical sensors are connected to the Min and Max ports on the GRL8 as indicated in the drawing. When the water level drops below the min sensor, the GRL8 relay closes the connection between ports 11 and 12 thus passing 12 volts to port 12. After the water level reaches the high sensor, the connection is opened and port 12 no longer has measurable voltage.
4. Low water logic continued: When port 12 on the GRL8 is closed with port 11, the 12 volts is passed to an LD1117v33 voltage regulator. This regulator reduces the voltage to 3.3v and has a 410k olm resistor connected between the 3.3 line and ground.
5. The 3.3v line is connected to the Raspberry Pi GPIO 17. A Mycodo chart is setup to track GPIO17 state so we can see how often and how long the water valve stays open. It has worked well for a number of months.
What you describe doesn't indicate how much current is being sunk.
I mistakenly was thinking of GPIOs as outputs, not inputs. As an input, It doesn't seem likely that your circuit would damage the pin.
With that being said, have you tried flashing Raspberry Pi OS to a new SD card and checking if your pin 17 can measure high/low states? If it can't, then you've confirmed the pin has died. If that's the case, I'm not sure what caused it, but you can either try using another pin, or take your schematic to someone more knowledgeable to try to find an issue with it.
I connected with a few engineers from Raspberry Pi org. They had me test the GPIO pins using a 1k resistor between ground and GPIO 17 and again to GPIO 27. GPIO 27 changed from high to low once the resistor connected the pin to ground. However it had no effect on GPIO 17. Thus they concluded that GPIO 17 has been damaged. They looked at my circuit and provided a possible explanation on what may have caused the failure. They said that having the 3.3v line from the 12v to 3.3v LD1117V33 Voltage Regulator; and having the 3.3v leg of the resistor directly connected to GPIO 17 most likely caused the failure.
They explained that when the 12V water valve is opened and that same 12v powers the LD117v33, a brief voltage spike on the 3.3v line can occur. Some suggested capacitors and others suggested flyback diodes. Since the timing of the 12v activation isn't time critical on the MS scale, I've decided to add a 12v relay that will switch a 3.3v line from the RP4 to a GPIO input pin. That will completely isolate the RP4 from any potential power spikes on the water level circuit.
Other than this problem, the water level circuit continues to work really well! No more stuck float issues. Plus this design allow the designer to decide the distance between high and low water marks, rather than the small level allowance on a float only design.
I'll close this issue for now. Thanks again for your help.
Nice investigation but sad to hear about your pin. Though, it's nice to know you've found the issue rather than just switching pins and waiting to see if it happens again.