DHT sensor vs light sensor


#1

the following little script returns 0 as light_intensity.
But the light sensor works ok if I disconnect the DHT sensor


import grovepi
from grovepi import *
import time

#Connections
light_sensor = 1
dht_sensor = 7

while True:
try:
[ temp,hum] = dht(dht_sensor,0)
light_intensity = grovepi.analogRead(light_sensor)
print temp, hum, light_intensity
time.sleep(5)
except Exception as e:
print e


#2

Hey,
I just tried the code for using the DHT sensor and the light sensor and you are right. FOr some reason the light sensor does give )'s when used along with the DHT sensor. To read from the light sensor, just add a small delay of 500ms b/w the reads from the light and the DHT sensor and it should start working. What seems to be happening is that the reads are being sent too fast and the GrovePi is unable to process them properly and giving the wrong values back. We’ll have a look at this in dept and add changes to the firmware to make it better. Here is the updated code that should work:

import grovepi
from grovepi import *
import time

#Connections
light_sensor = 1
dht_sensor = 7

while True:
	try:
		[ temp,hum] = dht(dht_sensor,0)
		time.sleep(.5)
		light_intensity = grovepi.analogRead(light_sensor)
		print temp, hum, light_intensity
		time.sleep(1)
	except Exception as e:
		print e

Do let us know if this works for you.

-Karan