[SOLVED] Values Repeating when sent


#1

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"

#2

Hi @jakobpackers,

We recommend you print the values that are you reading before send it and verify that the values are changing. Please send us a capture of your screen to check

Like this:

 print "value1: %s, value2: %s", % (value1, value2) 

If doesnt work, try assigning differents values so we can verify what is the problem

Like this:

value1 = 1
print(value1)
send(value1)
value1 = 2
print(value1)
send(value1)