7
votes
Accepted
ArduinoJSON v6 - Passing buffer as function parameter
The StaticJsonDocument is a template class. The template value in <> is here only the size of the internal buffer, but every size used generates a different class. (memory usage!)
To have the ...
6
votes
Accepted
Getting all data of my JSON object from Serial.read() at once
I was going to put this as a comment, but maybe it belongs as an answer:
For what it's worth, ArduinoJSON seems to be able to deserialize directly from a stream, i.e. Serial, which may obviate the ...
6
votes
Accepted
how to transfer json to string?
That's one of the peculiarities of the C language: the == operator compares the string addresses, not their content. It makes sense when you think of them as pointers, but it can be confusing for ...
6
votes
Accepted
Need help with parsing NWS JSON weather alerts causing reset on ESP8266
By default, the size of the stack is limited to 4KB on ESP8266, so you cannot store an 8KB document there.
To fix this issue, replace the StaticJsonDocument with a DynamicJsonDocument to move the ...
5
votes
Accepted
NodeMCU (Arduino IDE) 'DynamicJsonBuffer' was not declared in this scope
This error is caused by using a 6.x.x version of the ArduinoJson library with code that was written for a pre-6.x.x version of the library.
You have two options to solve the problem:
A. Downgrade ...
4
votes
Accepted
'DynamicJsonBuffer' was not declared in this scope
Did you forget to include the ArduinoJSON header file:
#include <ArduinoJson.h>
4
votes
Accepted
Unexplained behavior of char array after using `deserializeJson`
When you pass a char* input to deserializeJson(), it alters the input to avoid making useless copies.
This is the "zero-copy" mode of ArduinoJson.
In this mode, the JSON parser modifies the ...
4
votes
Accepted
Understanding ArduinoJson capacity calculation assistant
If you look at the details of the numbers reported, you should see:
Data structures 112
Strings 0
Total (minimum) 112
Total (recommended) 128
As you see, there are exactly zero ...
4
votes
Accepted
Determining ArduinoJSON document size based on file size
There is unfortunately no way to predict the size of the JsonDocument from the file size alone.
As a workaround, I suggest that you allocate a very large memory pool and shrink it after ...
4
votes
Accepted
ArduinoJson- unexplained '.size()' behaviour
The "fallback notation" you're referring to is JsonVariant::operator| and only works for JsonVariant.
In your program, you apply | to an unsigned long, so the built-in bitwise "or" ...
3
votes
Accepted
String class summation disappears the right operand
Your "disappearing string" has the following cause: Out-of-Memory.
You are constructing lots of String objects in your code and are concatinating to one. That uses memory on the heap for each String (...
3
votes
Accepted
publish json data to mqtt
What's your last error message?
no matching function for call to 'PubSubClient::publish(const char [11], String&)'
Read the documentation for the publish() method in PubSubClient:
int publish ...
3
votes
Reading & writing a configuration file on an Adafruit Circuit Playground Express
The problem was using the Arduino SAMD board core instead of the Adafruit SAMD board core. The Adafruit SAMD board core is not visible unless you add:
https://adafruit.github.io/arduino-board-index/...
3
votes
Accepted
deserializeJson() failed: NoMemory when sending Serial json using ArduinoJson
I'm pretty sure you're using ArduinoJson 7 because ArduinoJson 6 would not return NoMemory in such conditions.
On 8-bit microcontrollers (such as the Arduino Nano), I recommend using version 6 because ...
2
votes
Arduino JSON foreach loop
I found another way around the solution.
Idk if this is helpful to anyone but the problem was that I had an unknown number of nodes I wanted to loop through, Example of the json format above.
void ...
2
votes
Can't read JSON data from client (webpage) with Arduino Leonardo ETH
Below, you create a static string, which is never used again.
char json[] = "{\"index\" }";
Here you create a buffer and instantiate an empty JsonObject.
StaticJsonBuffer jsonBuffer;
JsonObject&...
2
votes
How to post JSON data from Arduino?
The string
"{\"AssetSensorDistance\":\"+st+\"}"
contains a literal "+st+". If you want to do string concatenation, you
should terminate the string with a double quote character, then add st,
then ...
2
votes
Accepted
Arduino parsing JSON
you have the HTTP chunked transfer encoding numbers in the content. 38 is the length of the body and it is on the first line of the HTTP body and 0 marks the end.
maybe try using ArduinoHttpClient ...
2
votes
ESP8266 SPIFFS not saving correctly?
You can write a struct to file as binary data. This example is from my project.
global data:
struct Stats {
int heatingTime; // minutes
int consumedPower; // watts
};
Stats statsData;
snippet ...
2
votes
Accepted
Reading file from SPIFFS in nodemcu using ArduinoJson
Your code at the top:
struct Config {
String ssid = "";
String pass = "";
bool hFlag = false;
};
defines a variable "type". It's like making a new int or bool, but yours is called struct ...
2
votes
Firmware gets stuck at obj.printto(client) in esp32
I see that you are using SSL. SSL uses a lot of RAM and it is possible that the stack and the heap are colliding which will corrupt the running sketch. I recommend you add the amount of free heap to ...
2
votes
Accepted
Not able to add JSON data to Arduino data
Comparison of floating point values is nigh on impossible. They aren't as accurate as you may think anyway, and two values have to be precisely the same to be considered equal - not something that is ...
2
votes
Accepted
Second item in array not gets assigned from struct object, ArduinoJson
ArduinoJson stores strings differently depending on their types:
for const char*, it saves a pointer;
for other types (char*, String...) it copies the string.
Because ArduinoJson stores the copy of ...
2
votes
json format in esp32 with arduino json
You are repeatedly overwriting the ssid property of the same object.
Instead, you want to write different properties, like
wifiJsonObject["ssid" + String(i+1)] = WiFi.SSID(i);
Then, only serialize ...
2
votes
Accepted
Serialize JSON as response to HTTP request
serializeJson() accepts a Print&, i.e, a reference to a class that implements the Print interface.
WiFiClient does implement the Print interface, but serializeJson() cannot make a reference to it ...
2
votes
What is the maximum size of Static Json Document in Arduino JSON?
The Arduino Mega has 8 KB of RAM, all of which you could use in a StaticJsonDocument.
The ESP8266 has 80 KB of RAM, but the core limits the stack to 4 KB. If you need something bigger, switch to a ...
2
votes
Understanding ArduinoJson capacity calculation assistant
I found what the real problem is. In the assistant tool, when choosing const char * as the input type, it shows that the size of the string is 0, which is wrong according to the documentation of the ...
2
votes
Accepted
Remove unwanted characters from char type
You can use strtok to split the string on the T character:
char *datepart = strtok(datetime, "T");
char *timepart = strtok(NULL, "T");
Serial.print("The current date is: &...
2
votes
Accepted
ESP8266 Arduino Json object array deserialisation into struct
No memory is allocated for the strings.
You should declare your struct like so:
struct Departure {
char destination[32];
char departure[32];
int deviation;
} depart;
This assumes the max ...
2
votes
Accepted
How to properly handle the Arduino String
+1 to @majenko's comments. I tend to avoid the String class, as I like to know what is actually going on, and I stick to char * and char [] in general (and the stdlib functions like sprintf, strlen, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
json × 97esp8266 × 31
arduino-uno × 21
esp32 × 17
arduino-ide × 14
http × 10
nodemcu × 7
string × 7
serial × 6
wifi × 6
programming × 5
c++ × 5
web-server × 4
iot × 4
arduino-mega × 3
serial-data × 3
mqtt × 3
esp × 3
library × 2
softwareserial × 2
c × 2
adafruit × 2
array × 2
compilation-errors × 2
pointer × 2