Hello, I am using MP as my language and I have it connected with the "blink led" project sample that works fine, I can hit the switch on the cloud on my phone and it will turn on or off the built in LED.
I am trying to add an I2c temp device I have (SHT45).
I can get the cloud to do the initial read and it posts it correctly on the widget. However no further updates happen. I looked at the official MP code examples and I'm stuck.
I'm doing this before connecting to the web:
i2c = I2C(1, sda=Pin(18), scl=Pin(19)) # Correct I2C pins for RP2040NANO
sht = sht4x.SHT4X(i2c)
sht.temperature_precision = sht4x.HIGH_PRECISION
temperature, relative_humidity = sht.measurements
tempF = (sht.temperature * 1.8) + 32
then I created a function for it
def tempchange(client,value):
sht = sht4x.SHT4X(i2c)
sht.temperature_precision = sht4x.HIGH_PRECISION
temperature, relative_humidity = sht.measurements
tempF = (sht.temperature * 1.8) + 32
client["tempF"] = tempF
Next at the very bottom of my code I associate the object, like I said it does a inital pull of the tempF value but never auto updates after that. How can do I do so?
client.register("tempF", value=None, on_write=tempchange, interval=0.50)
client.start()
How can I get tempF to update say every x amount of seconds? I'm stuck right now no updates except when 1 value at runtime when I kick off the code.
Thanks!