MATLAB – Internet of Things https://blogs.mathworks.com/iot Hans Scharler is an Internet of Things pioneer. He writes about IoT and ThingSpeak IoT platform features. Tue, 31 Mar 2026 22:45:55 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 Professor at Arizona State Uses MATLAB and ThingSpeak to Introduce Students to AI and IoT https://blogs.mathworks.com/iot/2022/11/21/professor-at-arizona-state-uses-matlab-and-thingspeak-to-introduce-students-to-ai-and-iot/?s_tid=feedtopost https://blogs.mathworks.com/iot/2022/11/21/professor-at-arizona-state-uses-matlab-and-thingspeak-to-introduce-students-to-ai-and-iot/#respond Mon, 21 Nov 2022 21:44:09 +0000 https://blogs.mathworks.com/iot/?p=3138

Professor Chao Wang at Arizona State University recently introduced a course on AI and IoT to first-year engineering students. Deep learning in MATLAB is used to classify images and send the results... read more >>

]]>
Professor Chao Wang at Arizona State University recently introduced a course on AI and IoT to first-year engineering students. Deep learning in MATLAB is used to classify images and send the results to ThingSpeak in the cloud. ThingSpeak allows the class to aggregate the results and compare their work in real time.

Read the article here:

Introducing Deep Learning and IoT to First-Year Engineering Students with MATLAB

l

]]>
https://blogs.mathworks.com/iot/2022/11/21/professor-at-arizona-state-uses-matlab-and-thingspeak-to-introduce-students-to-ai-and-iot/feed/ 0
Top ThingSpeak IoT Questions from Google https://blogs.mathworks.com/iot/2021/05/07/top-thingspeak-iot-questions-from-google/?s_tid=feedtopost https://blogs.mathworks.com/iot/2021/05/07/top-thingspeak-iot-questions-from-google/#comments Fri, 07 May 2021 16:36:37 +0000 https://blogs.mathworks.com/iot/?p=2806

We were searching around for ThingSpeak IoT resources and noticed that Google was sharing the top questions related to ThingSpeak. Christopher Stapels and I thought that it would be fun to answer... read more >>

]]>
We were searching around for ThingSpeak IoT resources and noticed that Google was sharing the top questions related to ThingSpeak. Christopher Stapels and I thought that it would be fun to answer them and share them as a blog post. So, here we are.

How do you use ThingSpeak?

Some people use ThingSpeak for monitoring machine processes. This allows them to share the data with potential customers and ensure the process is within control. There are over a million ThingSpeak channels representing a vast assortment of projects.  Some projects measure the temperature and humidity in one room, some projects include a global network of air quality monitors. You can send data to ThingSpeak from your devices, create instant visualization of live data, and send alerts.

What type of data is accepted by ThingSpeak?

ThingSpeak accepts strings, integers, decimal degrees, and any encoded data. ThingSpeak stores data as strings of up to 255 characters per field. ThingSpeak organizes data by channels, where a channel represents data from a given device or process. Each channel contains eight data fields, three fields for location: latitude, longitude, and elevation, and one extra field for a status report.  If you write a number into a field (integer or float), ThingSpeak will display the numbers in field charts on your channel view.

Is ThingSpeak free?

Yes, for non-commercial use. ThingSpeak has different license types for different intended uses. The free license has some restrictions. Purchasing a paid license allows a faster update rate and the creation of additional channels.  For more info, see How to Buy and the ThingSpeak FAQ.

How do you collect data from ThingSpeak?

Once your data is stored in ThingSpeak, you can retrieve your data from ThingSpeak from MATLAB, a REST API, or MQTT API.

Many devices can take advantage of the ThingSpeak library for Arduino and Particle devices. You can use the address bar in your web browser to test updating a channel via the REST API.

Use this format to update your field.

https://api.thingspeak.com/update?api_key=<YOUR_API KEY>&field1=<YOUR_VALUE>

If you have any questions for Christopher, myself, or the rest of the community, ask them at the ThingSpeak Community site.

]]>
https://blogs.mathworks.com/iot/2021/05/07/top-thingspeak-iot-questions-from-google/feed/ 5
Explore ThingSpeak IoT Data Using a MATLAB App https://blogs.mathworks.com/iot/2020/09/21/explore-thingspeak-iot-data-using-a-matlab-app/?s_tid=feedtopost https://blogs.mathworks.com/iot/2020/09/21/explore-thingspeak-iot-data-using-a-matlab-app/#respond Mon, 21 Sep 2020 16:19:30 +0000 https://blogs.mathworks.com/iot/?p=2737

ThingSpeak users frequently ask how to build customized views for their ThingSpeak data. The channel view provides automatically generated field plots that are customizable with the ThingSpeak Charts... read more >>

]]>
ThingSpeak users frequently ask how to build customized views for their ThingSpeak data. The channel view provides automatically generated field plots that are customizable with the ThingSpeak Charts API or a MATLAB visualization. You might want to run prepackaged analysis repeatedly or based on a variable you can set. You might want to view data from multiple channels, or view channels depending on a condition. For example, you could show the channels for all devices that have a measurement higher than a given threshold.

Christopher Stapels, the ThingSpeak Product Manager, built an IoT data explorer app for MATLAB. The app is available for download on File Exchange or GitHub to help you explore your ThingSpeak data.

The ThingSpeak and MATLAB integration makes MATLAB the best environment for building a tool to analyze your ThingSpeak data. The IoT Data Explorer App is straightforward to use, to answer some questions about your data, and to customize for your own purposes. Chrisopher also created a video to help you get started with the IoT Data Explorer App for MATLAB.

If you have some ideas for improvements to the app, leave your comments here. We are already thinking of new features such as using the user API key to prepopulate the channel ID boxes automatically.

Download the IoT Data Explorer App for MATLAB from File Exchange or GitHub.

]]>
https://blogs.mathworks.com/iot/2020/09/21/explore-thingspeak-iot-data-using-a-matlab-app/feed/ 0
One Million ThingSpeak Channels! https://blogs.mathworks.com/iot/2020/03/17/one-million-thingspeak-channels/?s_tid=feedtopost https://blogs.mathworks.com/iot/2020/03/17/one-million-thingspeak-channels/#comments Tue, 17 Mar 2020 22:11:43 +0000 https://blogs.mathworks.com/iot/?p=2695

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2020/03/17/one-million-thingspeak-channels/feed/ 4
Analyze and Visualize Air Quality Data with MATLAB https://blogs.mathworks.com/iot/2019/07/16/analyze-and-visualize-air-quality-data-with-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2019/07/16/analyze-and-visualize-air-quality-data-with-matlab/#comments Tue, 16 Jul 2019 20:08:36 +0000 https://blogs.mathworks.com/iot/?p=2638

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2019/07/16/analyze-and-visualize-air-quality-data-with-matlab/feed/ 11
Predictive Maintenance: From Development to IoT Deployment https://blogs.mathworks.com/iot/2019/05/06/predictive-maintenance-from-development-to-iot-deployment/?s_tid=feedtopost https://blogs.mathworks.com/iot/2019/05/06/predictive-maintenance-from-development-to-iot-deployment/#comments Mon, 06 May 2019 14:48:18 +0000 https://blogs.mathworks.com/iot/?p=2601

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... read more >>

]]>
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.

 

]]>
https://blogs.mathworks.com/iot/2019/05/06/predictive-maintenance-from-development-to-iot-deployment/feed/ 1
Deep Learning and IoT at University of Louisiana at Lafayette Science Day https://blogs.mathworks.com/iot/2018/12/07/deep-learning-and-iot-at-university-of-louisiana-at-lafayette-science-day/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/12/07/deep-learning-and-iot-at-university-of-louisiana-at-lafayette-science-day/#comments Fri, 07 Dec 2018 16:10:53 +0000 https://blogs.mathworks.com/iot/?p=2552

This is a guest post by Diamond Blackwell, ACM-W President at the University of Louisiana at Lafayette. On Friday, October 26, 2018, the University of Louisiana at Lafayette opened its doors to over... read more >>

]]>
This is a guest post by Diamond Blackwell, ACM-W President at the University of Louisiana at Lafayette.

On Friday, October 26, 2018, the University of Louisiana at Lafayette opened its doors to over 900 students participating in Science Day. This is a campus-wide event where high school students throughout Louisiana come to visit university’s various science departments. Our department, the College of Computing and Informatics, put on four demos for students to partake in.

The Association of Computing Machinery – Women (ACM-W) club, an organization dedicated to increasing the number of women in tech, decided we should do something different than the previous year for our demo. Our organization’s advisor, Dr. Sonya Hsu, gave us the idea to try a Deep Learning and IoT, Internet of Things demo presented at Grace Hopper Celebration of Women in Computing this past September by the team from MathWorks. With the help from the MathWorks GHC team and colleagues, we were able to put on this spectacular demo at the Science Day at the University of Louisiana. You can read about the GHC 18 Deep Learning and IoT workshop here on this blog.

We gathered all of the required tips from Anoush Najarian of MathWorks, configured all of our laptops, and put together an informal and interactive presentation. And we had our students very entertained! They really enjoyed taking photos of the fruit (and sometimes themselves) in order to see how and which objects were classified. Students kept taking photos until their fruit was correctly labeled, seeing how holding the object in a certain position or light would affect the MATLAB program’s answer.

We did notice that with smaller groups, it was easier to help everyone and keep control of the room. This made the demonstrations and feedback sessions a lot more educational: in larger groups, most people could not get most of their questions answered in the allotted time. But, the interactive segment of the demo did make up for it.

Meanwhile, the MathWorks team in Boston could keep up with what we’re doing by looking at the data collected on ThingSpeak and analyzing it with MATLAB – that’s IoT in action!

This was an amazing outreach opportunity for our organization that could not have been executed without the help of the MathWorks team! The positive feedback and help really made this an enjoyable experience for my team, and we hope to partner with MathWorks in the future.

You too are welcome to use our GHC 18 Deep Learning and IoT workshop materials, and share your thoughts in the comments! Check out the work of awesome women in engineering and science we have been highlighting with the #shelovesmatlab hashtag!

]]>
https://blogs.mathworks.com/iot/2018/12/07/deep-learning-and-iot-at-university-of-louisiana-at-lafayette-science-day/feed/ 2
Libelium Now Supports ThingSpeak with MATLAB enabled IoT Analytics https://blogs.mathworks.com/iot/2018/10/05/libelium-now-supports-thingspeak-with-matlab-enabled-iot-analytics/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/10/05/libelium-now-supports-thingspeak-with-matlab-enabled-iot-analytics/#respond Fri, 05 Oct 2018 18:07:34 +0000 https://blogs.mathworks.com/iot/?p=2489

Libelium makes the Meshlium IoT Gateway that supports commercial IoT systems and sensor applications such as waste management, forest fire detection, potable water monitoring, supply chain... read more >>

]]>
Libelium makes the Meshlium IoT Gateway that supports commercial IoT systems and sensor applications such as waste management, forest fire detection, potable water monitoring, supply chain control, and fleet tracking. Libelium now supports ThingSpeak, so that you can take IoT applications to the next level by using ThingSpeak’s integrated MATLAB enabled IoT analytics and visualizations.

ThingSpeak is a MATLAB enabled IoT analytics platform from MathWorks, the leading developer of technical computing software for engineers and scientists. With ThingSpeak, users can view instant visualizations of live data from any Internet-connected web browser and schedule MATLAB code to run live analyses and visualizations as new data arrives. To accelerate the development of IoT analytics, MATLAB offers a full set of statistics and machine learning functionality, plus advanced methods such as nonlinear optimization, system identification, and thousands of prebuilt algorithms for signal and image processing.

Libelium sensors are used in a variety of vertical IoT applications like air quality monitoring and smart agriculture that are also common applications for users of the ThingSpeak platform. “The new integration between the Meshlium IoT Gateway and ThingSpeak will allow our customers with mutual interests to quickly analyze their data in the cloud with MATLAB,” said Eric Wetjen, Senior Product Marketing Manager for ThingSpeak.

The ThingSpeak integration allows you to easily connect your Libelium devices to the ThingSpeak IoT analytics platform by using the ThingSpeak cloud connector, which is built into the Libelium Meshlium IoT gateway. The ThingSpeak cloud connector inside of the Meshlium Manager System creates the ThingSpeak channels needed for your devices and synchronizes the data automatically without writing any custom code.

Check out the MathWorks Hardware Catalog for more information about the Libelium support for ThingSpeak and MATLAB.

]]>
https://blogs.mathworks.com/iot/2018/10/05/libelium-now-supports-thingspeak-with-matlab-enabled-iot-analytics/feed/ 0
Create and Train a Feedforward Neural Network https://blogs.mathworks.com/iot/2018/07/31/create-and-train-a-feedforward-neural-network/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/07/31/create-and-train-a-feedforward-neural-network/#respond Tue, 31 Jul 2018 15:04:53 +0000 https://blogs.mathworks.com/iot/?p=2465

We have published an example in the ThingSpeak documentation that shows you how to train a feedforward neural network to predict temperature. The feedforward neural network is one of the... read more >>

]]>
We have published an example in the ThingSpeak documentation that shows you how to train a feedforward neural network to predict temperature. The feedforward neural network is one of the simplest types of artificial networks but has broad applications in IoT. Feedforward networks consist of a series of layers. The first layer has a connection from the network input. Each other layer has a connection from the previous layer. The final layer produces the network’s output. In our IoT application, the output will be the predicted temperature.

IoT Application

We are collecting data in a ThingSpeak channel and will use the integrated MATLAB analytics. To predict the temperature, this example makes use of the Neural Network Toolbox in MATLAB along with the data collected in a ThingSpeak channel. We will be using data collected by a weather station located at MathWorks offices in Natick, Massachusetts.

The process for creating, training, and using a feedforward network to predict the temperature is as follows:

  1. Gather data from the weather station
  2. Create a two-layer feedforward network
  3. Train the feedforward network
  4. Use the trained model to predict data

Read Data from the Weather Station ThingSpeak Channel

ThingSpeak channel 12397 contains data from the MathWorks weather station, located in Natick, Massachusetts. The data is collected once every minute. Fields 2, 3, 4, and 6 contain wind speed (mph), relative humidity, temperature (F), and atmospheric pressure (hg) data respectively. To read the data from the weather station within MATLAB, use the thingSpeakRead function.

data = thingSpeakRead(12397,'Fields',[2 3 4 6],'DateRange',[datetime('Jul 30, 2018'),datetime('Jul 31, 2018')],...
    'outputFormat','table');

Create Two-Layer Feedforward Network

Use the feedforwardnet function to create a two-layer feedforward network. The network has one hidden layer with 10 neurons and an output layer.

net = feedforwardnet(10);

Train the Feedforward Network

Use the train function to train the feed-forward network.

[net,tr] = train(net,inputs,targets);

Use the Trained Model to Predict Data

After the network is trained and validated, you can use the network object to calculate the network response to any input.

output = net(inputs(:,5))
output =

   74.9756

This example can be adapted to other IoT applications. Check out the ThingSpeak documentation for the code and explanation.

]]>
https://blogs.mathworks.com/iot/2018/07/31/create-and-train-a-feedforward-neural-network/feed/ 0
ThingSpeak Now Supports the Predictive Maintenance Toolbox for MATLAB https://blogs.mathworks.com/iot/2018/05/02/thingspeak-now-supports-the-predictive-maintenance-toolbox-for-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/05/02/thingspeak-now-supports-the-predictive-maintenance-toolbox-for-matlab/#comments Wed, 02 May 2018 21:51:02 +0000 https://blogs.mathworks.com/iot/?p=2404

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,... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2018/05/02/thingspeak-now-supports-the-predictive-maintenance-toolbox-for-matlab/feed/ 1
Discussions About How to Use MATLAB and Arduino on the MATLAB Maker Community https://blogs.mathworks.com/iot/2018/03/30/discussions-about-how-to-use-matlab-and-arduino-on-the-matlab-maker-community/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/03/30/discussions-about-how-to-use-matlab-and-arduino-on-the-matlab-maker-community/#comments Fri, 30 Mar 2018 15:53:13 +0000 https://blogs.mathworks.com/iot/?p=2352

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2018/03/30/discussions-about-how-to-use-matlab-and-arduino-on-the-matlab-maker-community/feed/ 1
Join Us at the MIT Connected Things Conference https://blogs.mathworks.com/iot/2018/03/28/join-us-at-the-mit-connected-things-conference/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/03/28/join-us-at-the-mit-connected-things-conference/#respond Wed, 28 Mar 2018 22:24:40 +0000 https://blogs.mathworks.com/iot/?p=2344

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2018/03/28/join-us-at-the-mit-connected-things-conference/feed/ 0
Learn How to Build a Condition Monitoring IoT System https://blogs.mathworks.com/iot/2018/02/22/learn-how-to-build-a-condition-monitoring-iot-system/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/02/22/learn-how-to-build-a-condition-monitoring-iot-system/#comments Thu, 22 Feb 2018 16:00:49 +0000 https://blogs.mathworks.com/iot/?p=2298

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2018/02/22/learn-how-to-build-a-condition-monitoring-iot-system/feed/ 1
What is a Bomb Cyclone? Use ThingSpeak and MATLAB to Figure it Out. https://blogs.mathworks.com/iot/2018/01/04/what-is-a-bomb-cyclone/?s_tid=feedtopost https://blogs.mathworks.com/iot/2018/01/04/what-is-a-bomb-cyclone/#respond Thu, 04 Jan 2018 22:32:58 +0000 https://blogs.mathworks.com/iot/?p=2236

Social media is blowing up the term bomb cyclone. The term is everywhere from Twitter to 24/7 news coverage of the storm hitting the East Coast of the United States. The technical term for a bomb... read more >>

]]>
Social media is blowing up the term bomb cyclone. The term is everywhere from Twitter to 24/7 news coverage of the storm hitting the East Coast of the United States. The technical term for a bomb cyclone is bombogenesis which is the combination of “bomb” and “cyclogenesis.” Or, you could call it an explosive cyclogenesis to grab views to your blog.

A storm undergoes bombogenesis when its central low pressure drops at least 24 millibars in 24 hours, according to the National Oceanic and Atmospheric Administration (NOAA).

At the MathWorks headquarters in Natick, MA we have a weather station sending data to ThingSpeak for the past several years. Here’s what the weather station looks like on a better day.

Not many interesting events emerge from the data, but with something called a bomb cyclone, Rob Purser decided to take a closer look using MATLAB. Our weather station on ThingSpeak channel 12397 collects temperature, humidity, and pressure data. By taking a look at this MATLAB plot of the pressure analyzed over 24 hours, you will see the pressure drops at least 24 millibars in 24 hours and in fact over 40 millibars. This storm definitely fits its name of explosive cyclogenesis.

Have a look at the raw data from ThingSpeak and see if you can determine the bomb cyclone event. In MATLAB, use thingSpeakRead via the ThingSpeak Support Toolbox. We documented the process of analyzing the weather station data using MATLAB on Hackster.io. Just follow the steps using MATLAB or MATLAB Online, to discover some interesting results.

Stay warm.

]]>
https://blogs.mathworks.com/iot/2018/01/04/what-is-a-bomb-cyclone/feed/ 0
Don’t Get Stuck in the Mud, Understand Tide Levels with MATLAB https://blogs.mathworks.com/iot/2017/09/14/dont-get-stuck-in-the-mud-understand-tide-levels-with-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/09/14/dont-get-stuck-in-the-mud-understand-tide-levels-with-matlab/#respond Thu, 14 Sep 2017 14:25:28 +0000 https://blogs.mathworks.com/iot/?p=2189

Tides go up and down. But, the question is when and how will the tide levels change in the future. If you are planning a boating trip or trying to understand how the wind affects tide levels during... read more >>

]]>
Tides go up and down. But, the question is when and how will the tide levels change in the future. If you are planning a boating trip or trying to understand how the wind affects tide levels during storms, you want to predict the tide levels using data that you have collected locally. In a tutorial published on Hackster.io, you will be able to learn how to use ThingSpeak to collect sensor data that represents the tide height at a given time, use MATLAB to preprocess the data, use MATLAB to predict future tide levels, and use ThingSpeak to send alerts. Here’s what the system looks like installed at a dock in Cape Cod.

The tide height is calculated using an ultrasonic level sensor. This measurement is taken periodically and then sent to ThingSpeak, an IoT analytics cloud platform by MathWorks, using a cellular modem. The system can easily be adapted to collect data about any environmental system such as greenhouses or oyster farms.

Once you have the data in a ThingSpeak channel, you use MATLAB to preprocess and clean up the data. The raw data some times has extraneous values caused by environmental factors such as lighting, cabling, and electrical interference. Sometimes, you have missing data caused by connectivity issues. It is important to clean up the data before you use the data in your analysis.

To predict future tide levels and send alerts when the tide is rising or falling, we use the MATLAB Analysis app on ThingSpeak. With MATLAB, we can use historical data to make a prediction about the future tide levels. This predicted tide level can be used to help schedule a boating trip or plan for a water surge after a storm.

 

Tide Alerts

Remembering to check the tide level when fishing or lazing on the beach is not particularly convenient. A much more useful approach is to have the system send a message when the time has come to pack up and start heading back to the dock. The timing of the alert depends on how much water depth is needed by a particular boat. Larger boats need higher water levels in order to move without getting stuck in the mud. One way to send alerts is to use ThingSpeak and MATLAB to detect changes in tidal height and send alerts.

Conclusion

Developing a tide monitoring system provided accurate tide level measurement and tide level prediction, with the added ability to send alerts. Robert has been able to avoid being stuck in the bay by providing enough time to get back to his dock using this system. This project also serves as a useful approach to solving many data-driven puzzles by having a reliable way to collect, analyze, and act on data. Using MATLAB, the accuracy of the tide levels improved by understanding the proper tide levels at a specific location and when the tide levels will change. If you used the general tide forecast, you would have to account for several inches of tide height difference.

Resources

]]>
https://blogs.mathworks.com/iot/2017/09/14/dont-get-stuck-in-the-mud-understand-tide-levels-with-matlab/feed/ 0
Learn about IoT and Digital Twins https://blogs.mathworks.com/iot/2017/08/07/learn-about-iot-and-digital-twins/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/08/07/learn-about-iot-and-digital-twins/#respond Mon, 07 Aug 2017 19:32:40 +0000 https://blogs.mathworks.com/iot/?p=2177

An emerging topic with IoT is Digital Twin (DT). The digital twin is a federation of data and models that can be analyzed or put into a simulation to create useful information about the past,... read more >>

]]>
An emerging topic with IoT is Digital Twin (DT).

The digital twin is a federation of data and models that can be analyzed or put into a simulation to create useful information about the past, present, or future of the DT’s physical twin.

Bruce Sinclair of the Iot-Inc. Business Show podcast invite Jim Tung, a MathWorks fellow, to discuss models, simulation, and digital twins. Jim shares information about a few MathWorks customer use cases and our products used for modeling, simulation, and IoT.

Bruce and Jim talk about many interesting and key topics for IoT system development, including:

  • The difference between data-driven models and functional models
  • Using raw data to calibrate, update and validate functional models
  • System level modeling
  • The importance model hierarchy to discover insights
  • A smart grid digital twin example
  • The role of deep learning in digital twin modeling
  • The actionable steps of how to create your digital twin

To listen to the  Iot-Inc. Business Show podcast, either subscribe on iTunes or play the episode on Iot-Inc.

Additional Resources

]]>
https://blogs.mathworks.com/iot/2017/08/07/learn-about-iot-and-digital-twins/feed/ 0
Send Bulk Sensor Data to ThingSpeak for Analysis https://blogs.mathworks.com/iot/2017/07/20/send-bulk-sensor-data-to-thingspeak-for-analysis/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/07/20/send-bulk-sensor-data-to-thingspeak-for-analysis/#comments Thu, 20 Jul 2017 15:00:17 +0000 https://blogs.mathworks.com/iot/?p=2167

Many IoT projects collect data from a sensor and send the data to ThingSpeak at the same time over and over. To continuously collect and send data to the cloud requires the device to be powered and... read more >>

]]>
Many IoT projects collect data from a sensor and send the data to ThingSpeak at the same time over and over. To continuously collect and send data to the cloud requires the device to be powered and connected all of the time. A battery-powered IoT device like a Particle Photon or Onion Omega2 would run out of power quickly. There are many IoT applications where you want your IoT device to collect the data offline over a long period of time, then send the data all at once to ThingSpeak for analysis.

The ThingSpeak team at MathWorks is excited to announce Bulk-Update! This new ThingSpeak feature is targeted at IoT devices trying to optimize battery use by allowing the device to update a lot of data at once. To help you get started with bulk-update, we have written examples for Arduino, ESP8266, Particle Photon, and the Raspberry Pi 3.

Once your data is on ThingSpeak, it is easy to analyze using the MATLAB Analysis and Visualization apps within ThingSpeak, MATLAB Online, or Desktop MATLAB. To read data from ThingSpeak into MATLAB, use the ThingSpeak Support Toolbox and the thingSpeakRead command. We have released documentation and examples to help you get started with bulk-update on ThingSpeak.

Resources for Bulk-Update

]]>
https://blogs.mathworks.com/iot/2017/07/20/send-bulk-sensor-data-to-thingspeak-for-analysis/feed/ 5
The Data Science Behind BBQ https://blogs.mathworks.com/iot/2017/05/29/the-data-science-behind-bbq/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/05/29/the-data-science-behind-bbq/#comments Mon, 29 May 2017 16:15:55 +0000 https://blogs.mathworks.com/iot/?p=2139

Smoking ribs or a pork shoulder requires lots of patience and practice. When everything works, you get to enjoy an amazing dinner. When things go wrong, you end up with dry, overcooked meat that only... read more >>

]]>
Smoking ribs or a pork shoulder requires lots of patience and practice. When everything works, you get to enjoy an amazing dinner. When things go wrong, you end up with dry, overcooked meat that only your dog may enjoy. Here’s what great BBQ looks like from @AndreasHarsch.

My process of smoking meat, cheese, or even ice cream is to monitor only the meat temperature and the internal temperature of the smoker. When I finish a cook, I go back and try to learn from the data. I do not attempt to control the smoker using the Internet of Things, I use IoT to collect the data with ThingSpeak, analyze the data with MATLAB, and apply the insights to the next cook. The best advice that I have been given is to not change too many variables. Stick with simple rubs, the same charcoal, the same wood, the same cuts of meat, etc. Only change one variable for one cook. It takes years of trial and error before you get great at BBQ.

With the help of ThingSpeak and MATLAB, I can help you understand one of the more frustrating parts of smoking meats… the stall! The stall is a period of time where what you are cooking does not seem to be increasing in internal temperature. I used to panic during the stall and mess with the temperature by adding more charcoal or turning the vents. Overtime, I realized this is normal. No reason to panic.

Cooking is taking something cold and getting its internal temperature up to a safe level. Everything that you cook has a different target internal temperature, but generally the sweet spot is 190-205F. Smoking is about low and slow cooking. This means that you are trying to raise that internal temperature slowly with a low temperature. I use a cook temperature of 230-250F. This means that smoking takes a lot of time to properly cook. In some cases, this is two hours per pound. Things don’t change much minute to minute in a BBQ pit, so you can collect data every few minutes and still have an accurate picture of what’s happening.

Collecting Data

First, I set up a ThingSpeak channel to store my temperature data. One field is for the smoker’s temperature and field two is for the internal temperature of what I am cooking. To get the data, you have many options. I did a quick search around the internet and discovered hundreds of Arduino and ThingSpeak projects to get data from a smoker. In general you need two temperature probes that can take the heat of the smoker, connectors, an Arduino with Wi-Fi like the MKR1000.

Analyzing the Temperature Data

The first step is to read in the temperature data using MATLAB that was collected by ThingSpeak. Data on ThingSpeak is stored in a channel and identified by a channelID. If you have a private channel, you will need to supply a Read API Key to get access to the data.

smokerTT = thingSpeakRead(279400,'ReadKey','9AYZQDT1XFDM98FW','OutputFormat','timetable','NumPoints',115);

Sometimes the data from your temperature probe is noisey. This means the value that the temperature probe reports is sometimes higher or lower than the actual temperature. If you take a few samples and take a median, you get a consistent result. In MATLAB, I use smoothdata to take a moving median of my time-series sensor data.

smoothSmoker = smoothdata(smokerTT);

After I clean up the data, I want to visualize it and to see what happened. This is a good time to learn how long things actually take, so on your next cook you budget the right amount of time and don’t rush any phases.

plot(smoothSmoker.Timestamps, smoothSmoker.Variables);

I can use this data to determine how long the total cook will last and even set alerts using ThingSpeak. I tend to watch the smoker and tend the fire.

Results

After a lot of research, I discovered what the stall is doing and why it is important to keep your patience and push forward. This is starting to sound like a metaphor for life. According to Prof. Greg Blonder, “The stall is evaporative cooling”. Prof. Greg is a physicist, entrepreneur, former Chief Technical Advisor at AT&T’s legendary Bell Labs, and regularly contributes to AmazingRibs.com. He likes to bust myths about barbequing and help us understand the thermodynamics of cooking. You are heating the meat slowly, but the moisuture in the meat is evapotaring at the same rate. This effect causes a stall in the temperature rise. The temperature of the meat will go up when the moisture is depleted. The stall is important to the cooking process and leads to something called the bark. This is an outer layer of the meat that is slightly thicker and less tender than the rest of the meat, but traps in lots of flavor and adds to its complexity. So, don’t rush during the stall. Keep the smoker temperature constant – avoid the temptation to turn the heat up to get through faster. And in the end, enjoy some well made BBQ with friends and family over the summer weekends and holidays.

]]>
https://blogs.mathworks.com/iot/2017/05/29/the-data-science-behind-bbq/feed/ 4
IoT Day is the Day to Learn About Our New MATLAB Analytics Features https://blogs.mathworks.com/iot/2017/04/08/iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/04/08/iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features/#respond Sun, 09 Apr 2017 02:30:59 +0000 https://blogs.mathworks.com/iot/?p=2048 IoT Data heatmap

April 9th is IoT Day! We are celebrating by announcing new IoT Analytic features. All ThingSpeak users now have access to the new features of MATLAB R2017a. In ThingSpeak you can analyze and... read more >>

]]>
April 9th is IoT Day! We are celebrating by announcing new IoT Analytic features. All ThingSpeak users now have access to the new features of MATLAB R2017a. In ThingSpeak you can analyze and visualize your data using the power of MATLAB. With the latest updates you can visualize your IoT data as a heatmap and analyze large sets of time-stamped data using a tall timetable.

In the latest update, we have added many new analytics features perfect for IoT data:

  • isoutlier / filloutliers: To find outliers in your data, use the isoutlier function. To replace outliers with alternative values, use the filloutliers function.
  • smoothdata: Smoothing noisy data is now possible with the smoothdata function. For example, smoothdata(A,’movmedian’) smooths data with a moving-window median.
  • fillmissing: Filling missing data using a moving mean or moving median option is now available with the fillmissing function.

Smooth Weather Data

At our headquarters in Natick, MA, we have a weather station sending data to ThingSpeak channel 12397. We use ThingSpeak to collect raw temperature, humidity, wind, and rain data. We use MATLAB to analyze and visualize the data so we can use it for forecasting plant harvesting and building weather models. Learn how to build your own weather station at Hackster.io and learn how to analyze the weather data using MATLAB with the source code on File Exchange.

Often you want to process the raw data by removing outliers and smoothing the data. This helps if you are building a predictive model and to better visualize the data. The common IoT analytics workflow is to read in raw data, synchronize the data in time, detect and remove outlier values, smooth the data, and visualize the data. This example works on ThingSpeak, MATLAB Online, and desktop MATLAB.

Read historic weather data

[weather,channelInfo] = thingSpeakRead(12397,...
'DateRange',[datetime('Feb 04, 2016'),datetime('Feb 10, 2016')],...
'outputFormat','table');

Convert to timetable

weather = table2timetable(weather);

Smooth the data

First, resample the timetable using the retime function so the times and data are uniformly spaced on the minute.

wdata = retime(weather(:,{'Humidity','TemperatureF'}),'minutely','linear');

Smooth the data using a moving median and compare this to the original data. There are a number of moving statistics functions for vectors and matrices like movmean, movmedian, etc and also the smoothdata function which also works on timetables and uses the RowTimes as the sample points. Moving median is the default and other options are available.

smdata = smoothdata(wdata);

Visualize the original and smoothed temperature data on a plot

figure
plot(wdata.Timestamps,wdata.TemperatureF,...
smdata.Timestamps,smdata.TemperatureF,'m--')
legend('Raw Data','Smooth Data')
ylabel('Temperature (\circF)')
title('Temperature Over Time')

Smooth Weather Data

Have a happy IoT Day and we hope that you understand your IoT data a littler more by using MATLAB Analytics on ThingSpeak. I would like to thank Heather Gorr for helping me put together the example MATLAB code. Cheers!

]]>
https://blogs.mathworks.com/iot/2017/04/08/iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features/feed/ 0
Build IoT Projects on Arduino Day Using MATLAB and ThingSpeak https://blogs.mathworks.com/iot/2017/03/31/build-iot-projects-on-arduino-day-using-matlab-and-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/03/31/build-iot-projects-on-arduino-day-using-matlab-and-thingspeak/#respond Fri, 31 Mar 2017 22:01:05 +0000 https://blogs.mathworks.com/iot/?p=2042

April 1st is Arduino Day, no joke! For in person events near you, check out the Arduino Day website. If you have been kicking around an idea about a project to build, this is a great time to try to... read more >>

]]>
April 1st is Arduino Day, no joke! For in person events near you, check out the Arduino Day website. If you have been kicking around an idea about a project to build, this is a great time to try to get it done and share it with others from around the world. We provide some great tools to build projects that use Arduino.

MathWorks Arduino Resources

Maybe it’s time to build your version of a MATLAB and Arduino powered dartboard.

We hope you build some awesome projects using Arduino, MATLAB, Simulink, and ThingSpeak on Arduino Day!

]]>
https://blogs.mathworks.com/iot/2017/03/31/build-iot-projects-on-arduino-day-using-matlab-and-thingspeak/feed/ 0
Building a Dynamic and Self-organizing Network of Devices https://blogs.mathworks.com/iot/2017/03/25/building-a-dynamic-and-self-organizing-network-of-devices/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/03/25/building-a-dynamic-and-self-organizing-network-of-devices/#respond Sat, 25 Mar 2017 19:24:56 +0000 https://blogs.mathworks.com/iot/?p=2039

Anders Sollander, a principal technical consultant at MathWorks, and his team put together a project to determine what demo was the most popular at one of our demo showcases. Anders made an... read more >>

]]>
Anders Sollander, a principal technical consultant at MathWorks, and his team put together a project to determine what demo was the most popular at one of our demo showcases. Anders made an assumption that if your demo was popular, you would have a lot of visitors. If you have a lot of visitors, your demo would be the loudest.

Anders was determined to measure sound from over 20 demo stations at the same time and figure out who the the winner is. This turns out to be a complicated challenge and he used our tools such as MATLAB, Simulink, and ThingSpeak, to produce some interesting results. Here’s what the raw data looks like from just five sound sensor nodes at the demo stations.

The sensor nodes uses the Arduino Nano devices because they’re small, low-cost, and Simulink has an Arduino support package. Arduino Nano’s both low cost and energy efficient which is great, but it doesn’t have Wi-Fi. They connect the sensor nodes to an Internet-connected Raspberry Pi using an RF mesh network with the nRF24l01+ radio. The RF24 solution is both very cheap and energy efficient, which is valuable if you’re running them with battery power. Simulink Coder has a Raspberry Pi Support Package which simplified the workflow.

When you follow the tutorial, you are going to learn many things and experience their analytic workflow as they decide how to develop an algorithm to normalize sound levels, determine which data to send to ThingSpeak, and build visualizations to see the results of the project.

Anders also shared a library on File Exchange that allows users to communicate with RF24 chips on Raspberry Pi and Arduino boards. The library relies on the RF24Mesh library, and has S-functions that interact with the classes there. The File Exchange submission includes an example for the Arduino to read sensor data from a temperature sensor and sends it to the gateway Raspberry Pi and then sends the data to ThingSpeak. In order to download the File Exchange, you need to sign in with your MathWorks account. This would be the same account that you use on ThingSpeak.com.

Visit ThingSpeak Tutorials, to see the complete tutorial for Building a Dynamic and Self-organizing Network of Devices.

]]>
https://blogs.mathworks.com/iot/2017/03/25/building-a-dynamic-and-self-organizing-network-of-devices/feed/ 0
Cadmus Collects and Analyzes IoT Data Using MATLAB and ThingSpeak https://blogs.mathworks.com/iot/2017/02/22/cadmus-analyzes-iot-data-with-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2017/02/22/cadmus-analyzes-iot-data-with-matlab/#respond Wed, 22 Feb 2017 19:58:01 +0000 https://blogs.mathworks.com/iot/?p=2028

The Internet of Things (IoT) enables power producers, public utilities, and other companies in the energy sector to collect energy power consumption data from hundreds of factories and thousands of... read more >>

]]>
The Internet of Things (IoT) enables power producers, public utilities, and other companies in the energy sector to collect energy power consumption data from hundreds of factories and thousands of homes in near real time. This wealth of information has opened opportunities to evaluate energy efficiency initiatives, predict power demand, and perform energy audits.

Consulting firm Cadmus provides full-spectrum energy-efficiency support services to energy utilities throughout North America. These services include studies of energy use that require extensive data collection and analysis.

To make the most of the opportunities presented by the IoT, Cadmus engineers used MATLAB® and the ThingSpeak™ IoT platform to develop a workflow for collecting, storing, analyzing, visualizing, and interpreting data from sensors in homes and businesses distributed across wide geographic areas.

“In just a few months, we implemented a new service that measures and analyzes temperature and humidity changes in dozens—and soon hundreds—of homes,” says Dave Korn, vice president of engineering at Cadmus. “Without MATLAB and ThingSpeak, we would still just be talking about it. Instead, we’re already pitching this service to utilities. That is a huge competitive advantage for our company.”

Solution

Cadmus used MATLAB and ThingSpeak to develop and deploy two systems of cloud-connected sensors for the near-real-time measurement and analysis of energy data, while establishing a workflow for rapidly implementing similar systems.

The first system, designed for an energy efficiency study of residential homes, used custom sensors to send temperature, relative humidity, and device battery voltage measurements to ThingSpeak every five minutes. The second, designed to monitor loads of HVAC systems and large appliances, used off-the-shelf home automation hardware to send power usage data, captured at residential circuit breakers and individual outlets, every minute.

Using the ThingSpeak web application, the engineers created new channels to collect data from the sensors and to quickly verify that each new sensor added to the system was reliably sending data.

Working in MATLAB, the team analyzed the collected data, using standard statistical techniques to identify outliers and calculate means and standard deviations. For example, they calculated and plotted power load profiles by the hour and correlated the load data with weather data from an outside source.

They created a variety of data visualizations, including interactive maps, which they shared with clients and prospects.

Cadmus engineers are currently using MATLAB and Statistics and Machine Learning Toolbox™ to develop predictive algorithms based on machine learning and advanced classification and regression techniques. These algorithms are designed to predict and model load based on weather conditions and sensor data collected via ThingSpeak.

Results

  • Market opportunity seized. “In our industry, many utilities are looking to design better energy efficiency programs and to lower the costs of those programs,” says Korn. “MATLAB and ThingSpeak enabled us to develop solutions rapidly, which meant we could capitalize on these demands this fall. Without MATLAB and ThingSpeak we would have had to wait until spring and miss numerous opportunities in the market.”
  • Development effort cut by two-thirds. “With MATLAB and ThingSpeak, our team of five engineers was collecting and analyzing data in a matter of months. We could not have met our deadlines without them,” says James Kennedy, energy analyst at Cadmus. “With other tools we would probably have needed 15 engineers to complete the work in the same time amount of time—if we could have done it at all.”
  • Sensor networks quickly deployed. “On our first project with ThingSpeak, it took just over three months to implement a network that we quickly scaled from 50 operational sensors to 500,” says Kennedy. “In a very short period we had another complete network set up and collecting data, and that one was deployed at an even faster rate than the first.”
]]>
https://blogs.mathworks.com/iot/2017/02/22/cadmus-analyzes-iot-data-with-matlab/feed/ 0
Cloud-based People Counter Using MATLAB and ThingSpeak https://blogs.mathworks.com/iot/2016/11/21/cloud-based-people-counter-using-matlab-and-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/11/21/cloud-based-people-counter-using-matlab-and-thingspeak/#respond Mon, 21 Nov 2016 21:28:58 +0000 https://blogs.mathworks.com/iot/?p=1959

Over the weekend, I noticed a tweet about a people counter using MATLAB and ThingSpeak being demonstrated at Big Data Spain. They were able to detect over 1,500 visitors at their demo station. The... read more >>

]]>
Over the weekend, I noticed a tweet about a people counter using MATLAB and ThingSpeak being demonstrated at Big Data Spain. They were able to detect over 1,500 visitors at their demo station.

People Counter using MATLAB and ThingSpeak

The project uses MATLAB to create a cloud-based people counter by detecting faces with the Computer Vision System Toolbox™. The raw people count is then sent to the ThingSpeak IoT platform for data collection in the cloud and further data analysis.

Check out File Exchange to learn how to build your own people counter using MATLAB and ThingSpeak.

]]>
https://blogs.mathworks.com/iot/2016/11/21/cloud-based-people-counter-using-matlab-and-thingspeak/feed/ 0
MATLAB Toolboxes are Now Available on ThingSpeak for IoT Analytics https://blogs.mathworks.com/iot/2016/11/05/matlab-toolboxes-on-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/11/05/matlab-toolboxes-on-thingspeak/#comments Sat, 05 Nov 2016 15:35:21 +0000 https://blogs.mathworks.com/iot/?p=1943

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2016/11/05/matlab-toolboxes-on-thingspeak/feed/ 5
Use MATLAB ‘timetable’ to Merge ThingSpeak Data Channels https://blogs.mathworks.com/iot/2016/09/25/use-matlab-timetable-to-merge-thingspeak-data-channels/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/09/25/use-matlab-timetable-to-merge-thingspeak-data-channels/#comments Mon, 26 Sep 2016 00:12:57 +0000 https://blogs.mathworks.com/iot/?p=1924

We released a new version of MATLAB and it’s available now for every ThingSpeak user. MATLAB R2016b includes many new features that make it easy to work with time-stamped tabular data,... read more >>

]]>
We released a new version of MATLAB and it’s available now for every ThingSpeak user. MATLAB R2016b includes many new features that make it easy to work with time-stamped tabular data, manipulate, compare, and store text data efficiently, and find, fill, and remove missing data.

With multiple sensors around my house or office, I want to be able to send data to multiple ThingSpeak channels. But, when I want to perform data analysis, I have a hard time working with data from multiple channels. The channels do not have the same time stamps and are out-of-sync with each other.

With R2016b of MATLAB®, I am able to use the new timetable data container. Once the data is a stored as a timetable, I can perform powerful operations such as retime, synchronize, and rmmissing.

In this example, I have two sensors outside of my office here in Natick, MA. One sensor is a temperature sensor that is sending data to ThingSpeak channel 163540. My other sensor is writing humidity data to channel 163545. Both channels are public. My goal is to plot temperature versus humidity over one time series. To accomplish this, I will use timetable and synchronize inside of a new MATLAB Visualization on ThingSpeak.

% Read from the temperature channel
temperatureTT = thingSpeakRead(163540,'Fields',1,'NumPoints',100,'outputFormat','timetable');

% Read from the humidity channel
humidityTT = thingSpeakRead(163545,'Fields',1,'NumPoints',100,'outputFormat','timetable');

% Synchronize two timestables and fill in missing data using linear interpolation
TT = synchronize(temperatureTT,humidityTT,'union','linear')

% Plot Temperature and Humidity over time
plotyy(TT.Timestamps,TT.Temperature,...
       TT.Timestamps,TT.Humidity);
        
title('Temperature and Humidity Synchronized From Two Channels')
xlabel('Temperature and Humidity in Natick, MA')
legend('Temperature','Humidity')

The first part of the script reads in ThingSpeak data from two different channels and stores the data in two timetables. Once the data is stored in a timetable, I am able to take advantage of synchronize. With synchronize, I can combine both timetables with one time series and fill in missing data using linear interpolation. This results in a plot that shows my data over time without any missing data. To create the plot, I signed into ThingSpeak, selected Apps, and created a new MATLAB Visualization with my MATLAB code.

All ThingSpeak users are able to try this example or explore the other new MATLAB features directly on ThingSpeak. I will leave my temperature (163540) and humidity (163545) channels public, so you can try out timetable example without having to connect devices to ThingSpeak.

]]>
https://blogs.mathworks.com/iot/2016/09/25/use-matlab-timetable-to-merge-thingspeak-data-channels/feed/ 10
Introducing MATLAB Central… https://blogs.mathworks.com/iot/2016/08/25/introducing-matlab-central/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/08/25/introducing-matlab-central/#respond Thu, 25 Aug 2016 21:51:22 +0000 https://blogs.mathworks.com/iot/?p=1911

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... read more >>

]]>
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.

]]>
https://blogs.mathworks.com/iot/2016/08/25/introducing-matlab-central/feed/ 0
Analyzing Squirrel Behaviour and Weather Forecasting with MATLAB and ThingSpeak https://blogs.mathworks.com/iot/2016/07/25/analyzing-squirrel-behaviour-and-weather-forecasting/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/07/25/analyzing-squirrel-behaviour-and-weather-forecasting/#respond Mon, 25 Jul 2016 14:23:54 +0000 https://blogs.mathworks.com/iot/?p=1861

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... read more >>

]]>
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 www.TheSquirrelCafe.com.

 

]]>
https://blogs.mathworks.com/iot/2016/07/25/analyzing-squirrel-behaviour-and-weather-forecasting/feed/ 0
Prototyping IoT Analytics with MATLAB and ThingSpeak https://blogs.mathworks.com/iot/2016/07/09/prototyping-iot-analytics-with-matlab-and-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/07/09/prototyping-iot-analytics-with-matlab-and-thingspeak/#respond Sat, 09 Jul 2016 18:54:41 +0000 https://blogs.mathworks.com/iot/?p=1853

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... read more >>

]]>
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

]]>
https://blogs.mathworks.com/iot/2016/07/09/prototyping-iot-analytics-with-matlab-and-thingspeak/feed/ 0
Weather Station with Particle, SparkFun, ThingSpeak, and MATLAB https://blogs.mathworks.com/iot/2016/06/06/weather-station-data-analysis/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/06/06/weather-station-data-analysis/#respond Mon, 06 Jun 2016 14:46:25 +0000 https://blogs.mathworks.com/iot/?p=1837

[Haodong Liang] has released a weather station project with full MATLAB data analysis, device source code, and procedures on Hackster.io. He used the Particle Electron to connect the SparkFun weather... read more >>

]]>
[Haodong Liang] has released a weather station project with full MATLAB data analysis, device source code, and procedures on Hackster.io. 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 Hackster.io 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.

[via Hackster.io]

]]>
https://blogs.mathworks.com/iot/2016/06/06/weather-station-data-analysis/feed/ 0
Explore your IoT data with ThingSpeak and MATLAB https://blogs.mathworks.com/iot/2016/03/25/explore-your-iot-data-with-thingspeak-and-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/03/25/explore-your-iot-data-with-thingspeak-and-matlab/#respond Fri, 25 Mar 2016 19:09:34 +0000 https://blogs.mathworks.com/iot/?p=1749

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... read more >>

]]>
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.

MATLAB car counting display

Loren explores the data using MATLAB Analysis and MATLAB Visualizations app built into ThingSpeak.

Offline Analysis: Analyzing Data stored on ThingSpeak

If you have desktop MATLAB, you can gain even more insights into our traffic data or any of your ThingSpeak Channels. You need to first import the data from ThingSpeak into desktop MATLAB. To simplify the retrieval of the data from ThingSpeak, we use the functions from the ThingSpeak Support Toolbox, available on MATLAB Central File Exchange.

readChannelID = 38629;
readAPIKey = '8NPXB8G515OAD94Q';

%% Read Data %%
[data, time] = thingSpeakRead(readChannelID,'DateRange',[datetime('Mar 13, 2016'),datetime('Mar 14, 2016')],'ReadKey', readAPIKey);

[via Loren on the Art of MATLAB]

]]>
https://blogs.mathworks.com/iot/2016/03/25/explore-your-iot-data-with-thingspeak-and-matlab/feed/ 0
New MATLAB Analysis Feature – movmax – for ThingSpeak https://blogs.mathworks.com/iot/2016/03/11/new-matlab-feature-movmax/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/03/11/new-matlab-feature-movmax/#respond Fri, 11 Mar 2016 21:52:07 +0000 https://blogs.mathworks.com/iot/?p=1743

My power meter at my house reports its power every few minutes. I capture that data and send it to ThingSpeak. The value reported is the total kilowatt-hour (kWh). I would love to see the maximum... read more >>

]]>
My power meter at my house reports its power every few minutes. I capture that data and send it to ThingSpeak. The value reported is the total kilowatt-hour (kWh). I would love to see the maximum value over an hour versus randomly reported values over an hour. With the release of MATLAB R2016a, ThingSpeak users have access to a new suite of data analysis features. One of them is movmax – with movmax, I now can look at my ThingSpeak data over time and figure a moving window of maximum values. This new feature is highly customizable for your application, but I will show you how I use it.

My data over an hour looks like this: 803, 919, 724, 1349, 1500, 602, 549, 899, 1678, 1577

Using movmax, I can have a sliding window ran over my data to pull out a maximum value from the window and use it for visualization or further analysis.

The MATLAB code to process my power data is really straightforward.

readChannelID = 97871;
fieldID1 = 1;
readAPIKey = '7MOXB8G515OAD94Q';

%% Read Data %%
[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 10, 'ReadKey', readAPIKey);

%% Process Data %%
data_max = movmax(data, 4)

%% Visualize Data %%
plot(time, data_max);

Now, using the MATLAB Visualizations app on ThingSpeak, I can visualize the data. Here’s the before and after.

Power Data Processed Data with MATLAB movmax

You can use movmax in the MATLAB Analysis or MATLAB Visualizations apps on ThingSpeak. Sign up or sign into ThingSpeak, select Apps, and click “MATLAB Visualizations”. Create a new one with the blank template and use my MATLAB code. I will leave my channel of data up for you to try out. You can use channel number 97871 and my read API key 7MOXB8G515OAD94Q. The power data is stored in field1.

]]>
https://blogs.mathworks.com/iot/2016/03/11/new-matlab-feature-movmax/feed/ 0
Uber Ride Analysis with ThingSpeak and MATLAB https://blogs.mathworks.com/iot/2016/02/05/uber-ride-analysis-with-thingspeak-and-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/02/05/uber-ride-analysis-with-thingspeak-and-matlab/#respond Sat, 06 Feb 2016 03:17:02 +0000 https://blogs.mathworks.com/iot/?p=1641

Have you ever wondered how long it will take to get an Uber at your location? This project uses ThingSpeak to log the ETA for an Uber service based on your latitude and longitude. We will use... read more >>

]]>
Have you ever wondered how long it will take to get an Uber at your location? This project uses ThingSpeak to log the ETA for an Uber service based on your latitude and longitude. We will use ThingSpeak’s MATLAB Analysis and TimeControl apps to track Uber’s ETA over time.

Uber Ride Estimate

The Uber API allows you to pass a latitude and longitude to determine the estimated time of arrival for an Uber car. The API also allows you to schedule a car. I have made a button that requests an Uber car and also schedules an Uber at the right time.

MATLAB Analysis Code

% Read the ThingHTTP for 'Uber Ride Estimate'
data = webread('https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXX')

% Convert the response to a number
eta = str2num(data);

% Write the data to the 'Uber Ride Estimate Data' ThingSpeak Channel
thingSpeakWrite(Channel_ID,eta,'WriteKey','XXX');

Each time the MATLAB Analysis code is executed, it will write the estimated time of arrival (ETA) for Uber to your ThingSpeak channel. To track the ETA over time, schedule the MATLAB code with TimeControl. I am running the code every 5 minutes to get an idea of when the peak times are for Uber to pick me up at my office in Natick, MA. Check out the ThingSpeak channel number 840700 to see the estimated times.

Uber_Ride_Estimate_Data

Step-by-step project details are available at Hackster.io.

]]>
https://blogs.mathworks.com/iot/2016/02/05/uber-ride-analysis-with-thingspeak-and-matlab/feed/ 0
Reacting to Events in Your Data With MATLAB https://blogs.mathworks.com/iot/2016/01/21/reacting-to-events-in-your-data-with-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2016/01/21/reacting-to-events-in-your-data-with-matlab/#comments Fri, 22 Jan 2016 00:05:42 +0000 https://blogs.mathworks.com/iot/?p=1613

Chris Hayhurst uses a solar water heater at his house to lower energy costs and use hot water in his house heated up by the sun. Chris is a consulting manager for The MathWorks and partnered with the... read more >>

]]>
Chris Hayhurst uses a solar water heater at his house to lower energy costs and use hot water in his house heated up by the sun. Chris is a consulting manager for The MathWorks and partnered with the IoT team to use ThingSpeak to collect data about his system and use ThingSpeak’s built-in MATLAB app to analyze it. In this project, Adarsh and I are going to show you how to send alerts when events are detected in the data by using the MATLAB Analysis app.

Solar water heating system

Chris’ home solar water heating system is an example of an IoT application that uses multiple sensors to collect data about a physical system.  Chris’s water heater measures ambient temperature, stored water temperature, collector temperature, and pump speed. All of this data gets collect by ThingSpeak and stored in Channel 29633.

Solar water heater

On days when the stored water temperature exceeds 50°C (122°F), there’s no need to use other methods to heat the store of water to a useful working temperature.  The pump should turn on only when the collector temperature is greater than the temperature of the stored water tank. If the pump turns itself on when the collector is cooler than the stored water temperature, valuable heat is lost from the stored water tank. Chris wants to be alerted of this condition, so that he can adjust the controller settings and increase the efficiency of the system.

IoT systems like Chris’ solar water heating system, typically gather large amounts of data but often the real interest is in events that occur infrequently. The ability to take action when these infrequent events occur is important and requires a mechanism to detect such an event and launch an action. We are going to use the data collected by the solar water heating system stored in the ThingSpeak Channel 29633 and use the MATLAB Analysis app to detect a condition and alert him using Twitter.

solar-water-heater-inside

MATLAB Event Detection

To detect an erroneous pump behavior event, create a new MATLAB Analysis on ThingSpeak with the following code:

% Read data from fields 1, 2, and 3 from channel 26633.
% Field 1 represents the stored water temperature
% Field 2 represents the collector temperature
% Field 3 represents the state of the pump - on or off
[data, time] = thingSpeakRead(29633, 'Fields', [1, 2, 3]);

% Assign measurements to individual variables
storeTemp = data(1);
collectorTemp = data(2);
pumpState = data(3);

% Check if collectorTemp is less than storeTemp
isCollectorCooler = collectorTemp < storeTemp;

% Identify if pump is on while the collector is cooler.
% We apply a logical AND operation to detect an event only when collector
% is cooler than store temperature and the pump is on.
eventDetected = isCollectorCooler & pumpState

Press the ‘Run & Save’ button to save the MATLAB Analysis App. The code above sets eventDetected to 1 every time the collector temperature is cooler than stored temperature and if the pump is on. Now that we can detect the event, we need to set the MATLAB App to be run on a schedule. To do this, we will setup a TimeControl to run our MATLAB code every 5 minutes.

TimeControl options

Sending Alerts using MATLAB Analysis

So far, we’ve created a MATLAB Analysis to detect events in the data being collected in the solar water heater data channel. We associated our MATLAB Analysis code with a TimeControl to have it run every 5 mins to check for our event of interest. To receive a notification via Twitter when the pump is on incorrectly, we can use MATLAB Analysis to send a Tweet.

First, you need to link your Twitter account to your ThingSpeak account. Then, add the following lines of code at the end of your MATLAB Analysis code to send a Tweet when an event is detected:

If eventDetected
webwrite('http://api.thingspeak.com/apps/thingtweet/1/statuses/update',
'api_key', '<ThingTweet_APIKey>', 'status', 'Alert! Solar pump error!')
end

Be sure to replace <ThingTweet_APIKey> with your ThingTweet API Key.

If the solar water heater pump turns on at the wrong times, you will get a Tweet to let you know!

Next Steps

This example shows you the power of some of the ThingSpeak apps that we make available to you to experiment with. The MATLAB Analysis app is really powerful and can be used to detect events in your data and send alerts. MATLAB Analysis can be used for all sorts of calculations and orchestrations of different web services. We could have also used MATLAB to control the pump.

Feel free to try this example and take it further…

  • Reading data from fields in different channels
  • Combining data from fields in a channel and data read from a website such as a weather station or weather forecast.

What will you MATLAB?

]]>
https://blogs.mathworks.com/iot/2016/01/21/reacting-to-events-in-your-data-with-matlab/feed/ 4
element14 Webinar: How To Use MATLAB and Simulink With ThingSpeak https://blogs.mathworks.com/iot/2015/11/11/element14-webinar-how-to-use-matlab-and-simulink-with-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/11/11/element14-webinar-how-to-use-matlab-and-simulink-with-thingspeak/#respond Thu, 12 Nov 2015 02:46:00 +0000 https://blogs.mathworks.com/iot/?p=1554

element14 is hosting a free webinar, “How To Use MATLAB and Simulink With ThingSpeak“, a free webinar hosted by Eric Wetjen of MathWorks. Join the webinar live on November 12, 2015 at... read more >>

]]>
element14 is hosting a free webinar, “How To Use MATLAB and Simulink With ThingSpeak“, a free webinar hosted by Eric Wetjen of MathWorks. Join the webinar live on November 12, 2015 at 10am EST or watch a recording at a later time.

Car Counting Camera

This webinar will show how you can use MATLAB and Simulink with ThingSpeak, an Internet of Things data collection platform. ThingSpeak can be used to collect, analyze and act on data sent from devices such as Raspberry Pis and Arduinos. To illustrate this, a car counter is implemented overlooking a busy highway using a Raspberry Pi 2 and a webcam.  In this demonstration, Simulink is used to deploy the car-counting algorithm on the Raspberry Pi which is connected to ThingSpeak. The traffic can be analyzed offline with MATLAB or online using ThingSpeak and its built-in MATLAB Analysis and MATLAB Visualizations apps.

Eric Wetjen MathWorks IoT

Eric Wetjen has been working in Product Marketing at MathWorks for the last 7 years. He focuses on bringing MATLAB analysis capabilities to low cost hardware, Test and Measurement equipment and Internet of Things devices.  Prior to MathWorks, Eric held various positions in Product Management and Application Engineering primarily in the telecom industry.  Eric holds a Ph.D. in Engineering from Brown University.

Sign up at element14

]]>
https://blogs.mathworks.com/iot/2015/11/11/element14-webinar-how-to-use-matlab-and-simulink-with-thingspeak/feed/ 0
Schedule MATLAB Code with TimeControl https://blogs.mathworks.com/iot/2015/11/03/schedule-matlab-code-with-timecontrol/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/11/03/schedule-matlab-code-with-timecontrol/#comments Wed, 04 Nov 2015 02:18:56 +0000 https://blogs.mathworks.com/iot/?p=1539

Here at our headquarters we have a weather station collecting lots of weather data and sending it to ThingSpeak. We have made that data public for use in your own projects. We write the temperature... read more >>

]]>
Here at our headquarters we have a weather station collecting lots of weather data and sending it to ThingSpeak. We have made that data public for use in your own projects.

MathWorks Weather Station

We write the temperature and humidity values from the weather station to a ThingSpeak channel. At some point in the project, we started to wonder about dew point calculations. We wrote some MATLAB code that combined the temperature and humidity to calculate dew point. I did this using the ThingSpeak app, “MATLAB Analysis”. You can try this out with ThingSpeak now by signing in, selecting Apps, MATLAB Analysis, New, selecting “Calculate Dew point”, and clicking “Create”. This happens to be one of our built-in examples using our weather station’s public data.

It is great that it was easy to calculate dew point with MATLAB, but I want to see this analyzed data over time just like any other sensor data. The solution is a powerful combination of MATLAB Analysis and TimeControl. We use MATLAB Analysis to do the analysis and write the data to a ThingSpeak channel. Then, we use the TimeControl app to repeat the analysis every 5 minutes.

To setup MATLAB Analysis on a schedule, sign into ThingSpeak, select Apps, TimeControl, and New TimeControl.

Dew Point TimeControl in ThingSpeak

My MATLAB code now runs every 5 minutes doing analysis and writing data to my ThingSpeak channel. The TimeControl settings can be tailored to your needs such as executing MATLAB code once a day or only on weekends. This combination of MATLAB Analysis + TimeControl allows you to create continuous analysis of your project data.

To try this out for yourself, we have a public channel of weather station data that we have collected in Natick, MA at our headquarters. You can use that data and do your own MATLAB Analysis and writing the results back to your own channel. Also, Check out the ThingSpeak Documentation where we have a complete tutorial for you to help get started with ThingSpeak and MATLAB.

]]>
https://blogs.mathworks.com/iot/2015/11/03/schedule-matlab-code-with-timecontrol/feed/ 1
Video Introduction to ThingSpeak and the Internet of Things https://blogs.mathworks.com/iot/2015/09/25/video-introduction-to-thingspeak-and-the-internet-of-things/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/09/25/video-introduction-to-thingspeak-and-the-internet-of-things/#respond Fri, 25 Sep 2015 15:13:14 +0000 https://blogs.mathworks.com/iot/?p=1515

Our very own Robert Mawrey produced a video introducing ThingSpeak and the Internet of Things. ThingSpeak is an open data platform for the Internet of Things. Your device or application can... read more >>

]]>
Our very own Robert Mawrey produced a video introducing ThingSpeak and the Internet of Things.

ThingSpeak Intro Video

ThingSpeak is an open data platform for the Internet of Things. Your device or application can communicate with ThingSpeak using a RESTful API, and you can either keep your data private, or make it public. In addition, use ThingSpeak to analyze and act on your data. ThingSpeak provides an online text editor to perform data analysis and visualization using MATLAB®. You can also perform actions such as running regularly scheduled MATLAB code or sending a tweet when your data passes a defined threshold. ThingSpeak is used for diverse applications ranging from weather data collection and analysis, to synchronizing the color of lights across the world.

At the heart of ThingSpeak is a time-series database. ThingSpeak provides users with free time-series data storage in channels. Each channel can include up to eight data fields. This tutorial provides an introduction to some of the applications of ThingSpeak, a conceptual overview of how ThingSpeak stores time-series data, and how MATLAB analysis is incorporated in ThingSpeak.

[via MathWorks]

]]>
https://blogs.mathworks.com/iot/2015/09/25/video-introduction-to-thingspeak-and-the-internet-of-things/feed/ 0
Counting Cars and Analyzing Traffic https://blogs.mathworks.com/iot/2015/09/18/counting-cars-and-analyzing-traffic-with-thingspeak/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/09/18/counting-cars-and-analyzing-traffic-with-thingspeak/#comments Fri, 18 Sep 2015 21:05:59 +0000 https://blogs.mathworks.com/iot/?p=1509

The power of any tool becomes magnified when you start combing it with other tools. In this File Exchange project by Eric Wetjen, he demonstrates a powerful project by using a webcam to gather live... read more >>

]]>
The power of any tool becomes magnified when you start combing it with other tools. In this File Exchange project by Eric Wetjen, he demonstrates a powerful project by using a webcam to gather live traffic video of Route 9 in Natick, MA, using Simulink to deploy a car-counting algorithm to a Raspberry Pi, using MATLAB to perform analysis, and using ThingSpeak to collect and share the analyzed data with others.

Car Counting Camera

The project uses a Raspberry Pi 2 and USB webcam acting as a sensor. The webcam picks up traffic flowing in both directions. Once the algorithm for detecting cars is modeled in Simulink, the algorithm gets deployed on the Raspberry Pi. The Raspberry Pi sends the raw data to ThingSpeak on regular basis where it is analyzed using the MATLAB Analysis app on ThingSpeak.

MATLAB_car_counting_display

After sending to ThingSpeak, Eric created a MATLAB Analysis app to calculate the daily traffic-volume on ThingSpeak Channel 51671. Now that the data is public, others could use this processed data within apps such as Waze to optimize directions using analyzed traffic flows.

MATLAB Traffic Analysis ThingSpeak Visualization

Check out the article for the complete project details and all of the code to get your Raspberry Pi + ThingSpeak analysis project started.

]]>
https://blogs.mathworks.com/iot/2015/09/18/counting-cars-and-analyzing-traffic-with-thingspeak/feed/ 3
Updates to the MATLAB Analysis App with Lots of Example Code https://blogs.mathworks.com/iot/2015/09/09/updates-to-the-matlab-analysis-app-with-lots-of-example-code/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/09/09/updates-to-the-matlab-analysis-app-with-lots-of-example-code/#comments Wed, 09 Sep 2015 21:54:53 +0000 https://blogs.mathworks.com/iot/?p=1497 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’), ... read more >>

]]>
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 https://thingspeak.com/account). 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:

MATLAB Code:

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

Output:

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

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.

]]>
https://blogs.mathworks.com/iot/2015/09/09/updates-to-the-matlab-analysis-app-with-lots-of-example-code/feed/ 3
Analyzing CheerLights with MATLAB https://blogs.mathworks.com/iot/2015/09/04/analyzing-cheerlights-with-matlab/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/09/04/analyzing-cheerlights-with-matlab/#respond Fri, 04 Sep 2015 21:13:01 +0000 https://blogs.mathworks.com/iot/?p=1486

CheerLights is an Internet of Things project created by Hans Scharler that allows people’s lights all across the world to synchronize to one color set by Twitter. This is a way to connect... read more >>

]]>
CheerLights is an Internet of Things project created by Hans Scharler that allows people’s lights all across the world to synchronize to one color set by Twitter. This is a way to connect physical things with social networking experiences and spread cheer at the same time. When one light turns red, they all turn red.

CheerLights uses ThingSpeak to collect the latest color. We get the color value by following “CheerLights” on Twitter using the TweetControl app. When someone Tweets using “CheerLights” and a color name, the TweetControl app writes the color to the CheerLights Channel on ThingSpeak. Other developers wanting to join the CheerLights project read in the latest color value using the ThingSpeak Channel API and then set their light color to the same one.

With some MATLAB Analysis and Visualizations, I know that currently red is the most popular color on CheerLights! I have recently taken advantage of the MATLAB integration with ThingSpeak. Under Apps -> MATLAB Analysis, we have an example that will show you how to analyze the public CheerLights Channel on ThingSpeak to determine the most requested color. The MATLAB Analysis example is called, “Analyze text for the most common color”.

Example MATLAB Visualization Code

lights = thingSpeakRead(1417,'OutputFormat','table','NumDays',30);
hist(categorical(lights.LastCheerLightsCommand))
set(gca,'XTickLabelRotation',45)

CheerLights MATLAB Histogram

People all over the world have joined CheerLights by making all kinds of light displays, apps, and browser plugins. I recently created a CheerLights display for my parents using a LIFX Wi-Fi Light Bulb. If you want to control all of the lights, just send a Tweet using Twitter that mentions @CheerLights and a color.

“@CheerLights Let’s go Blue!”

Check out CheerLights.com for more detail and for ideas on how to join the project. We are all connected!

]]>
https://blogs.mathworks.com/iot/2015/09/04/analyzing-cheerlights-with-matlab/feed/ 0
You’ve Collected Lots of IoT Data, Now We Can Help You Figure Out What It Means! https://blogs.mathworks.com/iot/2015/08/20/you-have-collected-lots-of-iot-data/?s_tid=feedtopost https://blogs.mathworks.com/iot/2015/08/20/you-have-collected-lots-of-iot-data/#comments Thu, 20 Aug 2015 19:27:30 +0000 https://blogs.mathworks.com/iot/?p=1475

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... read more >>

]]>
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 ThingSpeak.com!

 

]]>
https://blogs.mathworks.com/iot/2015/08/20/you-have-collected-lots-of-iot-data/feed/ 2