Grove- Temperature and Humidity Sensor - Nan Value

The latest firmware is 1.1 as seen on the Github repo.

If you want to make sure you are running the most recent firmware, you could always flash the Github firmware onto your device.

If it was already running 1.1 and you flash 1.1 there will be no change, but if your device had older firmware, you can be confident now that it is up to date and the problems you are experiencing are unrelated.

Hi,
Thanks for the reply. Is there any way I can find out if the sensors are getting recognized by the board or they are not faulty? I will try to upgrade the firmware when I get a chance to solder the pins.

Cheers,
Khattak

Hi,
There is no easy way to find out whether the DHT sensor is working or not other than to read it from the GrovePi. Do let us know if it works for you.

-Karan

Hi again,
Thanks for the reply.
One rather silly question, I have a lot of sensors (mostly analog) but only 3 analog ports. Is there anyway I can connect more than 3 analog sensors at the same time?
Cheers,
Fida

If you want more analog ports, you could use a MCP23008 or MCP23017.

They are breadboard ICs which give you 8 or 16 additional 16-bit input/output ports and an I2C or serial interface. They are also chainable, so you can run a bunch of them on your I2C bus.

http://tronixlabs.com/components/ics/io-expander/mcp23008-i2c-8-input-output-port-expander/

http://tronixlabs.com/components/ics/io-expander/microchip-mcp23017-16-bit-i2c-port-expander-ic/

A tutorial on how to use them:

Hi Fida,
If you want to stick with Grove, then there is this module http://www.seeedstudio.com/depot/Grove-I2C-ADC-p-1580.html?cPath=98_16 . We don’t have a library for it as of now but it looks pretty easy to make it work with Python on the Raspberry Pi.

-Karan

Hi again,

So updating the firmware did the trick, now I can read from the dht pro sensor. Some observations and questions though.

1. Convergence to temperature: It seems that the dht pro takes lot longer than the analog sensor to converge to temperature values if there is a sudden change in temperature. (outside +3 to room temperature). There is a slight difference (.5 C) between both sensor readings but that I presume is ok.
2. dht humidity value: It seems to be stuck at 25.6, I changed the location of the sensor to outside and it still reads the same value as in the room. The outside humidity shown by local forecast is 75%.
3. Version of dht sensor: There seems to be at least 3 dht sensors, as seen in seedstudio code for arduino. However, there is no selection choice in the python script for Grovepi. How do we go about that? Also how do we figure out which particular sensor are we running as the packaging of the sensor has nothing printed on it.
4. Any external libraries?: As far as I can see, the dht function is reading and writing through i2c_block functions. Are there any external libraries that are being used by the grovepi?

Cheers,
Khattak

Hi,
If you want to stick to the Grove Platform, then there is an I2C ADC available http://www.seeedstudio.com/depot/Grove-I2C-ADC-p-1580.html .

We don’t have code for this yet but it is compatible with Grove Pi and should be easy to get it to work with the GrovePi.

-Karan

Hi Karan,
Thanks for all the help. I am wondering how using an ADC will help with humidity reading of dht pro sensor? The reason for using grovepi is that I also need to run a delay tolerant stack on the Raspberry Pi and grovepi gives a clean interface between the sensors and the RaspberryPi.

Any idea on how the values are read from the sensor through read/write_I2C functions? May be I can tune/calibrate the sensors more accurately once I know how bits/blocks read from the I2C represent the sensor value. I can always buy another dht pro sensor if the sensor is faulty, but I will have to calibrate the values non-the-less for the final product.

Cheers,
Khattak

Hi khattak,
The DHT sensor seems to working differently for a lot of people. We have seen it work great with a lot of people and some people had the same problems like yours. Sadly there is nothing that we can say for sure about the sensors.

There is an argument which you can use to switch between the three types of DHT sensor. It’s the second argument that you send to get the reading’s from the DHT sensor can br 0,1 or 2 depending on the sensor.

For the I2C communication, we use the SMBUS library. The documentation around it is a bit obscure but this might help: https://github.com/bivab/smbus-cffi/blob/master/smbus/smbus.py and https://github.com/torvalds/linux/blob/master/Documentation/i2c/smbus-protocol .

How the I2C ADC works is that you send it 1 byte for initialization and for getting values back, you write 1 byte and read 2 bytes back, see here https://github.com/Seeed-Studio/I2C_ADC_Suli/blob/master/I2C_ADC_Suli.cpp . You’ll have to do the same but in python, you can refer to our library here to see how it works on python https://github.com/DexterInd/GrovePi/tree/master/Software/Python. There are libraries for the Compass and Acceleromenter with the GrovePi which would be much more helpful.

There are some typr of I2C commands for which there are no functions in Python so might have to jump to C to get them to work, but from the looks of the Datasheet for the I2C ADC, http://www.ti.com/lit/ds/symlink/adc121c021.pdf I think that it should work with python.

Let me know if you need any more help.

-Karan

I have followed the same procedure which is given that is Setting up the Software guide and Updating the Grove-Pi Firmware but I am getting reading from DHT sensor as
pi@raspberrypi ~/Desktop/GrovePi/Software/Python $ sudo python grove_dht_pro.py
temp = 640.0 humidity = 1715.2
temp = 614.4 humidity = 1689.6
temp = 614.4 humidity = 1664.0
temp = 614.4 humidity = 1664.0
temp = 614.4 humidity = 1664.0
temp = 614.4 humidity = 1664.0
temp = 614.4 humidity = 1664.0
Need Help regarding this issue. Thanks in advance.
Amol Desai

Hi Amol,
Can you post the code that you are using as well as the sensor you are using. The Grove DHT sensor comes in 3 variants and most probably you are using the wrong one in the code.

-Karan

Hi Karan,

Thanks for immediate reply.
I am using Grove-Temp & Humidity Sensor SEN11301P.
And the code which I used is same as given in Grove Pi files in the examples named as grove_dht_pro.py

import grovepi
sensor = 4

while True:
try:
[temp,humidity] = grovepi.dht(sensor,1)
print “temp =”, temp, " humidity =", humidity

except IOError:
    print "Error"

Thanking You,
Amol

Hi Amol,
The sensor you are using is different from the one in the example. Can you try changing the second argument sensor_type grovepi.dht(sensor_pin,sensor_type) to 0 and 2. It must work on either one of the settings.

-Karan

Hi Karan,

Thank You very much for your reply.
You have given very accurate solution to my problem.
I have changed the value to 0 and then I have checked the output it’s showing properly.

Once again thank you.

Amol

Hi,
I have Grove Pi board attached to the Raspberry Pi. My problem is that how do I identify by coding in python that for particular port temperature sensor is connected and for other ports there are no sensors connected to it.I mean how to check for particular port sensor is connected or not. Usually we mention in code as follows,
dht_sensor = 0 # connected to D0
light_sensor = 1 # connected to A1
But if mistakenly I connect it to different port then it must has to detect that sensor is not connected to that port.

Thanks in advance for your reply.
Amol

Hey Amol,
Sadly it is not possible to accurately detect if anything is connected on the Analog and Digital ports. It is only possible on the I2C ports.

Without any sensors, the ports just read noise on analog lines and usually digital 0 on the digital line. It might be somehow possible to write a function to look for expected values from the analog port but I don;t thing it would be worth the effort.

-Karan

hi Karan thanks
I have to read the port without which how can i separate readings of different sensors and store them.
Since there are so many ports , there has to be mechanism to identify reading is coming from a particular port
Please help it has stalled my project work.
fyi – i have connected one digital and analog sensor and wish connect more.

Hey Amol,
Have a look here: http://www.dexterindustries.com/GrovePi/engineering/port-description/ . The ports are marked as D1,D2, A2, I2C etc. You can use these as markers. Connect the sensors to the port and use the same port in the program.

-Karan

I got the same problem such as getting “nan” and “0” value from Grove DHT sensor, while running the example project from the user manual included to GrovePi+ Starter Kit. (P.26 “Example Project:Sensor Twitter Feed”)

But I found that the manual’s description was wrong.
I changed the port of DHT sensor from “A2” to “D7” and rewrote the port number at the source code from “4” to “7” and it gave me the right value.

First, at the Hardware setup section, it guides us to connect temperature sensor to an analog port, which is A2.
Second, at the Source Code section (P.27), the temperature sensor is set to digital port, which is D4.
*plz see the attached snap images of the manual.

Maybe the reason why DHS sensor works differently for many people is the manual?

Since I got the Starter Kit at Japan, probably the manual’s version was old, but I found several clerical errors in it.
If there’s a newer version, where can I get the latest, maybe in PDF?