-2

I'm trying to do serial communication between Arduino mega and a esp8266, and having issues with determining the size of the JSON document. I have read that the receiver buffer size should be greater than the sender buffer, but what's the maximum buffer size we can use for the JSON document?

2

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 DynamicJsonDocument.

In both cases, you need to leave a lot of room for other variables and libraries. As an example, I wouldn't create a StaticJsonDocument bigger than 6 KB on the Mega, and 2 KB on the ESP8266.

By the way, I heard this library is very well documented, did you have a look?
Do you know you can use the ArduinoJson Assistant to help you decide the capacity of the JsonDocument?

3
  • 1
    so you heard? :-) – Juraj Aug 19 '20 at 7:38
  • Thanks and I checked the links earlier, but I have an issue, is the size we give when creating the static json document is in bytes? ex StaticJsonDocument<450> doc; is it 450 bytes? – Binara Medawatta Aug 24 '20 at 6:55
  • Yes, it's the capacity of the memory pool, in bytes. – Benoit Blanchon Aug 24 '20 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.