References
.data()
.on()

data.on

This method schedules a function to be called when a device variable changes on Grandeur.

A variable can be changed by a paired user from an app, dashboard, or any SDKs. All three of these updates would trigger the on-callback, or you can call it the device's data update handler. But updating a device's data variable from the device itself won't trigger its own update handler.

Update is a special type of event and the function that handles it is called an update handler.

NameTypeDescription
pathstringPath of the device variable using dot notation
callbackCallbackAn update handler for the device variable
  Grandeur::Project project;
  Grandeur::Project::Device device;
 
  void voltageUpdatedCallback(const char* path, int voltage) {
    // When "voltage" update occurs on Grandeur, this function
    // writes it to an analog pin.
    Serial.println("Voltage update occurred!\n");
    analogWrite(voltage, A0);
  }
 
  void setup() {
    project = grandeur.init(apiKey, token);
    device = project.device(deviceID);
 
    device.data().on("voltage", voltageUpdatedCallback);
  }
 
  void loop() {
    if(WiFiIsConnected) project.loop();
  }