Make Any Sensor a Smart Sensor with PICMG IoT.1, Part 4: What Is A Builder and How Do I Get Started?

By Brandon Lewis

Editor-in-Chief

Embedded Computing Design

By David Sandy

Technical Writing Consultant

PICMG

February 02, 2022

Story

Make Any Sensor a Smart Sensor with PICMG IoT.1, Part 4: What Is A Builder and How Do I Get Started?

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 1: What Makes a Sensor Smart?

Part 2: What is a Data Model and How Does it Apply to PICMG IoT.1?

Part 3: How Do I Create Smart Sensor Firmware?)

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.
 

Brandon is responsible for guiding content strategy, editorial direction, and community engagement across the Embedded Computing Design ecosystem. A 10-year veteran of the electronics media industry, he enjoys covering topics ranging from development kits to cybersecurity and tech business models. Brandon received a BA in English Literature from Arizona State University, where he graduated cum laude. He can be reached at [email protected].

More from Brandon

David has been instrumental in developing the open source Configurator as part of the PICMG IoT effort. He has been involved with PICMG since 2020 as both an intern and a technical writer. David is currently pursuing his Bachelor’s of Science in Software Engineering at Arizona State University.

More from David

Categories
Open Source