ArduinoJson Serializer
Hi,
I would like to use ArduinoJson to serialize my sensor data before publishing it via mqtt. Unfortunatlex it seems like ArduinoJson and the D21G board package are not compatible?
Is there a way of making them compatible?
Help is highly appreciated!
Error message:
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Industruino D21G"
In file included from C:\...\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Numbers/FloatTraits.hpp:13:0, C:\...\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Numbers/convertNumber.hpp:15,
....
C:\....\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of 'const T* ArduinoJson::V704PB2::detail::pgm_read(const T* const*) [with T = char]':
C:\....\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:85:42: required from here
C:\....\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Polyfills/pgmspace_generic.hpp:25:52: error: 'const void*' is not a pointer-to-object type
return reinterpret_cast<const T*>(pgm_read_ptr(p)); ^
exit status 1
Error compiling for board Industruino D21G.
Apperently this is not an Industruino specific error but a SAMD21 specific error.
The solution is this:
#define ARDUINOJSON_ENABLE_PROGMEM 0
#include <ArduinoJson.h>
Hope this will save somebody else some time saerching.
I just ran into this problem also.
This is an error in Arduino.h, propagated from a mistake in an early Arduino.h getting cut-and-pasted into multiple board support packages from various vendors. Hopefully Industruino will release version 1.0.4 with this bug fix.
<user_directory>\AppData\Local\Arduino15\packages\industruino\hardware\samd\1.0.3\cores\industruino\avr\pgmspace.h
This is the fix, there needs to be another asterix inserted because addr is a pointer to a pointer, not a pointer to a primitive.
OLD: #define pgm_read_ptr(addr) (*(const void *)(addr))
NEW: #define pgm_read_ptr(addr) (*(const void **)(addr))
Best regards,
Chris
I just ran into this problem also.
This is an error in Arduino.h, propagated from a mistake in an early Arduino.h getting cut-and-pasted into multiple board support packages from various vendors. Hopefully Industruino will release version 1.0.4 with this bug fix.
<user_directory>\AppData\Local\Arduino15\packages\industruino\hardware\samd\1.0.3\cores\industruino\avr\pgmspace.h
This is the fix, there needs to be another asterix inserted because addr is a pointer to a pointer, not a pointer to a primitive.
OLD: #define pgm_read_ptr(addr) (*(const void *)(addr))
NEW: #define pgm_read_ptr(addr) (*(const void **)(addr))
Best regards,
Chris
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 4/29/24, 10:52 AM |
Seen: 711 times |
Last updated: 3/19/25, 1:46 PM |