I need help here. I am using the web editor. I recently downloaded ArduinoJSON library from the github: GitHub - bblanchon/ArduinoJson: π JSON library for Arduino and embedded C++. Simple and efficient., and then compiled some samples from there. It worked at first, and then today, I tried to recompile the same sample and I got this error:
error: 'const void*' is not a pointer-to-object type
Using library ESP8266WebServer at version 1.0 in folder: /home/builder/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/ESP8266WebServer
Using library ArduinoJson at version 6.19.4 in folder: /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson
In file included from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp:11:0,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp:14,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp:18,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp:9,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp:8,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp:7,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp:8,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson.hpp:24,
from /mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson.h:9,
from /tmp/390803116/esp8266_mega_test/esp8266_mega_test.ino:9:
/mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of 'typename ArduinoJson6194_F1::enable_if<ArduinoJson6194_F1::is_pointer<T>::value, T>::type ArduinoJson6194_F1::pgm_read(const void*) [with T = const __FlashStringHelper*; typename ArduinoJson6194_F1::enable_if<ArduinoJson6194_F1::is_pointer<T>::value, T>::type = const __FlashStringHelper*]':
/mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp:85:12: required from here
/mnt/create-efs/webide/ed/6a/ed6a586071b1ba657f1b50b444f78479:gunawan98/libraries_v2/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:15:45: error: 'const void*' is not a pointer-to-object type
return reinterpret_cast<T>(pgm_read_ptr(p));
^
Error during build: exit status 1
I tried to compile this code:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
ESP8266WebServer server;
char* ssid = "YOUR_SSID";
char* password = "YOUR_PASSWORD";
void setup()
{
WiFi.begin(ssid,password);
Serial.begin(9600);
while(WiFi.status()!=WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/",handleIndex);
server.begin();
}
void loop()
{
server.handleClient();
}
void handleIndex()
{
// Send a JSON-formatted request with key "type" and value "request"
// then parse the JSON-formatted response with keys "gas" and "distance"
DynamicJsonDocument doc(1024);
double gas = 0, distance = 0;
// Sending the request
doc["type"] = "request";
serializeJson(doc,Serial);
// Reading the response
boolean messageReady = false;
String message = "";
while(messageReady == false) { // blocking but that's ok
if(Serial.available()) {
message = Serial.readString();
messageReady = true;
}
}
// Attempt to deserialize the JSON-formatted message
DeserializationError error = deserializeJson(doc,message);
if(error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
return;
}
distance = doc["distance"];
gas = doc["gas"];
// Prepare the data for serving it over HTTP
String output = "distance: " + String(distance) + "\n";
output += "CO level: " + String(gas);
// Serve the data as plain text, for example
server.send(200,"text/plain",output);
}
I tried to find some info about this one, but I don't seem to understand the solution. Any help would be very appreciated! I am stuck here now.