ThingSpeak with Arduino and Processing
Light Sensor and Motion Sensor Using ThingSpeak, Arduino, and Processing 15 Apr 2011
Light Sensor and Motion Sensor Using ThingSpeak, Arduino, and Processing 15 Apr 2011
“Thingspeak.com” allows one to post information gathered by a networked device in real time. I decided that I would test out the system with a simple light sensor. Then, I went further by developing a new Processing application which detects motion using a webcam and posts it to a ThingSpeak channel.
I’ve been working with microcontrollers for some time, but Thingspeak.com is a great way to connect those microcontrollers to the world.
First, I made a simple program to learn how to send an HTTP GET request to thingspeak.com: thingspeaktest.zip. The program sends any numeric key press as a value to the thingspeak server.
Then I made the circuit to interface the light sensor to the Arduino.
The code I uploaded to the Arduino couldn’t be simpler:
Then, I modified my original processing app so that it forwards data received from the arduino to the server: click here to download
After making the system with the light sensor, I had the idea to make a motion sensor using a webcam.
The Processing application essentially does the following:
Takes the difference between frames continuously for thirty seconds (at only 2 frames per second to not overload the CPU).
At the end of the thirty seconds, takes the max difference between frames and interprets this as the movement value.
Sends this movement value to ThingSpeak.com
Click here for a live graph of the light sensor data(Not active)
Click here for a live graph of the motion data. (Not Active)
After getting it to work, I checked the output after leaving it over night. I was surprised to find that in the dark, the output was a regular sawtooth wave. What is the source of this strange signal? Noize? No. I actually have a clock on the wall which displays the time as the number of dots illuminated for each digit. The sawtooth signal is due to the last digit of the time incrementing—pretty cool!