Multiple DHT Pro sensors are unstable[SOLVED]

Hi,
I have purchased 5 temp and humid pro sensors, and connect to GrovePI+(firmware 1.2.7) with Pi B+.

I tried example code with 1 dht pro sensor, I got correct temp and humid values. But 2 or more sensors were connected to, I got strange situations.

I connected sensors to D2,D3,D4,D7,D8, then I made python code based on example like

[ temp,hum ] = grovepi.dht(2,1)
print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))
time.sleep(1)

[ temp,hum ] = grovepi.dht(3,1)
print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))
time.sleep(1)

[ temp,hum ] = grovepi.dht(4,1)
print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))
time.sleep(1)
.
.
.

I couldn’t get values or same value from different sensors. Sometimes I got right values, sometime I got “nan” from same port sensor.

Then, I tried to read values whether sensors were connected to or not. I found that there was a difference between the port number on the code and the port number on the board.

D2 = port 3
D3 = port 4
D4 = port 5
D5 = port 6
D6 = port 7
D7 = port 8
D8 = port 1

So, I have some questions
Q1) Can I connect mutiple DHT Pro sensors to 1 GrovePI+?
Q2) How can I fix the port no difference?
Q3) How can I get the values more stable?

I’m not python guy and I’m not good English speaker. So I will explain in more detail if necessary.
I would appreciate it if you could help.
Taichi

@taichi.nishioka,
We have never used 5 of the DHT sensors before but we have used 2-3 and they have worked. I also wanted to double check that you are using the white DHT sensors and not the blue ones.

I found that there was a difference between the port number on the code and the port number on the board.

Can you explain a bit more about this. The ports are daisy chained. So port D2 has D2,D3 pins, port D3 has D3,D4 pins and so on. The DHT sensor only used one of the two data lines (the yellow wire on the sensor), so you should be able to connect as many as you want.

However, for the sake of experimenting, what happens if you connect 2 DHT sensors to port D2 and D4 and issue reads like

[ temp,hum ] = grovepi.dht(2,1)
[ temp,hum ] = grovepi.dht(4,1)

can you post the screenshot of the output that you get.

Hi karan,

Yes, I bought 5 WHITE dht sensors.

I made test code. grove_dht_test.py (455 Bytes)
I connected dht sensor to D2 and D4 port then ran this code, And I’ve got the following output.

Port#1 - Fail
Port#2 - Fail
Port#3 : temp = 22.80 C humidity =28.20%
Port#4 - Fail
Port#5 : temp = 32.40 C humidity =16.10%
Port#6 - Fail
Port#7 - Fail
Port#8 - Fail
---
Port#1 - Fail
Port#2 - Fail
Port#3 : temp = 23.70 C humidity =28.30%
Port#4 - Fail
Port#5 : temp = 32.50 C humidity =16.80%
Port#6 - Fail
Port#7 - Fail
Port#8 - Fail
---

I’ve got values from port 3 and 5. If my code is correct, the port numbers doesn’t match.

And according to karan’s request, I got a value with a simple code. Sensors connection is same as above.

pi@dex:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grovepi
>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
22.9
>>>
>>> [temp,humidity] = grovepi.dht(3,1)
>>> print temp
32.5
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
22.8
>>> [temp,humidity] = grovepi.dht(3,1)
>>> print temp
32.4
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan
>>>
pi@dex:~ $

I got values from port 3 and 4 in this case.

It’s a bit confusing because of the result…

How can I fix the port and stable to get values from 5 sensors?

@taichi.nishioka: Can you post a picture of your current setup. Can you also check each of the sensors individually and check which pin is marked with SIG. Example below:

@karan: Please find these pictures.

  1. Boards
    <img src="/uploads/default/original/1X/03572d1cd006b705038395088bf2e6ce70283048.JPG" width="300 height=“200”>
    Isolated with masking tape between PiB+ and GrovePI+.


GPIO pins could be a right position.

  1. Connections

    DHT Pro sensors are connected D2,D3,D4,D7,D8
    D3 and D7 : with 50cm Grove cable.


D2,D4 and D8 are relaying with RJ45 adapter and 2m or 3m CAT6 UTP cables.

This Pi B+ is powered by 5V 2A adapter.

My all dht sensors are marked SIG as same as your picture.

@taichi.nishioka,
I am not really sure what the problem is. Are you using the RJ45 extenders for the 2 sensor test above too, or was that directly connected to port D2 and port D4. Can you post a picture of the setup that you had used in that test.

@karan ,
Thank you for your reply,
Here is the picture that I’ve test on today.

2 sensors are directory connected to D2 and D4 with GroveCable that was in DHT Pro package.

And I ran test programs again and got results.

pi@dex:~ $ python grove_dht_test.py
Port#1 - Fail
Port#2 - Fail
Port#3 : temp = 22.40 C humidity =30.50%
Port#4 - Fail
Port#5 : temp = 22.70 C humidity =27.20%
Port#6 - Fail
Port#7 - Fail
Port#8 - Fail
---
Port#1 - Fail
Port#2 - Fail
Port#3 : temp = 23.50 C humidity =28.10%
Port#4 - Fail
Port#5 : temp = 23.50 C humidity =24.50%
Port#6 - Fail
Port#7 - Fail
Port#8 - Fail
---

And I tried the test via python command line.

pi@dex:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grovepi
>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
23.5
>>>
>>>
>>> [temp,humidity] = grovepi.dht(3,1)
>>> print temp
23.4
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan
>>>

From these result, I didn’t get the result I expected.

But after running the command several times, I found regularity.
I read values from same sensor several times continually. Here are results,

>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
23.2
>>> [temp,humidity] = grovepi.dht(2,1)
>>> print temp
23.1

or

>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
23.1
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
23.2
>>> [temp,humidity] = grovepi.dht(4,1)
>>> print temp
23.3

or

>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
23.3
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan
>>> [temp,humidity] = grovepi.dht(5,1)
>>> print temp
nan

I found that the value is different between the first run and later.

Maybe, There is a problem reading a value first time from a sensor or there is some necessary steps before read a value.

At this moment, I will try modifying my program to discard the first value.

If you find any problems or tips on using more than 4 sensors, please let me know.

Hi @karan,

As a result of above modify, I got values seem to be correct.

Update my test program grove_dht_test.py (526 Bytes) and I got values from 5 sensors successfully. Sensors were connected to D2,D3,D4,D7 and D8.

pi@dex:~ $ python grove_dht_test.py
Port#1 - Fail
Port#2 : temp = 22.60 C humidity =29.80%
Port#3 : temp = 23.50 C humidity =29.60%
Port#4 : temp = 31.10 C humidity =29.40%
Port#5 - Fail
Port#6 - Fail
Port#7 : temp = 22.30 C humidity =28.10%
Port#8 : temp = 34.40 C humidity =15.00%
---
Port#1 - Fail
Port#2 : temp = 22.30 C humidity =27.60%
Port#3 : temp = 23.50 C humidity =27.50%
Port#4 : temp = 31.00 C humidity =28.10%
Port#5 - Fail
Port#6 - Fail
Port#7 : temp = 21.40 C humidity =28.10%
Port#8 : temp = 34.40 C humidity =14.20%
---

I can now acquire the sensor value of the D2 port by specifying the port 2 by my program. Also I can get the values with RJ45 adapters. My problems were totally solved.

Thank you very much for your comments and for responding to my poor English.

Taichi.

@taichi.nishioka,
Great to hear that the problem were resolved. We were going to test this at our end. Can you describe a little more about how did you solve the problem. I wasn;t able to spot the difference in the program.

Also, we have not seen the RJ45 cables being used so just wanted to ask how the sensor is performing with it and how long of a cable are you using with the sensor.

Thanks again, @karan,

Finally I can monitor my server room temperature and humidity by this sensors!

The difference is add “grovepi.dht” func. and “time.sleep(1)” func, to just before original “grovepi.dht” func.

while True:
    for i in range(1,9):
        [temp,humidity] = grovepi.dht(i,white)   # Here
        time.sleep(1)  # Here
        [temp,humidity] = grovepi.dht(i,white)
        if math.isnan(temp) == False and math.isnan(humidity) == False:
            print("Port#%d : temp = %.02f C humidity =%.02f%%"%(i, temp, humidity))

In my case, just extend the length.

And I used 2m and 3m CAT6 cables. Detail connections are follows

  1. D2 -> 5cm GroveCable -> RJ45 Adapter -> 3m CAT6 -> RJ45 Adapter -> 5cm GroveCable -> DHT Pro sensor
  2. D3 -> 50cm GroveCable -> DHT Pro sensor
  3. D4 -> 5cm GroveCable -> RJ45 Adapter -> 2m CAT6 -> RJ45 Adapter -> 5cm GroveCable -> DHT Pro sensor
  4. D7 -> 50cm GroveCable -> DHT Pro sensor
  5. D8 -> 5cm GroveCable -> RJ45 Adapter -> 2m CAT6 -> RJ45 Adapter -> 5cm GroveCable -> DHT Pro sensor

My system gets values every 5 min .All sensors are working fine now.

I hope it will be helpful.

Thanks again, Taichi.

Hi @taichi.nishioka,

Thanks a lot for sharing the information, it will be helpful for us to try out. Glad it is working for you.

-Shoban

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