Hello,
I would like to ask if there is any way to decode the json and store in a text document at a micro SD card of a mcufriend 2.4" tft lcd.
My project will have to deal with sending the last row of sql database via esp8266 get request, and be decoded and translated to instructions to be output on the screen. The instructions have to be there on the lcd even after power cycle of the tft lcd. So I'm assuming that it has to be stored in a sd card. The instruction will only go away when the user touches the tft lcd screen
Do I run json parsing library in my esp8266 or at my arduino mega board where the tft lcd is mounted on?
And if so, how do I store the values?
here is my http GET code
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
WiFiClient client;
void setup () {
Serial.begin(115200);
WiFi.begin("supremacy", "Supremacy6236!");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Waiting for connection");
}
// check if below pin is necessary!!! ***********************************
pinMode(2, OUTPUT);
delay(100);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
http.begin("http://192.168.1.16/SensorDataWebService/api/dht11service"); //Specify request destination
int httpCode = http.GET(); //Send the request
if (httpCode >0) {
//String payload = http.getString(); //Get the request response payload
String json="";
boolean httpBody = false;
while (client.available())
{
String line = client.readStringUntil('\r');
if (!httpBody && line.charAt(1)=='{')
{
httpBody = true;
}
if (httpBody)
{
json += line;
}
}
StaticJsonBuffer <400> jsonBuffer;
Serial.println(json);
JsonObject& root = jsonBuffer.parseObject(json);
String data = root["url"];
//Serial.println(payload); //Print the response payload
}
else
{
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
// http.writeToStream(&Serial);
http.end(); //Close connection
}
delay(1000); //Send a request every 5 seconds
}
Best,
Shannon