I am sending value and they keep repeating the same numbers on ubidots when they should change. I am using a DHT22 temperature and humidity sensor. To test change I blow on it and it should change(it does when running different code).
Below is my python code:
from ubidots import ApiClient
import Adafruit_DHT
import RPi.GPIO as GPIO
import time
sensor = Adafruit_DHT.DHT22
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
#Create an ApiClient object
api = ApiClient(token=‘xxxxxxxxxxxxxxxxx’)
GPIO.setmode(GPIO.BCM)
GPIO.setup(1, GPIO.OUT)
GPIO.setup(7, GPIO.IN)
GPIO.setup(6, GPIO.OUT)
#Get a Ubidots Variable
try:
variable1 = api.get_variable(“5711025d76254250de6dac65”)
variable2 = api.get_variable(“571ba07976254240aa73c7c7”)
except ValueError:
print"It is not possible to obtain the variable"
while(1):
try:
# sends data to ubidots.
# temperature reading is in fahrenheit since thats what Americans like
value1 = (temperature)*1.8+32
value2 = humidity
variable1.save_value({'value': value1})
variable2.save_value({'value': value2})
print "Value sent"
time.sleep(10)
except ValueError:
print "Value not sent"