[SOLVED] DHT Sensor responding -1

Hey,
I’ve been trying to get my DHT sensor working (the blue one with the starter kit). I’ve tried in both Java and Python and had no success, the values have returned -1. From research I have already done, I have made sure I am inputting the right value as to which sensor it is, and checked ports etc.
My LCD, however, does work fine. The values the DHT sensor recieves are also false with isnan, and throw no errors, but just return -1 as there values.

I would really like to get this working! Thanks, Scott

Hi Scott,

Let’s get this thing done.


Step 1

Can you confirm you’re using this python script?

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

If you got the GrovePi base kit, than you’d be using the blue sensor, so the script above is what you need.


Step 2

As you can see, in this example, we are using digital port 4, so you also have to match the port onto the GrovePi.


Step 3

It would be great if you could provide us with some logs. There are 2 options depending on which OS image you’re using:

  1. Raspbian for Robots
  2. Raspbian Jessie (what the Raspberry releases)

If you got the first the 1. option then things are simple.
You have to go onto the desktop, click the Test and Troubleshoot and choose Troubleshoot GrovePi. Next upload the log.txt on the forums and we’ll give it a look.

You can also follow our youtube tutorial here.


If you got the second 2. option then you have to go into Troubleshooting directory and run the all_test.sh shell script.

Use your terminal and cd into your cloned directory (of the repository of GrovePi) and run the following commands:

  1. cd Troubleshooting
  2. sudo chmod +x all_tests.sh
  3. sudo ./all_tests.sh

In the end, your log.txt file we’ll be generated on the Pi’s Desktop. Upload it here.


Additional stuff

Would be awesome if you can share with us a picture with the sensor connected to the GrovePi. This way, we can see if there’s something not ok.

1 Like

Thanks for your response! I have completed the tests you asked, and here are the results:-

  1. Yes, that is the script I am using, and to be sure I ran that one. Still the same error.
  2. I made 100% sure it was plugged into the D4 connection.
  3. Here is my log.txt file: log.txt (6.6 KB)
    4)And finally, here is my connection photo:

Hi Scott,


###I have a couple of questions:

  1. What image are you using: wheezy or jessie?

  2. Does the RST LED stays on all the time? If it’s this way, then the Raspberry cannot communicate.

  3. Have you run the sudo bash GrovePi/Script/install.sh


###And here are some suggestions:

  1. Run the firmware update without any sensors or HDMI connected to the Pi. So, open a terminal and follow this commands.:
cd Desktop/GrovePi/Firmware
sudo bash firmware_update.sh
  1. Then next, let’s reinstall the GrovePi dependencies (there might be something that’s still not set up). After you update the firmware, you’ll reboot it. So, open a terminal and follow this commands:
cd Desktop/GrovePi/Script
sudo bash install.sh
sudo reboot
  1. Run again your DTH sensor example.

  2. Go again to step 3 in my previous post and troubleshoot again, and post here the log.txt.


Thank you

Hey, sorry for the delayed response.

I am running Jessie, and I followed all your steps - updating firmware and making sure the packages/dependencies were installed. However, the problem still happens.

However, the RST light it constantly on - so there must be a communication error.

Hi Scott,

Can you install Raspbian For Robots and redo everything you have done till now?

Then tell us if it goes well or if not, please post here another log.

Thank you

Hi, I have the same problem (-1 -1 response from DHT). My setup has been running happily until a update/upgrade cycle yesterday. I have tried everything listed above (after a re-install). My setup has the blue DHT sensor in D7 but I have tried with it in D4 and after adjusting sensor port tried it in port D7. I imagine that the whole problem has been caused by something in the upgrade. Attached are the log file and a photo of the setup (with the dht in D7 and the LCD in i2c-1).

Peter
alltestlog.txt (6.2 KB)

Hi, Tried to install Raspbian for Robots - a very annoying process some people live in different countries and time zones and even use different keyboards. Went straight back to my old SD.
Peter

Hi, Problem solved by repeat install and firware update. Thank you for ideas.
Peter

Hi @peterr,

The problem was with the Firmware update, the logs show an improper firmware update, glad that you figured it out yourself.

-Shoban

This topic was automatically closed after 23 hours. New replies are no longer allowed.