Thanks to this forum, I was able to successfully use the PIGPIO library to get my DHT22 sensor to work. My next requirement is to attach an RTC chip and it seems to use pin 4, which works for my PIGPIO. Reading around, the DHT22 can use pin 18, which on my rev 1 pi, is six pins from the right edge, away from the 5v pins.
I've modified the code to reflect pin 18 but my output is -999.00 which is similar to my previous problem. But a simple pin change should work, it seems. I have restarted the pigpiod program, reattached to pin 4 to ensure the DHT22 still works and looked on Google in the library to see if pin 18 has something special going on. Here is my code:
import os, requests, json, pigpio, time
pi = pigpio.pi()
import DHT22
s = DHT22.sensor(pi, 18)
s.trigger()
time.sleep(0.2)
my_url = "http://192.168.0.155:4567/record"
data = json.dumps({"content": "json from pi", "temperature": "%(temp)s", "humidity": "%(humid)s"}) % {"humid" : '{:3.2f}'.format(s.humidity() / 1.), "temp" : '{:3.2f}'.format(s.temperature() / 1.)}
req = requests.post(my_url, data)
print req.json
s.cancel()
Move my connection back to pin 4 and changing the index to 4 works, but pin 18 does not. What am I overlooking? thx, sam