Cloud-based People Counter Using MATLAB and ThingSpeak

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.

Forgetting Something on Your To Do List? Use MATLAB to Analyze Your Tasks.

Allie Fauer, a designer from New York, has released another awesome Instructable tutorial on how to build a “To Do List Reminder Light”. This project is very creative and easy to build on your own. Allie tracks her tasks on an app called Todoist. With a little help of the MATLAB Analysis app on ThingSpeak, Allie is able to analyze her tasks and alert herself of anything overdue. She gently reminds herself with a glowing “Remembrall” globe.

To Do List Reminder Light

Allie uses the MATLAB Analysis app on ThingSpeak to check her to do list and see if anything is overdue. If a task is overdue, the MATLAB code writes the task overdue into a ThingSpeak channel. The MATLAB code is very straightforward and does a bit of analysis on her task list to see what is overdue. To get the MATLAB Analysis code to keep checking her task last, she schedules the MATLAB code using the TimeControl app on ThingSpeak.

Allie also has other ideas on how to make use of her status light:

  • Alert you when you’ve forgotten to water your plants
  • Tell you when you’re out or range of important objects like your keys or wallet
  • Combine with IFTTT to alert you when you’ve forgotten to respond to emails or phone notifications

To build your own Remembrall light, follow the step-by-step tutorial on Instructables.

Analyzing Squirrel Behaviour and Weather Forecasting with MATLAB and ThingSpeak

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

Squirrel Monitoring

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

Squirrel Cafe System

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

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

 

Weather Station with Particle, SparkFun, ThingSpeak, and MATLAB

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

IoT Quick Start With the Arduino MKR1000 and ThingSpeak

If you are looking to start with the Internet of Things, then try out the Arduino MKR1000 and connect it to the ThingSpeak IoT Platform. We have put together a complete tutorial that uses the MKR1000 to collect data about your Wi-Fi signal and send it to ThingSpeak for storage, analysis, and visualization.

Arduino MKR1000

The Arduino MKR1000 is a great starting point when learning about the “things” in IoT. The MKR1000 has a microcontroller, Wi-Fi module, encryption module, and a battery-charging circuit. It’s easy to get started and once you get it connected to ThingSpeak, you have a lot of “cloud power”. ThingSpeak has a suite of apps to allow the Arduino to post messages to Twitter, do data analysis, show charts and visualizations, and be controlled by schedules and external events. With these building blocks you can prototype any IoT system.

ThingSpeak Channel Data

Once you have your data on ThingSpeak, you can analyze and visualize the data with built-in MATLAB apps.

[via ThingSpeak Tutorials]

ThingView – Mobile App to See ThingSpeak Charts on Android Devices

Cinetica has released to Google Play, a new app to see ThingSpeak charts on Android smartphones and tablets. The app is called ThingView and has already reached 5,000 installs on Android devices!

ThingView Android App for ThingSpeak Charts

Even if you do not have devices and sensors sending data to ThingSpeak, you can still use ThingView to see public channels. For example, if you want to see the charts created by sensors in my house, just add Channel ID 9 to ThingView. You see charts of light levels and temperature generated by my house.

Check out ThingView on Google Play!

Explore your IoT data with ThingSpeak and MATLAB

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

Getting Started with IoT using the Particle Electron and ThingSpeak

Julien Vanier over at Hackster.io created a new tutorial showing you how to get started with the Internet of Things using the new Particle Electron and ThingSpeak.

Particle Electron Kit using ThingSpeak IoT

The Electron is a new 3G connected IoT device using cellular data and works anywhere you can get 3G in the United States. It is really awesome to plug-in a device and get it connected without the issues of Wi-Fi. This development kit also makes it possible to build battery-powered, mobile sensors. Good thing that ThingSpeak supports GPS data and offers sensor data analytics.

Check out Julien’s tutorial to go “From 0 to IoT in 15 Minutes” and other ThingSpeak projects on Hackster.io.

Uber Ride Analysis with ThingSpeak and MATLAB

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.

Reacting to Events in Your Data With MATLAB

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?