Nanopb encodes and decodes Protocol Buffers on memory-constrained devices using small ANSI C sources generated from .proto files.
Overview
Nanopb targets microcontrollers and other restricted environments that cannot host full Google protobuf libraries. Developers run protoc with nanopb's generator to produce .pb.c and .pb.h files, then compile pb_encode.c, pb_decode.c, and pb_common.c into firmware.
Options files customize field limits and storage strategies for tiny RAM footprints. Build integration ships for Make, CMake, Bazel, Conan, Meson, and other ecosystems.
A test suite runs under Scons with platform targets including STM32 and AVR simulators. Binary packages bundle Python, grpcio-tools, and protoc for easier header generation on desktop OSes.
Documentation and examples include a simple Makefile project for first-time integration.
Key features
- Small ANSI C protobuf codec
- protoc code generator
- .options file customization
- CMake and Bazel integrations
- Embedded test targets
- No dynamic allocation options
- Cross-platform generator tools
- Stable and pre-release packages
Use cases
- Embedded sensor messaging
- Firmware RPC definitions
- Low-RAM protobuf parsing
- IoT device configuration structs