Im making a little project with my NodeMCU Mx with ESP8266, but ArduinoJson lib tells me there's an error. I just want to fetch the data inside my json file and use the data as variable, in order to print it on a LCD display. It was working at the beginning, but now its always makes the same error, even if i recompile and transfert it into my nodemcu.
The code :
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
String payload = "";
void setup()
{
//CONNEXION AU WIFI
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.begin("test", "testtest");
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
}
Serial.println("Connected !");
delay(1000);
Serial.print("Local IP:");
Serial.println((WiFi.localIP().toString()));
Serial.print("Mac adress :");
Serial.println((WiFi.macAddress().c_str()));
Serial.print("Hostname :");
Serial.println((WiFi.hostname()));
//LED ALWAYS ON
digitalWrite(LED_BUILTIN, LOW);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
http.begin("http://latin-american-brea.000webhostapp.com/dan.json"); //Specify request destination
http.addHeader("Content-Type", "text/html");
int httpCode = http.GET(); //Send the request
if (httpCode > 0) { //Check the returning code
String payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
// Stream& input;
StaticJsonDocument<96> doc;
DeserializationError error = deserializeJson(doc, payload);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
const char* fruit = doc["fruit"]; // "Apple"
const char* sizz = doc["sizz"]; // "Large"
const char* color = doc["color"]; // "Red"
Serial.println(fruit);
} else {
Serial.println("Marche pas");
}
http.end(); //Close connection
}
Serial.println(payload);
delay(30000); //Send a request every 30 seconds
}
And here's the error:
deserializeJson() failed: NoMemory
I don't really understand, can someone help me please? Thanks!