[solved] ESP8266, pgm_read_ptr(): error: 'const void*' is not a pointer-to-object type

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.

Hi,
I tested your code here and it compiled without errors.

My IDE ver: 1.8.9
Board Manager ESP8266 version 2.6.3
Arduinojson : Version 6.14.1

What versions do you have?

1 Like

I am using Arduino Web editor, compiled using board ESP8266 Lolin (WEMOS), D1 R2 & Mini. As it is web editor (cloud based), I don't know how to check the version. ArduinoJson: version 6.19.4.

It was compiled successfully before, and then suddenly, it didn't work yesterday. Not sure what I did to make this happen. Probably library update?

I need the serializeJson() and deserializeJson() in my project. I don't think there are similar functions in Arduino's own JSON.

I tried to use Arduinojson v6.14.1 as you did, and it was successful! So, the problem is in the library. Don't know which part. I tried several versions also and found out that the latest version I could use successfully is v6.16.1. Starting from 16.7.x and above will result compiling error. So I guess I have to use the old version for the time being. Thanks for your reply, it gave me an idea to try the other version.

Hi,
if your problem was solved, do a kindness to everyone on the forum, especially to those who helped you. Write [Solved] before your topic title, so if someone searches and finds your topic, they'll know what the solution looks like.
And if it was solved by some help, please tick the one that best describes your solution.

Will do.
But, I am just curious about the real why. I guess, I just have to accept this 'downgrade version' solution and just hope someday the author will resolve it in the next version.

The problem has been addressed by the developer in
Troubleshooter | ArduinoJson 6 which states:

This error comes from a bug in the Arduino Core API (or Arduino.h, if you prefer). This bug was fixed by arduino/ArduinoCore-API#118 in October 2020, but the fix wasn't immediately propagated to derived projects.

First, make sure that every related piece of software is up-to-date. Then, if the problem persists, please open an issue in the relevant project and mention arduino/ArduinoCore-API#118 in the description.

As a workaround, you can disable support for PROGMEM in ArduinoJson (your board doesn't support it anyway) by setting ARDUINOJSON_ENABLE_PROGMEM to 0, like so:

#define ARDUINOJSON_ENABLE_PROGMEM 0
#include <ArduinoJson.h>
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.