Skip to content

Instantly share code, notes, and snippets.

@kakopappa
Created March 6, 2018 11:03
Show Gist options
  • Save kakopappa/d2a3522ebf917962a521aac1750eaa4f to your computer and use it in GitHub Desktop.
Save kakopappa/d2a3522ebf917962a521aac1750eaa4f to your computer and use it in GitHub Desktop.
arduino_json_temp_example.ino
DynamicJsonBuffer jsonBuffer(128);
JsonObject& root = jsonBuffer.createObject();
root["action"] = "setPowerState";
root["value"] = "ON";
StreamString databuf;
root.printTo(databuf);
webSocket.sendTXT(databuf);
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["action"] = "SetTargetTemperature";
JsonObject& value = root.createNestedObject("value");
JsonObject& targetSetpoint = value.createNestedObject("targetSetpoint");
targetSetpoint["value"] = 2.0;
targetSetpoint["scale"] = "CELSIUS";
StreamString databuf;
root.printTo(databuf);
webSocket.sendTXT(databuf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment