ThingSpeak IoT Blog

One Million ThingSpeak Channels!


Christopher Stapels, the product marketing manager for ThingSpeak, told me that we crossed ONE MILLION CHANNELS of IoT data on ThingSpeak. We have come along way over the years. The first channel that we created got the Channel ID of 1. We deleted the channel to test if the channel deletion feature works. Then, we created a second channel, sent data to it, cleared it, and deleted it. The oldest active ThingSpeak channel is Channel 3. It’s still collecting weather data from my parent’s house after 10 years. I never expected to see seven-digit channel ID numbers, like Channel 1018612 based in Oslo, Norway.

Thanks to all of our users who keep collecting data, adding devices, and analyzing data on ThingSpeak! This is a huge milestone for all of us and you are making an impact on IoT all around the world.

To commemorate one million channels, Christopher saved the number of channels at the beginning of each year to an array and used MATLAB to fit a power function to the data. You can do this using a MATLAB Visualization in ThingSpeak. The fit parameters are a = 1693 and b=2.277 for the model shown here.

According to a Business insider article, there will be 25 billion IoT devices by 2025. If the present rate continues, at least .1% of those devices can be on ThingSpeak by 2024 when we reach 2.5 million channels!

Here’s some MATLAB code to generate this plot and estimate the number of the ThingSpeak channels in the future.

% Gather data
dates=2015:2020;
absYears=dates-2014;
numChan=[22155,75957,208835,394780,666479,1000000];

% Plot the data
plot(dates,numChan,'r*-','linewidth',3);
xlabel('time');ylabel('Number of Channels');title('1 Million Channels!');
[xData, yData] = prepareCurveData( absYears, numChan );

% Set up fittype and options
ft = fittype( 'power1' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';

% Fit model to data
[fitresult, gof] = fit( xData, yData, ft, opts );
hold;
extendRange = 2015:2025;
plot(extendRange,fitresult(extendRange-2014),'r--');
yline(2.5e6,'b','LineWidth',3);

We wanted to thank you again. We look forward to the next million channels and supporting your IoT journey. Let us know in the comments what you are doing or planning to do with ThingSpeak and what functionality that will help you along the way.

Send Email Alerts from ThingSpeak


For this post, I would like to introduce Christopher Stapels as our guest blogger. Christopher builds lots of cool IoT projects and is omnipresent on MATLAB Central and ThingSpeak and MATLAB questions. He is also the product marketing manager for ThingSpeak and MATLAB hardware here at MathWorks. Welcome to the team!

ThingSpeak has added an alerts API to let you to send emails from your ThingSpeak account. Let me say that again… ThingSpeak now offers email alerts!

Use the new alerts API key to trigger emails and check the sent email history using MATLAB code or another HTTP client.  With MATLAB code in ThingSpeak, you can read and analyze channel values and then respond with an email.  You can even add information in the email about the condition that triggered the email.

My Thirsty Plant

Until recently, you needed a third-party service to get email notifications sent about your ThingSpeak channels.  New in 2020, you can now get email alerts sent to you directly from ThingSpeak.

Regular visitors to the public channel 276330 will be familiar with my desk plant.  I have a soil monitor probe set up to measure the conductivity of the soul, and my plant will send me email if it needs refreshment. I can now have the email set directly from ThingSpeak.  The easiest way is to use a MATLAB analysis.  Here is the general format for sending an email.

Make a MATLAB Analysis to Send Email

  1. First get your ThingSpeak Alerts API key from the Account > My Profile The alerts API key will start with ‘TAK’.
  2. Create a new MATLAB analysis at Apps > MATLAB Analysis. Click the New button on the top. Choose the blank template and with this code.
    alert_body = 'This is the text that will be emailed';
    alert_subject = 'This will be the subject of the email';
    alert_api_key = 'YOUR_API_KEY_FROM_STEP_1';
    alert_url= "https://api.thingspeak.com/alerts/send";
    jsonmessage = sprintf(['{"subject": "%s", "body": "%s"}'], alert_subject,alert_body);
    options = weboptions("HeaderFields", {'Thingspeak-Alerts-API-Key', alert_api_key; 'Content-Type','application/json'});
    result = webwrite(alert_url, jsonmessage, options);
  3. Adjust the alert body, subject and API key.
  4. Click save and Run and you will receive an email within a few moments.
  5. Connect the MATLAB Analysis to a TimeControl or React that depends an a channel value you are interested in.

You can see a more detailed example at Analyze Channel Data to Send Email Notification.  There is even a new template for email alerts in the MATLAB analysis app. You can see all the information on how to send an alert or get your alerts history in the documentation.

Let us know what you think!

Collect and Visualize Agricultural Data using The Things Network and ThingSpeak


Long-range wireless communication technology enables the transfer of sensor data over a long distance while using low-power radios for connectivity. This technology can be leveraged to connect sensors covering a large geographic area and give you insights into what is happening. With agricultural applications it is important to measure the soil moisture and efficiently irrigate. A big challenge for agricultural applications is robust connectivity in remote locations. By using a combination of The Things Network and ThingSpeak insightful applications can be built. The Things Network is a protocol and infrastructure that provides a link to cloud applications using LoRaWAN® technology. If you are already a The Things Network user, check out the documentation about the ThingSpeak integration at The Things Network. ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud using MATLAB®. You can send data to ThingSpeak from devices via The Things Network, create instant visualization of live data, and send alerts.

The ThingSpeak team has created a new example that shows you how to leverage The Things Network and build an agricultural data application using ThingSpeak. The sensors send data to The Things Network, which is then forwarded to ThingSpeak for collection, analysis, and visualization. Here’s what the project view on ThingSpeak looks like.

To build a soil moisture sensor device for The Things Network, you need use an Adafruit Feather M0 RFM95 LoRa Radio (900MHz), an Adafruit Ultimate GPS FeatherWing, a SparkFun Soil Moisture Sensor, and a DHT22 temperature and humidity sensor. Once you have the device put together and programmed, you can use this device to measure soil moisture, temperature, humidity, and its location.

Check out the full Collect Agricultural Data over The Things Network example at the MathWorks Documentation site.

Analyze and Visualize Air Quality Data with MATLAB


Have you ever wondered if the air around you is healthy? It is possible to understand air quality by using MATLAB to analyze air quality data collected by an air quality sensor on  ThingSpeak.

What is “healthy” air quality?

Good or moderate air quality is when the Air Quality Index (AQI) is 100 or less. AQI is a relative measurement of five common air pollutants: ground-level ozone, particle pollution, carbon monoxide, sulfur dioxide, and nitrogen dioxide. A high AQI indicates a higher level of pollution and is considered unhealthy over 100.

Air Quality Sensors

We have installed a PurpleAir sensor at the MathWorks Apple Hill campus in Natick, MA. PurpleAir sensors use laser particle counters that provide an accurate and low-cost way to measure smoke, dust, and other particulate in the air. The data from our air quality sensor is available on a public ThingSpeak channel.

PurpleAir produces an interactive map using the air quality data from their sensors deployed around the world. Among other applications, the data is used by researchers to understand the effects of forest fires on air quality.

Air Quality Analysis using MATLAB

On File Exchange, we have posted our MATLAB functions used to analyze the air quality data collected by ThingSpeak. The MATLAB code helps preprocess the sensor data, provides functions to classify the data, and provides functions for visualizing the processed air quality data. The MATLAB visualizations are added to a ThingSpeak channel dashboard so you can see the current air quality near you. The MATLAB analysis code calculates the AQI using the definitions from the United States Environmental Protection Agency (EPA).

You can build a data analysis dashboard on ThingSpeak using publicly available data and MATLAB. This project it makes it easy to explore IoT data analysis using MATLAB to preprocess and visualize data without having IoT hardware.

Download the code from File Exchange and follow along with our video tutorial.

Predictive Maintenance: From Development to IoT Deployment


Interest in predictive maintenance is increasing as more and more companies see it as a key application for data analytics that leverages IoT systems. Branko Dijkstra, a technical consultant at MathWorks, held a talk at the MATLAB Conference and covers the development of predictive maintenance algorithms, as well as their deployment on the two main nodes of IoT systems—the edge and the cloud.

What do you expect from predictive maintenance?

  • Maintenance cares about day-to-day operations – Reduced downtime
  • Operations and IT look at the bigger picture – Improved operating efficiency
  • Engineering groups get product feedback – Better customer experience
  • Upper management wants to drive growth – New revenue streams

Why MATLAB and Simulink for predictive maintenance?

  • Get started quickly
  • Reduce the amount of data you need to store and transmit
  • Deliver the results of your analytics based on your audience
  • Create training data for your algorithm in the absence of real failure data

You can watch Branko’s full talk and download related resources from MathWorks Videos and Webinars.