Hi There,
I am having issues reading analog voltages on the Automation Phat.
Here is the python script I am using which a one shot cut down of your input.py The aim is to read the analog input once as part of another implementation. however this script returns only value’s of zero.
#!/usr/bin/env python
import time
import automationhat
print(automationhat.analog.read())
Returned example print,
pi@Levelcrossingmon_test:~/Pimoroni/automationhat/examples $ ./oneread.py
{‘three’: 0.0, ‘two’: 0.0, ‘one’: 0.0}
The python script used by your example python script, input.py returns zero value for the first read of the analog inputs. Then after that the second or more reads by the script works fine. I suspect the library scripts has a bug preventing it reading the analog input on the first pass
pi@Levelcrossingmon_test:~/Pimoroni/automationhat/examples $ ./input.py
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.0, ‘two’: 0.0, ‘one’: 0.0} <----- First Read comes back with a zero value read
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.03, ‘two’: 0.03, ‘one’: 5.19} <------ second and more reads comes back correct values
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.03, ‘two’: 0.03, ‘one’: 5.19}
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.03, ‘two’: 0.03, ‘one’: 5.19}
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.03, ‘two’: 0.03, ‘one’: 5.2}
{‘three’: 1, ‘two’: 1, ‘one’: 1}
{‘three’: 0.03, ‘two’: 0.03, ‘one’: 5.19}
^CTraceback (most recent call last):
File “./input.py”, line 14, in
time.sleep(0.5)
KeyboardInterrupt
The phat script version is 0.0.2
Can you please have a look at this, Thanks