What is a Smart Sensor?
The PICMG IoT.1 specification offers a standard data model for sensor makers and systems integrators to speed the development and deployment of smart sensors in Industry 4.0 applications. We look at the requirements for a smart sensor and detail the tools you’ll need to construct your own.
Data is the foundation of smart factory and Industry 4.0 value, and sensors at the edge capture that data. The confluence of the IT and OT sectors, which begins with smart sensors, is required to turn that data into intelligence.
Smart sensors are exactly what they sound like on the surface. Endpoints for data gathering that include some logic for detecting, filtering, and transferring points of interest from collected data to other systems.
Of course, it’s more than that, especially if you’re a business intelligence specialist who needs to record and evaluate operational data. Smart sensors rely on sophisticated code built by embedded experts with years of experience, and that firmware must be vetted and tested to guarantee that production sensors perform as expected.
This is enough to put a smart sensor endeavor on hold for non-engineers. However, for Industry 4.0 to deliver on its promise, technicians of all skill levels must be able to easily deploy and maintain smart sensors.
The IoT.1 firmware specification from PICMG was created with this in mind, and it provides a straightforward, no-code approach to constructing smart sensors that makes the process easier than ever before.
What Characterizes a Smart Sensor?
The ability of a smart sensor, and by extension any host, to interpret data in a user-friendly, human-readable format distinguishes it from a typical sensor.
You should be able to plug a smart sensor into any device and immediately recognize it and its output. Any system that you plug a smart thermistor into should immediately read its outputs as oC or oF and the value of the outputs as natively formatted on the thermistor, just like when you plug a mouse into a computer, and it is immediately recognized as a mouse so you can start navigating with your cursor.
All of this is made possible by firmware, which interprets electrical signals generated by the sensor and outputs useable data to the host using a set of established settings. Sensor integrators, in contrast to the uniform world of consumer PCs and mice, now frequently create their own bespoke software and device drivers.
While this adds little, if any, value to the sensor manufacturer, it causes significant interoperability challenges across sensors that segment the market — and not in a positive way. PICMG developed the IoT.1 firmware specification in response to this, as well as the requirement for engineers of all skill levels to be able to develop smart sensors rapidly and easily.
The PICMG IoT.1 specification establishes a standard firmware data model with a focus on simplicity. Sensor manufacturers can utilize it to turn ordinary sensors into smart sensors, and OEMs and system integrators can easily pull data from any smart sensor into any design.
Anyone should be able to configure a smart sensor in minutes using PICMG IoT.1 as a basis.
But first, let’s obtain a better understanding of PICMG IoT.1 by looking at how the data model in the spec will fit into our project.
What is a Data Model, and how does it relate to PICMG IoT.1?
Smart sensors are enabled by a single data model.
For the uninitiated, a data model is a systematic method of organizing data that includes rules or instructions for how that data should be presented. When working with large amounts of data, data models make it easier to keep data accessible and manageable.
Consider it like a database record with numerous predefined fields. A car’s data model, for example, might include details such as the make, model, color, trim style, total miles driven, and so on. Because all entries contain the same fields, having a single database representation (data model) that can be utilized for all cars makes working with a large database of automotive data simple.
Similarly, in preparation for transfer to a system, a smart sensor data model can configure the unique model number, minimum and maximum values, readout types, and linearization of a smart sensor. There could be dozens of distinct sorts of data in environments where there are hundreds or thousands of sensors recording data, such as a smart factory.
In these situations, data models are essential for keeping track of all that data. After all, data is only helpful if it can be used, and you can only use it if you know what you’re looking for and where it is.
PICMG IoT.1’s Approach to Data Usability
In the IoT.1 data model, users can specify the unique properties of their sensor. The IoT.1 data model then arranges the data into specified fields based on the sort of data it is, because each sensor has its own set of fields that specify the sensor’s raw input, minimum and maximum values, and how the system will interpret and transmit commands for that data.
The data is then ready to be transported.
PICMG chose two industry-standard communications protocols for data transport when creating the IoT.1 data model: PLDM and MCTP. In the bidirectional transport of data, each of these protocols’ functions at a separate layer.
The Data Management Task Force’s (DMTF) PLDM protocol enables pre-determined commands to operate and interact with the device’s data model. MCTP accepts PLDM requests and transports them reliably across system hardware interfaces.
The smart sensor’s capacity to alert the system when it has been plugged in is one of the most beneficial components of this communications stack. The system can query the device, retrieve its data model, and integrate it into the system as needed after receiving a discovery request from the sensor.
Without the data model, plug-and-play device discovery would be impossible.
We’ll learn how to configure the sensor’s firmware by describing the data model in the next section so that the smart sensor can be discovered by the system afterward.
Creating Smart Sensor Firmware
PICMG IoT.1-compliant smart sensors operate with a predefined data model. The next section examines the process of configuring smart sensor firmware with a sample configuration tool provided by PICMG.
It’s time to start customizing the firmware now that we have a better knowledge of the PICMG IoT.1 data model and why it’s significant. Normally, this would necessitate some programming in languages like C, but PICMG has created an open-source reference tool for IoT.1 users that abstracts this complexity and makes producing compliant firmware as simple as filling out a few text boxes.
But first, why is it so crucial to configure the firmware if we’re using a data model?
The firmware is the implementation of the device that is described by the data model, whereas the data model is a template of what data is needed and how it is represented. To put it another way, the firmware implements the sensor’s actions and contains all the data about the sensor that the system requires to recognize it as a smart sensor.
The system has no means of knowing that a sensor is connected in the first place, and the sensor has no method of communicating effectively with the system without properly installed firmware.
The PICMG IoT.1 firmware can be found at https://github.com/PICMG/iot_firmware The Builder can be downloaded for free
PICMG IoT.1 Firmware Build & Configuration Automation
While a developer could design IoT.1-compliant firmware in C that defines all the data model’s specific behaviors, creating firmware for several sensors can be time-consuming for engineers and unfeasible for non-programmers.
PICMG created an example utility named “The Builder” to make this process easier. It builds C-based firmware from user-supplied JSON files and installs it on the target logic device.
[Editor’s Note: In Part 4, the Builder is discussed in greater depth.] The PICMG IoT.1 specification does not include it. More details can be found at https://github.com/PICMG/iot builder, where the Builder can be downloaded for free.]
The Builder simplifies the effort of building firmware by eliminating the requirement to write C code. The user must still give a JSON file, which is far easier than writing C code but can still be complicated and time-consuming. PICMG’s final piece of sample software, “The Configurator,” is now available.
The Configurator utility allows for simple firmware configuration using a graphical user interface, making data manipulation straightforward even for users who have no programming experience. Following the completion of the required information, after the necessary data is input, The Configurator exports a JSON file the Builder can use to generate firmware.
More information is available on Github, where you can also download the Configurator for free: https://github.com/PICMG/iot configurator
Configuration at Scale
The Configurator, in addition to abstracting away the more tedious technical aspects of developing smart sensor firmware, allows professional technologists to compile large libraries of configured sensors for mass deployment. This means that a factory that manufactures or uses sensors can easily and automatically convert many of them into smart sensors.
The Configurator enables this level of automation by, for example, recognizing and presenting the user with the various sensors in each sensor library that support a specific channel. The user only needs to select a logical control system (such as PID or PIV) and one of the supported sensors.
This is all that is required to generate a JSON file that defines our smart sensor. From here, a closer look at the Builder is required to convert the JSON into system-readable C firmware.
What Is A Builder and How Do I Get Started?
PICMG IoT.1-compliant firmware must be both user- and machine-readable. The Builder is the next link in the firmware development chain.
PICMG’s Configurator tool stores IoT.1-compliant data in JSON files. JSON is an excellent format for storing and exchanging human-readable data objects. However, it is not intended for machine interpretation, and the data must be presented.
What is a Builder?
A “Builder” converts JSON files into machine-readable code that is then uploaded to smart sensor hardware. PICMG does not explicitly specify a Builder as part of the IoT.x family of specifications, but they have provided reference software that demonstrates how a Builder might work.
[Editor’s Note: The reference “Builder” software is available for free download on the PICMG Github.]
The conversion process with PICMG’s example Builder is similar to Mad Libs in that a story is generated with words removed. You can create wildly different meanings depending on the words used to fill in the blanks.
When PICMG’s sample Builder receives a configured JSON file, it splits the data into two files: “config.h” and “config.c” as part of the conversion process.
“config.h” contains definitions for code blocks that can be enabled or disabled.
To complete firmware code that is unique to the configured data model and smart sensor, active “config.h” definitions are called into the main config.c file.
The only thing left is to use the microcontroller’s C compiler toolchain to compile both the config.h and config.h files (the builder is intended to work with AVR GNU Debugger, avr-gdb).
When PICMG’s sample Builder receives a configured JSON file, it splits the data into two files: “config.h” and “config.c” as part of the conversion process.
“config.h” contains definitions for code blocks that can be enabled or disabled
PICMG IoT.1-compliant firmware must be both user- and machine-readable. This article will discuss the Builder, the next link in the firmware development chain.
Next, we describe how to use PICMG’s Configurator tool to store IoT.1-compliant data in JSON files. JSON is an excellent format for storing and exchanging human-readable data objects. However, it is not intended for machine interpretation, and the data must be presented.
Ready to Build Your Own?
Are you ready to create your own interoperable smart sensor? You already have all of the necessary knowledge and tools to get started.
Just to refresh your memory, here’s a bill of materials snapshot
- Sensor – Any sensor with a datasheet will suffice.
- Microcontroller board – For the PICMG Smart Sensor Challenge, we used a Triple Ring Technologies PICMG MicroSAM board based on an 8-bit ATmega MCU.
- PICMG IoT.1 Configurator – Software that converts datasheet values into a JSON file that a builder can interpret. Download an IoT.1-compliant reference Configurator from Github (PICMG/iot configurator (github.com)) or use your own that meets the specifications.
- Builder – Vendor-specific software that accepts the JSON file from the configurator, generates firmware that the microcontroller board can read, and deploys it to the target. We created a reference builder for this demonstration, which is available on Github PICMG/iot builder
You can now make any sensor communicate with any logic device!
If you need more help, watch the video tutorial below, in which PICMG CTO Doug Sandy walks you through the entire build process in just a few minutes. Alternatively, you can visit the PICMG website to learn more or download the IoT.1 specification.