I have just upgraded my pi 2 b to a 3. The ldr system with a capacitor (like this one)...
... worked flawlessly on the b+, but on the new 3 it only gives a result 1 out of 2-6 times. So I get a result, for instance 55, then one to 5 times I get 1, then I get a result again, and so on. It looks like a pattern but I can't figure out what causes it.
For example: 55,1,1,56,1,1,1,43,1,1,1,47...
It seems somehow the capacitor is being drained way too fast during the false readouts, as my multimeter shows it raises to 3.3 volts and then drops again every cycle.
I have tried everything I can think of,
-different gpio port
-checked the ldr, works fine
-Longer sleeps between measurements
-Longer capacitor charge time
this is the test code I use.:
Is there a solution to this problem?
Code: Select all
#!/usr/bin/python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) def rc_time (pin_to_circuit): cap=10000000 count = 0 GPIO.setup(pin_to_circuit, GPIO.OUT) GPIO.output(pin_to_circuit, GPIO.HIGH) time.sleep(1) GPIO.setup(pin_to_circuit, GPIO.IN) state=GPIO.input(pin_to_circuit) count=0 while (state == GPIO.HIGH) and (count < cap) count += 1 print count time.sleep(.02) state=GPIO.input(pin_to_circuit) return count try: while 1: x= rc_time(17) print str(x) time.sleep(1)