Resolution of dht sensor


#1

Hey,

I’m trying to use my dht sensor with the GrovePi+ kit. I have the blue version.
I do receive the temperature in degrees and humidity, however, I only have integer values, being the python default example or Go code. The resolution is said to be 0.1, is that normal?
I saw that another post was mentioning it at Precission of temperature readout, but without answer from the requester.

Yesterday, I did git clone the code on a fresh raspbian install, run the install script and flashed the firmware (version 1.2.7).

Here is some output from the unmodified https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_dht_pro.py:

temp = 20.00 C humidity =39.00%
temp = 20.00 C humidity =39.00%
temp = 20.00 C humidity =39.00%
temp = 20.00 C humidity =39.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =0.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 21.00 C humidity =37.00%
temp = 20.00 C humidity =38.00%
temp = 20.00 C humidity =38.00%
temp = 20.00 C humidity =38.00%
temp = 20.00 C humidity =38.00%

You can see there both temp and humidity are rounded. I did try to directly print them (without formatting), and it’s the same.

Thanks for any help! (Could it be a bad GrovePi firmware flashing?)

EDIT: I just tried to add some printing for raw data in grovepi.py FYI:

        try:
                read_i2c_byte(address)
                number = read_i2c_block(address)
                print(number)
                # time.sleep(.1)
                if number == -1:
                        return [-1,-1]

Here is the result:

[0, 0, 0, 168, 65, 0, 0, 56, 66, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
temp = 21.00 C humidity =46.00%

#2

Perhaps. The answer to your problem is in the firmware code
itself. Here is a link to the I think contains t problem, but not limited to.

It changes every sensor reading to a float. It appears that the readings may only come in integer values, so when the number is converted to a float it just tacked o. Two zeroes.
If you want possibly more accurate numbers It appears you need to change the firmware.