Hans on IoT

ThingSpeak, MATLAB, and the Internet of Things

Counting Cars and Analyzing Traffic 1

Posted by Hans Scharler,

The power of any tool becomes magnified when you start combing it with other tools. In this MakerZone 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.


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 MakerZone article for the complete project details and all of the code to get your Raspberry Pi + ThingSpeak analysis project started.

[via MathWorks MakerZone]

1 CommentsOldest to Newest

siva replied on : 1 of 1

hi,do rasp pi have the power to run the program continuously.what kind of data is send to thingspeak,is the no.of vehicle.

what type of method did you used to detect vehicle,is it edge detection or backgrpond subtraction

Add A Comment

Your email address will not be published. Required fields are marked *

What is 5 + 6 ?

Preview: hide