Back again,
The above tests were done using an RPi4B device where I used GPIO18 on pin 12 on the header and it worked just fine.
So I removed the circuitry from the RPi4B and attached it to the RPiZeroW in the room where the light sensing will be part of the PiZero's tasks.
The connections are very simple:
3.3V from pin #1
0V from pin #6
Resistor-capacitor circuit to GPIO18 (pin #12)
And here it does NOT work at all.
The code gets stuck in the loop waiting for the voltage to rise above the 1 level.
Here is the actual code modified but essentially the same as proposed and working in the study on an RPi4B:
What is the problem?
Is there a difference in access to the pins between RPi4B and RPiZeroW.
Or a difference in the header pinout?
Or is GPIO18 blocked for some reason on an RPiZeroW?
The above tests were done using an RPi4B device where I used GPIO18 on pin 12 on the header and it worked just fine.
So I removed the circuitry from the RPi4B and attached it to the RPiZeroW in the room where the light sensing will be part of the PiZero's tasks.
The connections are very simple:
3.3V from pin #1
0V from pin #6
Resistor-capacitor circuit to GPIO18 (pin #12)
And here it does NOT work at all.
The code gets stuck in the loop waiting for the voltage to rise above the 1 level.
Here is the actual code modified but essentially the same as proposed and working in the study on an RPi4B:
Code:
import RPi.GPIO as GPIOimport sysimport timeGPIO.setmode(GPIO.BCM)GPIO.setwarnings(False)resistorPin = 18TIMEOUT = 3.0sum = 0cnt = 0REPEAT = 1for sequence in range(REPEAT+1): GPIO.setup(resistorPin, GPIO.OUT) GPIO.output(resistorPin, GPIO.LOW) time.sleep(0.04) # discharge time GPIO.setup(resistorPin, GPIO.IN) currentTime = time.time() diff = 0 while(GPIO.input(resistorPin) == GPIO.LOW): diff = time.time() - currentTime if diff > TIMEOUT: print("9999") GPIO.cleanup() sys.exit(1) #ignore first measurement if sequence > 0: sum += diff cnt += 1# print average time in millis, no decimalsprint( int(sum / cnt * 1000))GPIO.cleanup()sys.exit(0)
Is there a difference in access to the pins between RPi4B and RPiZeroW.
Or a difference in the header pinout?
Or is GPIO18 blocked for some reason on an RPiZeroW?
Statistics: Posted by Bosse_B — Wed Dec 11, 2024 6:13 pm