DHT is not working[SOLVED]


#1

Hi!

I’ve just bought my grovepi kit, I was doing the begginer projects and the dht is not working.

I have tried with each digital port, and still…

It throws me -1 as return in each value.

May the sensor be broken?

I am using: [temp,hum] = grovepi.dht(7,0)

Thank you!


#2

Hi Bruno!

Do you use the DHT from your kit? As in the blue colored sensor.

Your sensor should be fine. It has to do with the code.
Connect your sensor to digital port 4 and use the next following lines of code.
After you’ve done this, please tell me what’s being displayed.

import grovepi
import math
import time
# 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))
        else:
            print("nan values")
        time.sleep(0.5)

    except IOError:
        print ("Error")

Thank you!


#3

Now it works perfectly with your code!

Thank you!!


#4

Hi Bruno!

It would be great if you can tell us what solved the problem.
It might help other people having the same problem as yours.

Thank you!


#5

This topic was automatically closed after 2 days. New replies are no longer allowed.