Go Down

Topic: Get Cloud property from device (Read 721 times) previous topic - next topic

adriens

Context

On a property, I need my device to be able to get the value  from the cloud, ie. not reset it locally. For now everything is reset while I reboot my device, I'd like to restore the value with the cloud's value : any idea on how to perform this please ?

mbertorello

This feature is implemented is called Shadow Thing
https://blog.arduino.cc/2019/05/17/arduino-iot-cloud-aprils-new-features/

Please share more information and your sketch so we can help you.

ubidefeo

@mbertorello

The problem is when you need to set the first value from the board at initial run, I have helped someone else on the same issue.

@adriens
You can add a boolean flag as one of your properties and not initialise the variables in setup but only on connect.
if you care to share your sketch I'll rework it to help you out.

essentially it's like this
- subscribe to the callback for onSync
- in the callback check for the state of your flag (could be a property named "initialSetupDone")
- if this property is false set the initial values which will be sent to cloud
- if it's false do not set them and you'll automatically obtain the Shadow Values from the Cloud

let me know if you need more detailed work :)

u.

ubidefeo

@adriens
goes without saying that if you want to run a new "initial setup" you'll have to set that flag to false somehow :)

Go Up