JSON, the ESP-8266 with Arduino core, and ArduinoJSON

I was going to post a REALLY long story about the development of the serial & wifi protocol. As part of that journey I implemented two asynchronous state machine loops, a command interpreter, and a pile of standards for tying code to the api.

 

Then I got to the ArduinoJSON part of the work, and realized that a caution buried in the docs basically meant a re-write so I wouldn’t suffer a memory leak. Yuck. Screw that.

 

At the same time I’d mapped out what parts of that initial state machine communications code would benefit from being put in a library, and one important thing jumped out at me:

 

In an ESP-only or ESP+AVR pairing of controllers forming one node, ONLY the ESP needs to process JSON. Any data using the ESP as wifi-to-serial bridge to get to the AVR isn’t in JSON format.

 

Given the potential memory leaks and the re-write, I did a quick bit of reading: How complex is processing JSON in micropython? After all, if it’s a bear to implement in c++, why not just jump ship? I’ve been looking for an excuse to try python in something production, and this seemed like a good place to start.

 

After about 5 minutes I had the ESP-01 reflashed to micropython 1.9.4, and the REPL was responding to serial. A few minutes later and the webREPL was working too. Another hour of reading, and I had ampy running. And another hour of tinkering in atom.io and I had a nearly seamless IDE. (but not quite, ampy isn’t the best choice for being interactive, so I’ll try rshell next).

 

Ok, so now I can process JSON with basically one line of code. Next?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.