Hi,
I am modifying the default wifi_twit.py file by removing the twitter api bit and putting the rest in Software/Python folder.
I have LED connected to D3 and DHT temp/humidity sensor to D2, which are working fine. The readings changes according to the room temperature as I switch on/off the A/C. However the Sound sensor connected to A0 and light sensor connected to A1 are having the constant reading. (I have tried to make noise and cover the the light sensor). It always give me the same readings.
Here is the wifi_twit_test.py file
import time
import grovepi
import math
# Connections
sound_sensor = 0 # port A0
light_sensor = 1 # port A1
temperature_sensor = 2 # port D2
led = 3 # port D3
intro_str = "DI Lab's"
grovepi.pinMode(led,"OUTPUT")
grovepi.analogWrite(led,255) #turn led to max to show readiness
while True:
# Error handling in case of problems communicating with the GrovePi
try:
# Get value from temperature sensor
[t,h] = grovepi.dht(temperature_sensor,0)
# Get value from light sensor
light_intensity = grovepi.analogRead(light_sensor)
# Give PWM output to LED
grovepi.analogWrite(led,light_intensity/4)
# Get sound level
sound_level = grovepi.analogRead(sound_sensor)
# Post a tweet
out_str ="%s Temp: %d C, Humidity: %d, Light: %d, Sound: %d" %(intro_str,t,h,light_intensity/10,sound_level)
print (out_str)
time.sleep(5)
except IOError:
print("Error")
except KeyboardInterrupt:
exit()
except:
print("Duplicate Tweet or Twitter Refusal")
and the log.txt file. log.txt (6.1 KB)
Could someone advise please?
Regards,
Kenny