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)
my_url = ""
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

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


1 Answer 1


The connections you are making seem fine, so it should work.

I would double check the wiring, perhaps a loose wire.

pigpio only uses gpio numbers. gpio18 is on pin 12 which is indeed the sixth pin on the right (2=5V, 4=5V, 6=GND, 8=gpio14 TXD, 10=gpio15 RXD, 12=gpio18). You can put the DHT22 on any spare gpio but gpio18 is as good as any.

  • I have taken the liberty to include stuff from your earlier comments. Feel free to edit. Thanks bzw.
    – Ghanima
    Nov 9, 2018 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.