This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.


Nanopb is a C implementation of Google’s Protocol Buffers.


Nanopb uses the protocol buffer compiler to generate source and header files, make sure the protoc executable is installed and available.

Use apt to install dependency:

sudo apt install protobuf-compiler

Additionally, Nanopb is an optional module and needs to be added explicitly to the workspace:

west config manifest.project-filter -- +nanopb
west update


Make sure to include nanopb within your CMakeLists.txt file as follows:


Adding proto files can be done with the zephyr_nanopb_sources() CMake function which ensures the generated header and source files are created before building the specified target.

Nanopb has generator options that can be used to configure messages or fields. This allows to set fixed sizes or skip fields entirely.

The internal CMake generator has an extension to configure * files automatically with CMake variables.

See samples/modules/nanopb/src/ and samples/modules/nanopb/CMakeLists.txt for usage example.