Steven Reubenstone, using strings in a low memory environment was a worse solution to a bad problem. Now I’ve fixed both server and client to respond with and parse JSON respectively.
I’m using the ArduinoJson library to parse JSON. It works by statically allocating memory and uses low-level techniques. So it is better than using formatted strings.
Initially, free memory is ~1100 bytes. After a part of the memory is allocated to the JSON class, ~550 bytes are left free. It remains around the same even after 25 executions of the loop, with a delay of 60 seconds between executions, i.e., it worked flawlessly for 25 minutes. I stopped it when I had to recompile and upload the code for a small spelling mistake.
Ideally, you can run this device forever. If free memory goes below 300 bytes, it resets itself using WDT (Watch Dog Timer). It’s as good as powering the device off and then back on. In case this does not happen for some reason, your LCD will go blank.
We need to test how long this device can run without human intervention.