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.
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 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.
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 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.
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.
We are thrilled to announce the official ThingSpeak Communication Library for Arduino and Particle devices. This library enables an Arduino or other compatible hardware to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with built-in MATLAB analytics and visualization apps.
Arduino IDE Installation
In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.
Particle / Spark IDE Installation
In the Particle/ Spark Web IDE, click the libraries tab, find ThingSpeak, and choose “Include in App”.
- Arduino or compatible using an Ethernet or Wi-Fi shield (we have tested with Uno and Mega)
- Arduino Yun running OpenWRT-Yun Release 1.5.3 (November 13th, 2014) or later.
- Particle Core or Photon (Formally Spark)
The library includes several examples to help you get started.
CheerLights: Reads the latest CheerLights color on ThingSpeak, and sets an RGB LED.
ReadLastTemperature: Reads the latest temperature from the public MathWorks weather station in Natick, MA on ThingSpeak.
ReadPrivateChannel: Reads the latest voltage value from a private channel on ThingSpeak.
ReadWeatherStation: Reads the latest weather data from the public MathWorks weather station in Natick, MA on ThingSpeak.
WriteMultipleVoltages: Reads analog voltages from pins 0-7 and writes them to the 8 fields of a channel on ThingSpeak.
WriteVoltage: Reads an analog voltage from pin 0, converts to a voltage, and writes it to a channel on ThingSpeak.
Complete source code and examples for the ThingSpeak Library are available on GitHub.