Raspberry Pi Camera: Face Recognition and Email Alert

Though Open CV installation is highly time consuming process on a Raspberry Pi A+, it has multiple uses when it comes to image recognition. Framework created by Tony in his face recognition treasure box project is modified here for a camera which sends messages whenever it finds someone is in the backyard.

How it works?

Camera records images constantly and then passes it to the Open CV for face recognition. Once it recognizes a face in the image, it sends alert to the email address with the image in the attachment. You can modify this code further to include any other object recognition such as cat etc.

Here is the email message I received whenever peeked into camera.

blog

You can download the code which uses OpenCV 2.4.9 from here. Before you use it, you need to generate a password for the app from Gmail.

Gmail provides the following guidelines to generate the app password for emailing directly from Raspberry Pi. Use “other” option to generate the password for the app to login to Gmail and send an email.

Delicious Liquid Nitrogen Science

Today I planned to visit the newly opened “The Village Workshop” in Northville, MI for 3D printing some parts. It is really awesome facility to have in the neighborhood for every maker.

While waiting for 3D printing assistance at the entrance, I bumped into a demonstration by Willie from Kold Ice Cream. Both me and my daughter were stunned to see fumes of liquid nitrogen on the table.

IMG_5641

Willie was dropping liquid nitrogen on the hands, serving snacks dipped in it which was more fun to see exhaling cold fumes. He offered us a neat explanation behind cold nitrogen boiling at room temperature with boiling point of -196 deg C and turning into vapors. Though it is dangerous to leave your fingers for longer period in the liquid nitrogen, Willie seems fine dropping liquid nitrogen on hands and his shirt.

He showed me and my daughter some cool stuff, like starting fire and then extinguishing with nitrogen fumes and liquid. Too much liquid nitrogen around the flame stops it due to lack of oxygen nearby.

Most important part for my daughter was the liquid nitrogen ice cream preparation. It turned out that it was best ice-cream she ever tasted.

IMG_5649

Delicious science study was really cool for all the kids visiting the workshop today. I hope it attracts them to creative developments in STEM field.

Calculation of Heat Pumped by Peltier

Peltier units are simply heat pumping devices and have really low COP compared to conventional vapor compression cycle based units. To estimate, how much amount of heat is pumped, I did a simple experiment. I bought a simple Peltier unit from Adafruit and glued it to a heat sink with thermal tape.

I put the heat sink in the measured amount of water (160 gm) and recorded temperature with TMP 35 sensor. Initial temperature of water was 31 deg C and final temperature after 300 seconds was 44 deg C.

Resistance of the Peltier was around 3.1 ohm from the current (2.6 A) and voltage (9.6 V) measurement.

  1. Amount of total energy energy dissipated (Qd) in water is 8706 J from m*Cp*(Tf-Ti)
  2. Energy supplied (E) over the 300 seconds was found to be 7488 J from V*I*t
  3. Heat generated to resistance (Qr) is small 21.9 J from I^2*R loss.
  4. Amount of heat removed from cold side = Qd – Qe – Qr = 1197 J or about 4 W
  5. This comes to COP = 4 W/(2.6 A*9.6 V) = 0.16

This calculation is rough estimate of the COP as thermocouple was +/- 2 deg C accuracy. Also this test does not indicate the performance of peltier in other operating conditions. It was done just to know how good is the peltier performance.

Peltier Cooling and Heating with Arduino

Cooling with Peltier

I used a Peltier fan heat sink unit sold by Adafruit for this work. Small plate connected to this Peltier unit cools to a really low temperature of -7 deg C almost instantly due to its small size. I used Arduino UNO with N-channel MOSFET to control the Peltier unit. Program and Arduino circuit used came from this work on garagelab.com.

N-Chnnel MOSFET
Peltier with fan heat sink unit

Heating and Cooling a Peltier

I was working with a friend to explore option of simultaneous heating and cooling for neonatal care in India (http://www.palav.org/). I could not find easily an option for simultaneous heating and cooling with Peltier. There are many posts for cooling control. Several people mentioned using H bridge for reversing currents on Arduino forums. Still it was difficult to find which one will work with Peltier unit that I have. This is just an attempt to know that it is possible to use H bridge for this purposes. It gives precise control over temperature required with both heating and cooling. Ultimately I found it is possible but costly option for amount of heating and cooling required.

For simultaneous heating and cooling H-bridge is needed. I used Pololu simple high power motor controller for this work and used sample program from Pololu with Arduino. Software serial library is also needed with this, which is available on Arduino website. Change input to setMotorSpeed from -3200 to 3200 to control the cooling and heating respectively. This works great for the Peltier fan heat sink unit.

Connecting Pololu is easy with image from the H-bridge user guide.

Connect Arduino digital pin 4 to Simple Motor Controller RX and Arduino GND to Simple Motor Controller GND.

#include 
#define rxPin 3  // pin 3 connects to smcSerial TX  
#define txPin 4  // pin 4 connects to smcSerial RX
SoftwareSerial smcSerial = SoftwareSerial(rxPin, txPin);
 
// required to allow motors to move
// must be called when controller restarts and after any error
void exitSafeStart()
{
  smcSerial.write(0x83);
}
 
// speed should be a number from -3200 to 3200
void setMotorSpeed(int speed)
{
  if (speed < 0)   
{     
smcSerial.write(0x86);  // motor reverse command     
speed = -speed;  // make speed positive   
}   
  else   
{     
smcSerial.write(0x85);  // motor forward command   
} 
  
smcSerial.write(speed & 0x1F);   
smcSerial.write(speed >> 5);
}
 
void setup()
{
  // initialize software serial object with baud rate of 19.2 kbps
  smcSerial.begin(19200);
 
 // the Simple Motor Controller must be running for at least 1 ms
 // before we try to send serial data, so we delay here for 5 ms
 delay(5);
 
 // if the Simple Motor Controller has automatic baud detection
 // enabled, we first need to send it the byte 0xAA (170 in decimal)
 // so that it can learn the baud rate

 smcSerial.write(0xAA);  // send baud-indicator byte
 
 // next we need to send the Exit Safe Start command, which
 // clears the safe-start violation and lets the motor run
 exitSafeStart();  // clear the safe-start violation and let the motor run
}
 
void loop()
{
 setMotorSpeed(-2800);  // full-speed forward
 delay(10000);
 // setMotorSpeed(3200);  // full-speed reverse 
 // delay(1000);
}