DHT11 Temp and Humidity Sensor Giving 0 Values

Hi,

When running the example code for the grove temp and hum sensor and raspberry pi, I only get zero values. At first I only got nans until I updated firmware, then started getting 0s. I’m using GrovePi+ with RaspberryPi 3.

I’ve tried different ports, changing the ‘blue’ to ‘white’ sensor in the code, and I am now at a loss. Also, when I simply unplug the sensor, I still get the same 0 values. I’m starting to think the sensor is faulty.

Any help is greatly appreciated! Here’s the code:

import grovepi
import math

Connect the Grove Temperature & Humidity Sensor Pro to digital port D4

This example uses the blue colored sensor.

SIG,NC,VCC,GND

sensor = 4 # The Sensor goes on digital port 4.

temp_humidity_sensor_type

Grove Base Kit comes with the blue sensor.

blue = 0 # The Blue colored sensor.
white = 1 # The White colored sensor.

while True:
try:
# This example uses the blue colored sensor.
# The first parameter is the port, the second parameter is the type of sensor.
[temp,humidity] = grovepi.dht(sensor,blue)
if math.isnan(temp) == False and math.isnan(humidity) == False:
print(“temp = %.02f C humidity =%.02f%%”%(temp, humidity))

except IOError:
    print ("Error")

Update: tried the code again today and now getting nan for both temp and hum.

This is a known issue. The Grove Library for the DHT11 is broken. I recommend using Adafruit’s DHT11 Library which works fine.