2

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

0

1 Answer 1

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.

1
  • I have taken the liberty to include stuff from your earlier comments. Feel free to edit. Thanks bzw.
    – Ghanima
    Commented 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.