Heart Rate Using Webcam

Hear Rate Using Webcam

In May of 2012, a friend turned me onto a paper out of the MIT Media Lab by Ming-Zher Poh et. al. who were able to measure a person’s heart rate using a standard webcam.  It seemed hard to believe and I couldn’t let it go without testing it out.  I get out my webcam and laptop and in a few hours I had this:

More to come…

References

Poh, M.Z., McDuff, D.J., Picard, R.W., “Advancements in Non-contact, Multiparameter Physiological Measurements Using a Webcam,” IEEE Transactions on Biomedical engineering, vol.58, no.1, pp. 7-11, Jan 2011. doi: 10.1109/TBME.2010.2086456 PDF

 

Thermostat: Wireless, Web/Phone-Programmable

DRAFT – I’m still working on this project, and the post, but here’s the basic setup and some pictures…

Overview

This project was born because our programmable thermostat was a piece of junk and the Nest is expensive (although I ended up spending about as much on supplies as I would have on a Nest. The goals were 1) to have a thermostat that could be controlled via a smartphone and 2) to keep a log of temperature and thermostat data.

The project consists of five parts

  • HVAC system control hardware and temperature sensor in hallway
  • Temperature sensor in living room
  • Desktop application
  • iPhone app
  • MATLAB script to process log data

Hardware

HVAC system control hardware and temperature sensor in hallway

Arduino Uno (datasheet)
XBee 802.15.4 1.0 (XBee | Shield | Explorer USB)
Relay Shield (Wiki Page)
TMP36 Temperature Sensor (2x) (datasheet)

 
Device Data Pins
TMP36 #1 -> A0
TMP36 #2 -> A5
Control Pins for Thermostat
G Wire (Fan) -> 8
W Wire (Heat) -> 9
Y Wire (AC) -> 10
 
 

Thermometer (via Ethernet)


Arduino Mega (datasheet)
Arduino Ethernet Shield (datasheet)
TMP36 Temperature Sensor (2x) (datasheet)

Layout

 

 

 

Interface via Serial

Setting Thermostat Parameters

Goal Temperature
Delay Time
Mode

Sending Data via Serial

Temp 1
Temp 2
Goal Temp
Mode
State
Delay Time

Algorithms

Toggling HVAC On/Off

Processing Sketch

Thermostat Serial Message Parsing

Outdoor Weather via XML

Desktop Application

Status windows
Goal Temp/State/Mode control

Web-Based Control

Temperature control

Data Logging

MATLAB Data Visualization

Statistics of Birthdays

Facebook Friend’s Birthday Statistics

I few months ago I noticed that I had four Facebook friends who shared a birthday.  I was curious if that was remarkable.  An hour of Matlab scripting later and I had some Monte Carlo simulation results.  It turns out that if you have 500 Facebook friends you should expect to have around 10-20 days with 4 or more people with that birthday in common.  If you have 1000 facebook friends, you might even have a day or two that 8 people call their birthday.

Magic 8-Ball Pumpkin

Overview

The Magic 8-Ball Pumpkin was my 2012 entry in the Rosenwinkel pumpkin carving competition (which only John and I know is a competition at all).  John has won the last few with some pretty awesome pumpkins.  My entry this year was a working Magic 8-Ball, powered by an Arduino Mega and a set of sensors to detect motion.  A gyroscope and an accelerometer are used to detect when the 8-Ball has been picked up and/or shaken, while an IR receiver is used to power on or off in response to a remote control.  Here is a video of the working electronics, before it was installed into the Pumpkin.

And here are some pictures of the fully assembled pumpkin and it’s electronics.

Hardware

Arduino Mega ( datasheet )
Memsic 2125 Dual-axis Accelerometer ( datasheet | tutorial )
SerCLD v2.5 Serial Enables LCD ( datasheet | tutorial )
Gyroscope Module 3-Axis L3G4200D ( datasheet | tutorial )
IR Receiver Module TSOP38238 ( datasheet | tutorial )

Layout

Device Data Pins
LCD -> PWM 10
IR Reciever -> PWM 2
Accelerometer -> PWM 6 and 7
Gyroscope -> SDA (20) & SCL (21)

 

 

Algorithms

Motion Sensing

The motion sensing algorithm is the only non-trivial algorithm in the pumpkin.  The pumpkin identifies that it has been picked up by evaluating the maximum magnitude of the angular velocity vector from 20 measurements spaced 50 ms apart (i.e. 1 second of data).   If the max value is greater than 1e7 (units unknown) then the 8-Ball declares itself “picked up”.  If the max value is greater than 2.5e4 and the 8-Ball was already in a picked-up state, it remains “picked up”.  Only if the max angular velocity is below 2.5e4 does the 8-Ball deem itself “put down”.  This prevents the 8-Ball from thinking it has been put down when it’s only being help still in your hand.


The 8-Ball detects that it has been shaken using a different algorithm, mostly because I wanted to learn how to use the two-axis accelerometer, but also because people tend to shake the 8-Ball side-to-side, which you can’t detect with a rotation sensor.  The 8-Ball decides that is has been shaken if it is currently picked up and is the current magnitude of the acceleration in either axis is above 400 (units unknown).

 

 

IR Power On/Off

The power on/off algorithm it very primitive.  It just looks for more than 5 IR detections in the last 0.1 seconds, so any IR controller sending any IR signal will pretty much turn it on and off.

Arduino Code

MagicEightballPumpkin.ino