I have attached a DHT-22 weather sensor to my rev 1 raspberry pi after a fresh install of a recent install of debian.
Following the instructions from https://www.youtube.com/watch?v=IHTnU1T8ETk I installed the pipgio and got this to work using sudo python.
import os
import pigpio
pi = pigpio.pi()
import DHT22
s = DHT22.sensor(pi, 4)
s.trigger()
print('{:3.2f}'.format(s.humidity() / 1.)) => 48.60
print('{:3.2f}'.format(s.temperature() / 1.)) => 27.50
Great! What I expected. This code when I put in a file called mypio.py in the same folder as PIGPIO I get this response:
-999.00
-999.00
I'm sure it's my not understanding what python is doing but surely I would have found a post on Google about it. I'm unsure which github repo has the canonical version of this library, but no fruitful yield of my searches yet. Help me understand the difference between running it in the python console and the file itself, thx, sam