ThingSpeak IoT Blog

Send Bulk Sensor Data to ThingSpeak for Analysis


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

Using IoT Devices as Teaching Aids in Engineering Education


We are excited to return to the 124th Annual American Society of Engineering Education Conference & Exposition! ASEE is committed to fostering the exchange of ideas, enhancing teaching methods and curriculum, and providing prime networking opportunities for engineering and technology education stakeholders such as: deans, faculty members, and industry and government representatives. MathWorks is proud to sponsor and support engineering education initiatives.

This year, I will be hosting an IoT workshop with Dr. Gerald W. Recktenwald, Portland State University, Jeff Branson from SparkFun, Dr. Duncan James Bremner P.E. from the University of Glasgow. Our session is called, “Your Head in the Clouds: A Hands-on Workshop on Using IoT Devices as Teaching Aids“. We will explore IoT hardware and software to be used as teaching aids in engineering education. We will use tools from SparkFun, ThingSpeak, and MATLAB to build an IoT project in the workshop. For more information, visit the ASEE session website.

American Society for Engineering Education Conference

Greater Columbus Convention Center
400 N. High Street
Columbus, OH

W426B·WEDNESDAY WORKSHOP:

Your Head in the Clouds: A Hands-on Workshop on Using IoT Devices as Teaching Aids
Wednesday,  June 28, 2017 1:30 PM to 5:30 PM

The Data Science Behind BBQ


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.

IoT Day is the Day to Learn About Our New MATLAB Analytics Features


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!

Build IoT Projects on Arduino Day Using MATLAB and ThingSpeak


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!