0% found this document useful (0 votes)
22 views2 pages

Code JSON

The document includes code to create a JSON object from sensor data and print it to the serial port when a character is received.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Code JSON

The document includes code to create a JSON object from sensor data and print it to the serial port when a character is received.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <ESP8266WiFi.

h>
#include <ArduinoJson.h>

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if(Serial.read() == 'j') {
DynamicJsonBuffer jBuffer;
JsonObject& root = jBuffer.createObject();

root["day"] = "Monday";

int temp = 21;


int humidity = 53;

root["temperature"] = temp;
root["humidity"] = humidity;

root.prettyPrintTo(Serial);
Serial.println();
}
delay(2000);
}#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if(Serial.read() == 'j') {
DynamicJsonBuffer jBuffer;
JsonObject& root = jBuffer.createObject();

root["day"] = "Monday";

int temp = 21;


int humidity = 53;
root["temperature"] = temp;
root["humidity"] = humidity;

root.prettyPrintTo(Serial);
Serial.println();
}
delay(2000);
}

You might also like