Use MATLAB ‘timetable’ to Merge ThingSpeak Data Channels

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.

Basement Dehumidifier Tweets Its Humidity with ThingSpeak and ESP8266 Wi-Fi

ThingSpeak user, Spencer, adapted a humidifier that sits in his basement. He is solving a common issue about humid basements. If your dehumidifier fails, you get wet things you have stored and then mold. Spencer created a humidity board using the DHT22 that measures humidity and then reports the data to his ThingSpeak Channel via the ESP8266 Wi-Fi module. Once the data is stored in ThingSpeak, he uses ThingSpeak React to update Twitter when things get out of whack.

Basement Dehumidifier Twitter

[via Twitter]

DIY Weather Station with Arduino, Processing, and ThingSpeak

[lars] created a weather station from scratch using sensors and bits from SparkFun and Adafruit. Lars wanted to log weather data and access it from remotely. He built the weather station using humidity, temperature, pressure, and light sensors collecting data from his apartment in Ithaca, NY. Originally, Lars was collecting data with his own web application created with PHP and MySQL. He has since started publishing his data to ThingSpeak where others can view the data and potentially build applications.

ThingSpeak Weather Station

Behind the scenes, Lars uses the Arduino microcontroller to collect data from the sensors and uses Processing to publish data to his ThingSpeak Channel.

From Lars’ project site:

The goal of this project is to log some weather data and be able to access it from anywhere. There is some sensor data (temperature, relative humidity, pressure, and ambient light) and some computed data (dew point). You can see the weather condition in my apartment in Ithaca, NY at my ThingSpeak Channel 346. You can also look at the Google Chart of my own MySQL solution, which I no longer maintain.

Check out a detailed breakdown of the Weather Station project and more awesome projects on Lars’ project site, called “make.larsi.org“.