nanopb

If your system communicates with other devices (or even an app), I highly recommend using an RPC library, such as Google's Protocol Buffers or Apache's Thrift. These libraries allow you to define your interfaces using an interface design language (IDL) and can generate source stubs for a large number of languages. These RPC libraries also handle aspects like serialization/deserialization, leaving you free to worry about higher-level functions rather than re-inventing the wheel.

Today I'd like to feature a very useful embeddedable library: nanopb. nanopb is a plain-C implementation of Google's protobufs. This is quite a boon, as Google's normal protobufs implementation does not have support for C.

The library is built with 32-bit microcontrollers in mind. The library is small, so it is usable on other embedded systems. The author claims that the library requires 2-10kB of ROM usage and under 1 kB of RAM usage.

You can find the nanopb library on github, or you can take a shortcut and clone it using:

git clone https://github.com/nanopb/nanopb.git

Note: You will still need to download and install the Google protobuf compiler with nanopb. This tool lives on your host system.

Further Reading