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 ...
Juraj's user avatar
  • 18.1k
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 ...
timemage's user avatar
  • 5,231
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 ...
Benoit Blanchon's user avatar
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 ...
Benoit Blanchon's user avatar
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 ...
per1234's user avatar
  • 4,098
4 votes
Accepted

'DynamicJsonBuffer' was not declared in this scope

Did you forget to include the ArduinoJSON header file: #include <ArduinoJson.h>
jose can u c's user avatar
  • 6,974
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 ...
Benoit Blanchon's user avatar
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 ...
Edgar Bonet's user avatar
  • 43.1k
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 ...
Benoit Blanchon's user avatar
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" ...
Benoit Blanchon's user avatar
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 (...
Maximilian Gerhardt's user avatar
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 ...
romkey's user avatar
  • 1,554
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/...
user3308886's user avatar
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 ...
Sheraz Ahmed's user avatar
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&...
jose can u c's user avatar
  • 6,974
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 ...
Edgar Bonet's user avatar
  • 43.1k
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 ...
Juraj's user avatar
  • 18.1k
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 ...
Juraj's user avatar
  • 18.1k
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 ...
jose can u c's user avatar
  • 6,974
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 ...
Phil Haigh's user avatar
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 ...
Majenko's user avatar
  • 105k
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 ...
Benoit Blanchon's user avatar
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 ...
Edgar Bonet's user avatar
  • 43.1k
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 ...
Benoit Blanchon's user avatar
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 ...
Benoit Blanchon's user avatar
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 ...
Mohammed Noureldin's user avatar
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: &...
Majenko's user avatar
  • 105k
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 ...
Benoit Blanchon's user avatar
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, ...
Eugenio Pace's user avatar
2 votes
Accepted

ArduinoJson library parsing error

Your shell is stripping the " from inside the string. If you run the command: $ echo "{"callbackTopic" : "xyz"}" you get: {callbackTopic : xyz} so you see all the ...
Majenko's user avatar
  • 105k

Only top scored, non community-wiki answers of a minimum length are eligible