Make Any Sensor a Smart Sensor with PICMG IoT.1, Part 4: What Is A Builder and How Do I Get Started?
February 02, 2022
PICMG IoT.1-compliant firmware must be user-friendly but also machine readable. In Part 4 we discuss the next link in the firmware development chain: the Builder.
(Editor's Note: For a specific part of the series, click below:
Part 3 describes the process of storing IoT.1-compliant data in JSON files using PICMG’s Configurator tool. JSON is a great format for storing and transmitting human-readable data objects. However, it’s not designed to be interpreted by machines, and the data needs to be presented in a way our target hardware (the smart sensor) can use it.
That’s where the Builder comes in.
What is a Builder?
A “Builder” converts JSON files into machine-readable code then uploads it to the smart sensor hardware. PICMG doesn’t explicitly specify a Builder as part of the IoT.x family of specifications, but they have made reference software available that demonstrates how a Builder could function.
[Editor’s Note: Reference “Builder” software is available on the PICMG Github where it can be downloaded for free.]
The conversion process with PICMG’s example Builder works a lot like Mad Libs – a story is generated with words left out. Depending on the words that are chosen to fill in the blanks, you can create wildly different meanings.
When PICMG’s sample Builder receives a configured JSON file, it takes the data and splits it into two files as part of the conversion process: “config.h”, and “config.c”.
- “config.h” contains the definitions of blocks of code that can be turned on or off.
- Active “config.h” definitions are called into the main config.c file to complete firmware code that is unique to the configured data model and smart sensor
The only thing left is to compile both the config.h and config.h files with the microcontroller’s C compiler toolchain (the builder is intended to work with AVR GNU Debugger, avr-gdb).
Ready to Build Your Own?
Ready to build your own interoperable smart sensor? You already have all the knowledge and tools you’ll need to get started.
Just as a quick refresher, here’s a bill of materials snapshot:
- Sensor – Any sensor will do, as long as it has a datasheet.
- Microcontroller board – For the PICMG Smart Sensor Challenge we used a PICMG MicroSAM board from Triple Ring Technologies based on an 8-bit ATmega MCU.
- PICMG IoT.1 Configurator – Software that converts datasheet values into a JSON file to be interpreted by a builder. Download an IoT.1-compliant reference Configurator from Github (PICMG/iot_configurator (github.com)), or use your own that meets the spec requirements.
- Builder – Vendor-specific software that accepts the configurator’s JSON file, produces firmware that can be read by the microcontroller board, and deploys it to the target. For the purposes of this demonstration, we have created a reference builder that is available on Github (PICMG/iot_builder (github.com)).
Now you can make any sensor interoperate with any logic device!
If you’re looking for more guidance, check out the video tutorial below in which PICMG CTO Doug Sandy walks through this entire build process in just a few minutes. Or head over to the PICMG website to learn more or download the IoT.1 specification.