Blog Post

Applying Embedded Machine Learning to Temperature Monitoring in Cold Chain Applications

TinyML, Machine Learning, Embedded Devices

Zin Thein Kyaw

February 2, 2021

Read the Introduction  sectionIntroduction
 

In this blog, we show how to use Edge Impulse for deploying embedded Machine Learning (ML) on low-power sensors that measure really anything one can imagine. However, we start with temperature measurement as the baseline with a Proof-of-Concept (PoC) demo and explore how putting more intelligence on these sensors results in new paradigms for embedded development and systems design using a data driven approach vs. traditional techniques such as simple threshold checking. 

Previously, an embedded developer would need to be a Machine Learning expert and/or have a PhD in Data Science, use disparate tools to deploy intelligence at the edge, and the barrier to entry would be very high.

Edge Impulse provides an easy-to-use, end-to-end platform for:

  • Easily ingesting sensor data as inputs into an embedded ML model
  • Efficiently creating an embedded ML model optimized for memory size and power consumption (battery life)
  • Easily deploying the model on a target sensor using the Edge Impulse SDK and your development environment of choice

Now let’s explore how we can put Edge Impulse to great use for Cold Chain Monitoring applications as an example of a specific vertical that could fully benefit from more intelligence at the edge.

Read the Cold Chain Monitoring Applications section
Cold Chain Monitoring Applications


Cold Chain Monitoring is a multi-billion-dollar market that spans across many industries such as transportation and logistics, grocery retail, and smart agriculture. One of the key sensing metrics that makes applications in this space successful is the monitoring of environment temperature where perishable products are produced, processed, packaged, stored, transported, and sold.

Continuous monitoring of environment temperature is important for cold chain management as the environment temperature for perishable products cannot exceed certain temperature thresholds for too long. Otherwise, there will be terrible waste of products such as food or even vaccines in this day and age of COVID-19, not to mention the economic downsides of such product loss.

Figure 1. The Supply Chain

Read the Go Beyond Traditional Techniques sectionGo Beyond Traditional Techniques


Traditionally, measurement samples are continuously sent to the cloud where analysis is performed to gain insights (this is where most of the rules logic sits today) as to whether the environment temperature becomes abnormal. This traditional technique runs into challenges when the cloud connection is bandwidth constrained or even not available and/or sensors are power consumption constrained. Additionally, the power management profile of the radio transmit/receive cycle is much more costly in terms of power consumption than it is to wake up periodically to sample the data. Being able to send only what is insightful can further empower ultra-battery constrained or energy harvesting sensors that could not have been achieved before. Could the true potential of IoT be unlocked when edge sensors and the cloud truly work in concert?  

Edge Impulse solves these challenges by providing an end-to-end platform for deploying intelligent embedded ML on low-power temperature sensors. We allow you to put the intelligence (or rules logic) back at the source of the data so that the device can make real-time decisions, cut down the round-trip latency that is incurred by sensor to cloud interactions, and send only what is necessary to trigger a response by the system owner, such as when a freezer door is left open for too long.

Read the Example Use Case: Freezer Temperature Monitoring sectionExample Use Case: Freezer Temperature Monitoring


Freezer Temperature monitoring is an important use case to ensure that perishable products that need to be frozen are stored at the right temperature.

The following PoC demo configuration was used but could be easily ported to other embedded targets:

  • ESP32 DevKitC board
  • Adafruit MAX31855 Thermocouple board
  • K-Type Industrial Thermocouple probe
  • Embedded firmware compiled using Arduino IDE, including Edge Impulse SDK

The public Edge Impulse project is available at: https://studio.edgeimpulse.com/studio/16389/ so one can look at the data sets as well as how the anomaly detection model was trained. The embedded project is available at: https://github.com/edgeyoda/esp32_temperature

Figure 2. PoC Demo Configuration
Figure 3. Freezer Anomaly Detector Deployment

With Edge Impulse, an anomaly detection embedded ML model was easily created using the temperature profile of the sensor minutes after the freezer door has been opened or closed. This allows one to detect if the freezer door has been left opened or closed and also obtain a relative indication for how long this state has been in occurrence via an “anomaly score”; something that would have never been possible without more complex rules logic instituted in the sensor’s firmware (think one too many if/else statement blocks). We also potentially removed the need for a separate door sensor!

One of the methods of gathering data for training the anomaly detection model is by using the “data forwarder” tool (https://docs.edgeimpulse.com/docs/cli-data-forwarder)  that is part of Edge Impulse’s Command Line Interface (or CLI). The data forwarder creates a secure web connection between your host PC, the sensor, and Edge Impulse’s platform to collect live sensor data, which can then be used to train your embedded ML model.

The Edge Impulse Studio also allows you to visualize what part of your temperature profile is important, such as the critical temperature ranges that start to represent “danger zones”. For example, did you know that this is what your typical home freezer looks like 1 minute after you open the freezer door?

Figure 4. Temperature Profile 1 Minute After Freezer Door Opens

How about 1 minute before it hits optimal storage conditions?

Figure 5. Temperature Profile of Freezer 1 Minute before Optimal Storage Conditions

We used these temperature transition ranges where important knowledge about the system can be extracted to build our embedded ML model using K-Means Clustering and detect outliers in our data, which we label as “anomalies”. The figures below show the test data set (1 minute after opening the freezer door) vs. the established model. The “further away” the test data set is from the closest cluster, the higher the anomaly score.

Figure 6. 3D View of Test Data Set vs. Trained Model
Figure 7. Anomaly Explorer View (For Each Test Data Set)

Read the Test Results Against Edge Impulse Model sectionTest Results Against Edge Impulse Model


Here we show the test results against the Edge Impulse model for the 5 mins after the freezer down was opened, and then again for the 5 mins after the freezer door was closed. We can see that the anomaly score increases or decreases accordingly, allowing us to perform some simple logic using the anomaly score to alert any party that is interested in detecting this event.

Figure 6. Anomaly Score Rises as Freezer Door is Open for Longer
Figure 7. Anomaly Score Decreases as Freezer Door is Closed for Longer

Read the Summary sectionSummary


This blog has shown how easy it is to use Edge Impulse to deploy an anomaly detector for temperature sensing enterprise applications such as Cold Chain Monitoring using embedded ML. This will open the door to application use cases that haven’t yet been envisioned and realize efficiencies in our systems that would never have been possible by taking advantage of advanced computing power already available on these edge devices. This will in turn result in overall reduction in complexity of the system design as well as overall cost of ownership.

In future blog articles we are interested in showing how to:

  • Connect these sensors to the cloud to relay anomaly detection events
  • Expand sensing to humidity, ambient light, and others to implement sensor fusion
  • Utilize anomaly detection in combination with other neural network blocks such as regression (for predictions)
  • Realize this on other target platforms

We look forward to your feedback and seeing how you plan to use Edge Impulse for your next measurement and sensing project, or the next time you decide to push an OTA firmware update. 😉

 

Zin Thein Kyaw is a Senior User Success Engineer at Edge Impulse and loves all things embedded and IoT.

 

 

 

 

[Thumbnail graphic courtesy of The Courier]
[Supply chain graphic courtesy of The Cold Chain Federation]

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter