Smart Devices and Analytics Spur Innovation in the Internet of Things
By Eric Wetjen, MathWorks
The Internet of Things (IoT) is a rapidly evolving space in which virtually any smart hardware device—a mobile phone, a pacemaker, a wearable fitness sensor, even a refrigerator—can be connected to the internet to generate and receive data.
Combining internet-connected devices with cloud computing, machine learning, and other data analytics approaches is enabling products and solutions that are transforming the way we live and work. Today, for example, thanks to the Internet of Things:
- A doctor can remotely monitor how often a patient’s pacemaker fires.
- Athletes can measure how many calories they burn during a run.
- Farmers can optimize irrigation of crops.
- Building managers can save electricity by optimizing controls for HVAC equipment.
- Asthma sufferers can manage their condition by using a mobile phone app to monitor their wheezing levels.
- Automakers are close to developing a driverless car capable of autonomously navigating through city streets.
Inside an IoT System
A typical IoT system works like this (Figure 1):
- A smart connected device produces sensor data and ultimately sends data to the cloud. These devices are often smart enough to run data-reduction algorithms on their embedded processors.
- An analytic IoT platform processes and stores the sensor data. It may integrate information from other sources, such as business systems. It analyzes and takes action on the incoming data.
- A systems engineer or data scientist accesses the historical data from the cloud or the device and develops algorithms to preprocess and analyze it. These algorithms may involve machine learning techniques for predicting future values of a sensor quantity or for classifying the sensor data.
- The algorithm is deployed in the cloud or on a smart device, where it operates on incoming live data.
Creating an IoT System with MATLAB and Simulink
MATLAB® and Simulink® support IoT systems by helping you develop and test smart connected devices, access and collect data in the cloud, and analyze sensor data. Let’s look at two examples.
Example 1. A Traffic Monitor
Tired of sitting in traffic every time they drove home from work, two engineers decided to study traffic flow trends on the busy highway outside their building. They installed a webcam in an office overlooking the highway and connected it to a Raspberry Pi™ board running a computer vision algorithm (Figure 2).
The data was collected in the cloud using ThingSpeak™, an analytic IoT platform that can run MATLAB code.
They built a Simulink block diagram that included a Median Filter block to clean up the image and a Blob Analysis block to identify cars in the image (Figure 3). They then wrote a custom block to count the cars, and sent the summary data to ThingSpeak.
Before deploying the algorithm to the Raspberry Pi, they verified it using the video display in Simulink external mode (Figure 4).
Once the data was in ThingSpeak, they used the MATLAB app integrated into ThingSpeak to create live visualizations of the traffic density in each direction for the previous 48 hours. These include a color-coded visualization (Figure 5) that categorizes the current state of the traffic (light = green, moderate = yellow, and heavy = red).
Example 2. A Tide Gauge and Alert System
Getting your boat stuck in the mud is a distinct possibility without an accurate measure of water depth. Because tide predictions and real-time water levels are not available for most bays and estuaries, one boater and MATLAB user built a low-cost, real-time tide gauge. He quickly learned that the timing and amplitude of tide levels
The key hardware components he used were an Arduino® Mega board, a SparkFun Electronics® cellular shield, and an ultrasonic range finder. The cellular shield provided the connection from the Arduino to the internet. The Arduino was used to read the data from the ultrasonic sensor.
ThingSpeak was used to collect and process the data in the cloud. The ultrasonic sensor reports distance in mm. To convert from distance to water depth, the boater set up a ThingSpeak TimeControl that runs MATLAB code to read the range data, convert it into water depth, and write the data to a new ThingSpeak channel. The result was an internet-connected tide gauge that can be viewed on a mobile phone or a web browser (Figure 6).
The boater set up additional MATLAB code to detect tidal thresholds. He then used the Twitter integration in ThingSpeak to send alerts when particular conditions were met.
As these examples show, analytics is a vital ingredient of the innovations occurring in IoT. With MATLAB and Simulink you can develop analytics that run on your smart devices or in the cloud. With ThingSpeak, you can easily collect data from your devices in the cloud. You can then use MATLAB to gain insight into the sensor data you have collected.
Published 2016 - 93055v00