I am trying to use my Raspberry Pi Zero W for an IoT project. I want to read the temperature of a room. I have the DHT22 sensor (the blue 3 pin one that has the resistors soldered onto the pcb).
I have been using the example code and its "working," but the accuracy is way off. I have an arduino to compare it to and its accurate, so the sensor is fine (I'm literally just replacing it on the breadboard). Pinout wise, I have G connected to pin 39 (ground), V connected to pin 1 or 2 (3.3 or 5, theres not difference), and S to pin 11 (GPIO17)
import Adafruit_DHT
import time
import board
DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 17
while True:
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
print("Temp is "+ str(temperature))
temp = temperature(9/5)+32
print("Temp oF is " + str(temp))
if humidity is not None and temperature is not None:
print("Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature,humidity))
else:
print("Failed to retrieve data from humidity sensor")
The output looks like this. The value should be ~80 oF
Any idea what could be causing such a wild inaccurate reading? I tried searching for any similar topics, but seems like I'm the rare case where its working but off by a giant magnitude (compared to off by a little).
Any help would be appreciated! Thanks!