Arduino Due randomly slows down, serial communications stops
The Due will randomly stop sending data to the Pi after a few days, or sometimes after several hours.


Here is the typical manifestation of heap fragmentation in an Arduino sketch.

Solution:


Remove as many Strings as possible and replace them with char[]
Use a StaticJsonBuffer instead of a DynamicJsonBuffer


If you remove all the Strings and use a StaticJsonBuffer, your program will run without any heap. No heap, no fragmentation! Not only it will be more reliable, it will also be smaller and faster.

If you must use String, then call String::reserve() to make sure the size is the same at each iteration. Indeed, repeated allocation of the same size doesn't increase fragmentation.