Incorrect readings and TypeError

Hello,

So I have bought a GrovePi Temperature and humidity sensor => http://www.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro. I’m able to get some readings, but the readings seem a bit off. For example running this code:

import grovepi

# 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,white)
        print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))

    except IOError:
        print ("Error")

I get:

temp = 23.70 C humidity =60.00%
temp = 23.70 C humidity =59.90%
temp = 23.70 C humidity =59.90%
temp = 23.70 C humidity =59.90%
temp = 23.70 C humidity =60.00%
temp = 23.70 C humidity =59.90%
temp = 23.70 C humidity =59.90%
temp = 23.70 C humidity =60.00%
Traceback (most recent call last):
  File "/usr/lib/nagios/plugins/check_lin_grove_temp_hum.py", line 17, in <module>
    [temp,humidity] = grovepi.dht(sensor,white)
TypeError: 'int' object is not iterable

So my first problem is that after a few iterations I keep getting “TypeError: ‘int’ object is not iterable”

And the temperature readings is a bit wrong. I’m quite sure it’s not 23,70 degrees over here, as I have two other temperature meters, one saying 21,60 and the other 22,20. What could cause this higher temperature? The sensor is not placed on anything warm or next t the RaspBerry.

Grtz

Willem

Hello,

The TypeError: ‘int’ object is not iterable can be solved by adding an exception TypeError:

def main():
    sensor = 4  # The Sensor goes on digital port 4
    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,white)
            print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))

        except IOError:
            pass

        except TypeError:
            pass
if __name__ == '__main__':
    main()

If someone could comment on the readings being more then one degree of what I was expecting. Is anyone else seeing this?

Hey willemdh,
We have not tested multiple of these sensors in parallel so don;t have a good idea of what the accuracy is. The datasheet shows that the accuracy can be ±1C and it can vary by ±0.3C every year PDF datasheet here: http://www.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro.

Maybe that is why it is showing that bug of a difference. Can you run it for a few hours and see if the values stabalize.

-Karan