Hello, I have an issue at the time of updating my variable in Arduino cloud. I am running python in my PC as a Manually configured device. The variable seems to be updating every second in the cloud, but it is always giving me the same value=0. This is my code
import time
import logging
import sys
sys.path.append("lib")
from arduino_iot_cloud import ArduinoCloudClient
DEVICE_ID = b"01f1987"
SECRET_KEY = b"5nVVD"
value = 0
def logging_func():
logging.basicConfig(
datefmt="%H:%M:%S",
format="%(asctime)s.%(msecs)03d %(message)s",
level=logging.INFO,
)
def read_value(client):
global value
return value
def on_switch_changed(client, value):
print("Switch Pressed! Status is: ", value)
if __name__ == "__main__":
logging_func()
client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
client.register("test_value", on_read=read_value, interval=1.0)
client.register("test_switch", value=None, on_write=on_switch_changed)
client.start()
while True:
client.update()
value += 1
client["test_value"] = value # Update the test_value cloud object with the new value
time.sleep(1.0)