hi, I'm trying to use the ArduinoJson library to construct the JSON message. I need to construct and send multiple JSON messages. When building the first message, everything is fine, the message is composed and sent over the WiFi network. When trying to build the second JSON message the microcontroller just hangs and stops working, I have to reset the device, disconnect from the USB port and connect again. So the problem is that the first JSON message can be composed, but other subsequent JSON messages can't be buit, the device just stops working. I have tried to create instance of the JSON document is several ways:
DynamicJsonDocument firstJsonDoc(1024);
// construct the firstJsonDoc
DynamicJsonDocument secondJsonDoc(1024);
// the microcontroller crashes here
This is another way that I have tried to achieve the same thing:
DynamicJsonDocument* firstJsonDoc = new DynamicJsonDocument(1024);
// construct the firstJsonDoc
DynamicJsonDocument* secondJsonDoc = new DynamicJsonDocument(1024);
// the microcontroller crashes here
initially I was blaming on the insufficient memory, however after checking the memory capacity of the MKR device, this shouldn't be a problem, as the MKR WiFi 1010 has 32 KBytes of the SRAM memory and after allocating memory for all the global and local variables and other program - related things, at least 10000 bytes should remain for the application needs (dynamic program variables).
Please share any ideas why the microcontrolelr crashes after starting to build a second JSON message.