Created
June 8, 2019 03:32
-
-
Save isaacgr/6621cdee1e58e88d2072bdd5a0fdaae4 to your computer and use it in GitHub Desktop.
Setup a json message buffer with ArduinoJson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <ArduinoJson.h> | |
void setup() | |
{ | |
Serial.begin(115200); | |
} | |
void loop(){ | |
const size_t bufferSize = JSON_OBJECT_SIZE(5); | |
DynamicJsonBuffer jsonBuffer(bufferSize); | |
JsonObject &root = jsonBuffer.createObject(); | |
root["temp"] = 23; | |
root["humid"] = 44; | |
root["temp_f"] = 78; | |
root["loc"] = "bedroom; | |
root["key"] = "key"; | |
char JSONmessageBuffer[300]; | |
root.prettyPrintTo(JSONmessageBuffer, sizeof(JSONmessageBuffer)); | |
Serial.println(JSONmessageBuffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment