One of the things this community is famous for is the degree to which people will pitch in to fill an obvious need. Look at the vast array of libraries available for Arduino as an example of how people are willing to devote their time to making difficult tasks easier, often for little more than a virtual pat on the back.
One level up from the library writers are those who go through the trouble of explaining how all these libraries work in real-world applications. [Brian Lough] recently rose to that challenge with a thorough explanation of the use of the ArduinoJSON library, a very useful but often confusing library that makes IoT projects easier.
The need for an ArduinoJSON explainer no knock on its author, [Benoît Blanchon], who has done excellent work documenting the library; it’s more of a realization that the nature of JSON itself means a library that works with it is going to be complex. [Brian]’s contribution here is sharing his insights into getting ArduinoJSON up and running in a real-world ESP32 example, and dealing with the potential pitfalls of parsing a human-readable text file that can be used to represent almost any data object using the limited resources of a microcontroller. Along with the basics, we found the warning about how pointers refer back to the dynamic JSON document object particularly helpful; the bit about using filters to winnow down a large data set was useful too.
Thanks to [Brian] for taking the time to put this valuable information out there. Here’s hoping this encourages others to share the wealth of hard-earned knowledge in a similarly clear and concise manner.
I’ve used ArduinoJSON for a while and I think it’s a great library, saves me a lot of work. I don’t use it for parsing some APIs from some random service, though, but instead I use it to pass sensor-data from my remote sensors, or for passing settings and changes to those settings between a device and the browser over websockets — JSON makes it really easy to debug stuff in the browser, when you can just do ‘console.log(somejsonobjecthere)’ in the Javascript and get readable and well-structured output.
If you are going to have so much bloat just to pass information in/out of your microcontroller…..just use a an RPI and be done with it.
Often times the RPi is not fast enough for the task at hand. I use MCU’s in conjunction with RPi’s very frequently.
If you use Protocol Buffers instead, you might still be able to keep the microcontroller.
Because…what? Because it offends your sensibilities or something?
If the MCU isn’t struggling with it and there’s enough RAM and flash, then there is no good technical reason for ditching the MCU and your sensibilities don’t count as a good or a technical reason. On the other hand, dealing with JSON can make debugging things far easier than trying to squeeze every single bit of “bloat” out.
Nobody will care, but I have opted for tokenizing the data I need and send it over WPA2 via plain UDP to my ESP devices. A single raspberry is the orchestrator to fetch data from the net, parse it and send it to my LAN devices. I have never since worried about extra libraries. Sure it might not be the ideal solution for lots of data, but driving a couple of 20 chars x 4 lines LCDs is not a biggie.
Honestly: Whatever works for you.
But I enjoyed the video and I will know what to use, should I want to build a portable devices that connects to my phone’s wifi hotspot.