-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?

1 Answer 1

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? :-) Commented Aug 19, 2020 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? Commented Aug 24, 2020 at 6:55
  • Yes, it's the capacity of the memory pool, in bytes. Commented Aug 24, 2020 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.