MATLAB Toolboxes are Now Available on ThingSpeak for IoT Analytics

ThingSpeak offers an easy way to collect data from things, analyze and visualize the data with MATLAB, and act on your data. With MATLAB from MathWorks, you have access to powerful data processing and analysis functions for IoT data. To extend the functionality, we offer toolboxes such as the Statistics and Machine Learning Toolbox™ and Signal Processing Toolbox™. These toolboxes need a license from MathWorks. If you have access to these toolboxes linked to a MathWorks Account, you have access to many of the toolboxes on ThingSpeak. All you have to do is to log in to ThingSpeak using your MathWorks Account credentials. With very little code, it is possible to forecast tidal depths using tide data collected by a ThingSpeak channel and the System Identification Toolbox.

Tide forecasting using MATLAB and ThingSpeak

When you are logged into ThingSpeak using your MathWorks Account, you can use functions from the following toolboxes if you are licensed to use them:

We have created many examples showing you how to use MATLAB Toolboxes using ThingSpeak channel data. We have an example using the Signal Processing Toolbox to Visualize and Remove Outliers in Your Data which a common task when you are working with IoT data from sensors. If you want to forecast environmental data by using a feedforward neural network, we have an example using the Neural Network Toolbox operating on weather station data collected by ThingSpeak. In all of our examples, you are able to use the code right on ThingSpeak and allow it to run on a schedule using TimeControl or be triggered to run using React. Many of your licensed toolboxes are now available with your MathWorks Account on ThingSpeak.

Introducing MATLAB Central…

We launched MATLAB Analysis and Visualizations on ThingSpeak last year and have noticed a sharp increase in IoT analytics being used in your projects. We are seeing everything from analyzing squirrel behaviour to analyzing traffic patterns. As we are all learning how to use MATLAB in our IoT projects, we need to take notice of MATLAB Central.

MATLAB Central - ThingSpeak Community

MATLAB Central is “a place where you can get answers.” We have over 100,000 community members and MathWorks employees all sharing projects and files, experience, and answering questions. And, ThingSpeak is showing up on MATLAB Answers and File Exchange. This is great news for the ThingSpeak Community. If you already have a MathWorks user account and use it on ThingSpeak, you already have access to MATLAB Central. All you have to do is sign in. If you are new to MathWorks, you can sign up for a free user account to gain access to MATLAB Central and other features of ThingSpeak.

Check out Ned Gulley’s post, “Going Way Back with MATLAB Central” to learn about how the MATLAB community has formed over the years.

Cheers to MATLAB Central hitting the 15th year mark! We are happy to be a part of the story.

Analyzing Squirrel Behaviour and Weather Forecasting with MATLAB and ThingSpeak

Lord Kelvin said, “If you can not measure it, you can not improve it.” In Carsten’s project, he built a squirrel feeder complete with sensors and a camera. The “Squirrel Cafe” allows squirrels to lift a cover and take a peanut. When that happens, data gets collected and the feeder tweets its data summary with a photo. Carsten is learning a lot about the behaviours of the squirrels and is also trying to forecast the coming winter based on how many nuts are being taken. Behind-the-scenes, he is using Raspberry Pi, ThingSpeak, and MATLAB.

Squirrel Monitoring

The Squirrel Cafe is connected to the ThingSpeak IoT Analytics platform using the Raspberry Pi. The Raspberry Pi collects data from a tilt sensor, temperature sensor, and a camera to determine how many nuts the squirrels are taking. Whenever the lid opens, the current temperature gets measured by the DS18B20 sensor and sent to ThingSpeak for storage and analysis using MATLAB.

Squirrel Cafe System

Carsten is also testing a theory. He noticed through observation that there might be a correlation between the number of nuts that get taken from the feeder and how long the coming winter season will be. This winter forecast and “nuts per minute” calculations are being performed by ThingSpeak’s MATLAB Analysis app. We are excited to see what the results prove in the next few years.

For full project details and source code, visit Carsten’s website for this project at


Prototyping IoT Analytics with MATLAB and ThingSpeak

Rob Purser, our Senior Development Manager for IoT, will be holding a hands-on workshop at this year’s IoT Evolution in Las Vegas. Rob will teach the attendees how to prototype IoT analytics using MATLAB and the IoT platform, ThingSpeak.

IoT Evolution - Internet of Things Conference

The Internet of Things typically involves a discussion of smart devices and the cloud, with much less attention paid to the data collection, pre-processing of acquired data, and development of real-time analytics algorithms. A successful data analytics strategy involves embedded sensor analytics, historical data analysis, and online analytics. In this hands-on session, each participant will work with devices and try out the various types of analytics in action.

IoT Evolution West 2016

Caesars Palace, Las Vegas
900 Convention Center Blvd
New Orleans, LA

IOTD-02: Prototyping IoT Analytics: Hands on with ThingSpeak and MATLAB
Tuesday, July 12, 2016 at 2PM
Forum 15

Weather Station with Particle, SparkFun, ThingSpeak, and MATLAB

[Haodong Liang] has released a weather station project with full MATLAB data analysis, device source code, and procedures on He used the Particle Electron to connect the SparkFun weather station to ThingSpeak anywhere covered by a 2G/3G cellular data network. The project demonstrates how to build your own and start exploring data collected by ThingSpeak with MATLAB.

MathWorks Weather Station

The project also shows you how to use MATLAB to get very detailed visualizations and data analysis of the data collected by the weather station. Some of the examples include histograms of temperature, humidity, and pressure, curve fitting, daily comparisons, and 3D plots of temperature.

MATLAB weather station temperature plot

Visit for the complete tutorial to build your own weather station, connect it to the internet with the Particle Photon, collect your data with ThingSpeak, and do data analysis with MATLAB.


Explore your IoT data with ThingSpeak and MATLAB

Loren Shure, a blogger at MATLAB Central, has written a new blog post about Eric Wetjen’s Counting Cars and Analyzing Traffic project. Eric uses a Raspberry Pi and webcam to capture traffic data outside of the MathWorks headquarters in Natick, MA. All of the traffic data is stored on a public ThingSpeak channel, so you will be able to use it to learn data analysis with the built-in MATLAB Analysis and Visualizations apps in ThingSpeak. (more…)

Updates to the MATLAB Analysis App with Lots of Example Code

When using the MATLAB Analysis app on ThingSpeak, the MATLAB function to represent date and time (datetime) allows you to represent points in time. You can also use datetime(‘now’)datetime(‘today’), datetime(‘yesterday’), or datetime(‘tomorrow’) to create scalar datetimes at or around the current moment. Check out our documentation for more information about the datetime function.

On ThingSpeak, so far, the datetime function returned time set to UTC time zone by default. Starting at 10 am (EDT) on September 10th 2015, the datetime function will return date and time set to your account time zone (at This will allow you to read data from your channel with timestamps zoned to your local time zone instead of UTC.

For example, my account time zone is set to Eastern Time (US & Canada), and when I ran the following MATLAB code at 12:23 pm, I received:

dt = datetime('now')
dt =
     10-Sep-2015 12:23:35

Prior to this change, I would have received:

dt =
     10-Sep-2015 16:23:35

As you can see, the timestamp is 4 hours ahead of my time zone, which was due to MATLAB returning time in UTC.

This change makes it easier for you to perform time related activities in your time zone. Note that this new feature is available for both thingSpeakRead and thingSpeakWrite functions as well. As an example, consider the following request to read data from the MathWorks Weather Channel:


[data, timestamp] = thingSpeakRead(12397);
display(timestamp.TimeZone, 'TimeZone');


data =
     225.0000    3.8000   43.9000   95.8000
     0   29.9800    4.3000    0.0300
timestamp =
     10-Sep-2015 16:13:54
TimeZone =

With this enhancement, you would no longer have to explicitly specify the time zone of your dates and time to read and write data in your time zone.

Here are a few other examples:

  1. Read data corresponding to one entire day in your timezone:
startDateTime = datetime('September 10, 2015 00:00:00')
endDateTime = datetime('September 10, 2015 23:59:59')
readChannelID = 12397;
[data, timeStamps] = thingSpeakRead(readChannelID, 'DateRange', [startDateTime, endDateTime])
  1. Read data between certain hours of a day (between 7 am and 9 pm):
startDateTime = datetime('September 10, 2015 07:00:00')
endDateTime = datetime('September 10, 2015 21:00:00')
readChannelID = 12397;
[data, timeStamps] = thingSpeakRead(readChannelID, 'DateRange', [startDateTime, endDateTime])
  1. Generate a MATLAB plot in your local time zone:
[data, timeStamps] = thingSpeakRead(12397, 'Fields', 3, 'NumPoints', 10);
plot(timeStamps, data)

Note that, if at present, you are explicitly setting the time zone to your local time zone, you might see unexpected behavior in your code. Here are a few examples, based on support requests we have received:

  1. If you are using datetime function in your code similar to the example below:
% Set the time now to variable dt
dt = datetime('now')
% Assign time zone to UTC since the dt is unzoned by default
dt.TimeZone = 'UTC';
% Convert the timestamp to ‘America/New_York’
dt.TimeZone = 'America/New_York'

To fix this, remove the “TimeZone” assignments since time is now returned in your time zone by default, and use the code below:

% Set the time now to variable dt
dt = datetime('now')
  1. If you are setting the time zone of data returned by thingSpeakRead to your zone:
% Read data from a channel
[data, timeStamps] = thingSpeakRead(12397);
% Set the timezone to match your zone
timeStamps.TimeZone = 'America/New_York';

To fix this, remove the line with the “TimeZone” assignment, and use the code below:

% Read data from a channel
[data, timeStamps] = thingSpeakRead(12397);

For more information about the datetime function refer to the MATLAB documentation. If you need support, use the MATLAB section of the ThingSpeak Forum.

You’ve Collected Lots of IoT Data, Now We Can Help You Figure Out What It Means!

For the last several years, I have been collecting data with ThingSpeak from devices all around my house. I have been tracking temperature, humidity, light levels, outside weather data, my deep freezer’s temperature, the state of My Toaster, and air quality metrics. I just recently started to think about what all of this data really means to me and if it’s good data to begin with. Wouldn’t it be great if I could explore my data in ThingSpeak?  Well, I am happy to say that with the latest upgrade to ThingSpeak, you can do just that.

We have been working with the MATLAB team at MathWorks to provide two new ThingSpeak Apps: MATLAB Analysis and MATLAB Visualizations. With these new built-in Apps, the ThingSpeak web service can automatically run MATLAB code. That makes it easier to gain insight into your data.

ThingSpeak MATLAB Apps

With the MATLAB Analysis app, I am now able to turn my home’s temperature and humidity data into dew point. Dew point is important to find out if the environment is comfortable independent of just knowing the temperature alone. If the dew point is too high or too low, your guests may notice their glasses sweating or that they are uncomfortable.

I am also able to clean up my sensor data and filter out bad data and write it back to a new ThingSpeak channel. From time to time, I see one of my sensors report a really high value, and I’d like to have a way to fix it.

We have provided many MATLAB code examples to get started quickly.

Some of our analysis examples include:

  • Calculate Average Humidity
  • Calculate Dew point
  • Convert Celsius to Fahrenheit
  • Eliminate data outliers
  • Convert Fahrenheit to Celsius
  • Calculate hourly max temperature
  • Replace missing values in data

With MATLAB Visualizations, we made it way easier to chart data from multiple data fields. By selecting the “Wind Velocity” example MATLAB Visualization, I can see a plot of the wind velocity data collected by my weather station.

MATLAB Plot Output on ThingSpeak

Other visualization examples include:

  • View temperature variation over the last 24 hours using a histogram
  • Plot wind velocity over the last hour using a compass plot
  • Understand relative temperature variation
  • Plot data from multiple fields
  • View temperature and pressure levels
  • Visualize relationship between temperature and humidity

Are you looking for an easy way to connect your Arduino or Raspberry Pi devices to ThingSpeak? We have also been working with the MATLAB team at MathWorks on some Hardware Support Packages to help with that. I’ll talk about that in a future blog!

This is really big news for the ThingSpeak Community. I am really excited to see what you do with these new apps. I will share projects on the blog as they come in. Let’s find out together what all of this data means. Get started at!