ThingSpeak IoT Blog

ThingSpeak Now Supports the Predictive Maintenance Toolbox for MATLAB


The ThingSpeak team has integrated the Predictive Maintenance Toolbox for MATLAB into the IoT Analytics features of ThingSpeak. The Predictive Maintenance Toolbox provides tools for labeling data, designing condition indicators, and estimating the remaining useful life (RUL) of a machine. You can analyze and label machine data imported from local files, cloud storage, and distributed file systems. You can also label simulated failure data generated from Simulink models.

Here is a quick list of features of the Predictive Maintenance Toolbox for MATLAB:

  • Survival, similarity, and time-series models for remaining useful life (RUL) estimation
  • Time, frequency, and time-frequency domain feature extraction methods for designing condition indicators
  • Organizing sensor data imported from local files, Amazon S3™, Windows Azure® Blob Storage, and Hadoop®Distributed File System
  • Organizing simulated machine data from Simulink® models
  • Examples of developing predictive maintenance algorithms for motors, gearboxes, batteries, and other machines

The Predictive Maintenance Toolbox is available on ThingSpeak to users that have a license to the toolbox. Just sign into ThingSpeak using your MathWorks Account and you will have access to the features of the Predictive Maintenance Toolbox with the MATLAB Analytics app. If you have any questions about the Predictive Maintenance Toolbox, contact Aditya Baru at MathWorks.

Organize Your ThingSpeak IoT Channels with Tags!


I am excited to announce a number of new features that are available to all ThingSpeak users. We added the ability for ThingSpeak channels to be organized by tags. ThingSpeak channels have a “tags” setting that allows you to enter some tags separated by a comma. I use them to organize my channels by a project identifier. In some of my projects, I need a few channels to represent the system. By tagging both channels with the same project identifier, I can see the related channels. We have added a search box to help you search by tags. You can also click on a tag within your channel list to see only the channels that match.

We also added support for tags within the ThingSpeak User API. Just pass the same tag into the API call to ThingSpeak, and you will receive a list of channels that match. This is really useful for integrating ThingSpeak into enterprise systems and for automating channel creation by deployed devices.

All of the tag-related features are available today to all ThingSpeak users!

Discussions About How to Use MATLAB and Arduino on the MATLAB Maker Community


As most of you know I love building IoT projects. Most of these maker projects use an Arduino, Particle, or Raspberry Pi, like my IR color-changing robot that connects to ThingSpeak and the CheerLights project.

I recently became the moderator of the MATLAB Maker Community that is hosted on MATLAB Central. There are many times where MATLAB and Simulink can help build a hardware-based project or be used to create the code running on a device. I also use MATLAB for analytics. Here are the most popular colors on CheerLights in the last 30 days.

The goal of the MATLAB Maker Community is to connect makers and builders together. I learn by working with others and sharing my work. If you are interested in maker project, I suggest following the Maker Community and jumping in on conversations or starting new discussions. I find this helpful if I am exploring a new idea or looking for feedback.

Right now, there is a discussion thread about how to use MATLAB to interface and interact with an Arduino. Makers can use MATLAB to control an Arduino by first installing the MATLAB® Support Package for Arduino®. Once you have the support package, you can use MATLAB to control the Arduino with familiar MATLAB commands.

% create an Arduino object
a = arduino('com3', 'uno');
% turn on an LED connected to Pin D11
writeDigitalPin(a, 'D11', 1);
% turn off an LED connected to Pin D11
writeDigitalPin(a, 'D11', 0);

Share your ideas on how to use the MATLAB connection to Arduino on the MATLAB Maker Community.

Join Us at the MIT Connected Things Conference


Join the MathWorks and ThingSpeak IoT team at the MIT Connected Things 2018 conference held at the MIT Media Lab on April 5, 2018. MathWorks is proud to be a sponsor for a second year and we are looking forward to sharing our IoT solutions. We have tools for every part of the IoT workflow — everything from edge analytics to cloud analytics.

Randy Cronk, a volunteer at the MIT Enterprise Forum of Cambridge, sits down with Eric Wetjen of MathWorks and interviews him about IoT solutions from MathWorks and our ThingSpeak IoT Analytics platform. Check out the interview on the Connected Things blog.

Learn How to Build a Condition Monitoring IoT System


Douglas Mawrey created a Smart Humidity Sensor using ThingSpeak to collect data, MATLAB to analyze the data, and IFTTT to send push notifications for certain conditions. This project uses the outdoor temperature to determine the ideal indoor humidity and inform you about the room’s comfort. The data and condition results are displayed on Douglas’ public ThingSpeak channel 418058. This project is a good starting point to see the power of the MATLAB integration on ThingSpeak and how to perform real-time condition monitoring.

Setting up the Sensor

This project uses the ESP-based NodeMCU as an IoT gateway to forward sensor data to ThingSpeak. The NodeMCU is essentially a microcontroller and a Wi-Fi device that costs less than $10 US. The humidity sensor that is used in this project is the DHT11. This a very common sensor used to monitor temperature and humidity. The sensor either comes in a 4 pin or 3 pin package. The NodeMCU is programmed with the Arduino IDE using the code in Douglas’ tutorial or GitHub.

Using ThingSpeak Metadata

Douglas uses the metadata setting within a ThingSpeak channel to store condition ranges. This allows you to adjust settings in your online analytics code without redeploying new code. Each ThingSpeak channel has a metadata setting. You can store arbitrary text data that can be used in your MATLAB Analysis code. To load your channel’s metadata into MATLAB, use the webread function and add metadata=true to the ThingSpeak API Read Data request.

indoorChannelData = webread(strcat('https://api.thingspeak.com/channels/', ...
                                    num2str(indoorChannelID), ...
                                    '/feeds.json?metadata=true&api_key=', ...
                                    indoorChannelReadKey));

Using MATLAB for Condition Monitoring

Douglas uses MATLAB on ThingSpeak to determine the proper condition. This is a common requirement in complex IoT systems. This example could be a good starting point for building a condition monitoring system for industrial maintenance applications. You use MATLAB to determine the target humidity using a polynomial fit over the lookup data.

lookupFit = polyfit(humidityLookup(:, 1), humidityLookup(:, 2), length(humidityLookup) - 1);
optimalHumidity = polyval(lookupFit, curTempOut);

humidityDiff = curHumidity - optimalHumidity;

Using IFTTT for Alerts

Often you want to get notifications when a certain condition is met. Douglas shows you how to use IFTTT to send push notification directly to your phone. In this project, MATLAB is determining the condition and then interfaces with the IFTTT API to send the push notification. To send push notifications via IFTTT, use the webwrite function in MATLAB.

webwrite(strcat('https://maker.ifttt.com/trigger/', makerEvent, ...
                '/with/key/', makerKey), ...
                'value1', stateMsg, ...
                'value2', char(timeSinceChange, 'hh:mm'));

All of the MATLAB code can be deployed on ThingSpeak and scheduled to be executed periodically without having this on your desktop computer. The complete Smart Humidity Sensor project tutorial is available on Hackster.io. Feel free to discuss on the MATLAB Maker Community.