Saturday, February 23, 2013

Artificial Finger Arduino Critter Cam

I needed a reason to start a new project that would involve an Arduino. It came in the form of a mystery involving the dog food bin on my carport. For several mornings when stepping out of my back door to go to work I noticed the dog food bin lid was propped open. Some sort of critter was opening the bin and helping itself to the dog food. I wanted to know what it was and figured the Arduino would be a good build platform for an automatic camera that could get a picture of it.



I would need a camera and some way to detect when the dog food bin was opened and have it take some pictures. I had an older Samsung digital camera lying around and a small 110 volt DC solenoid that I thought could be used to press the shutter button. The camera shutter button also activated the auto-focus when it was depressed with about half of the force needed to actually take a picture. For this camera the auto-focus was needed in order to take decent pictures. Trying to get the solenoid and lever system to perform both the auto-focus and shutter actions turned out to be really complicated. I needed a simpler way to take a picture.

I pulled out my phone and thought about trying to use the Android camera API to take the picture. This I thought I could do but was really worried that the critter might find a better midnight buffet before I could code that up. I would then lose my chance to get some hard evidence on the perpetrator. The camera app was simple enough to operate manually so I figured that if I could make a simulated finger I could use the solenoid to have it touch the phone screen and take the picture.

Modern touch screen panels work on the principle of a change in capacitance caused by your finger touching the screen. A capacitor is made up of two conductive plates separated by an insulator. The capacitance can be changed by varying the area of one or both of the conductive plates. In the case of the touch screen there is a conductive layer behind the glass of the screen acting as one of the plates of the capacitor. The glass is the insulator and the other conductor of the capacitor is formed by a finger when it comes in contact with the glass. When the finger touches the glass the increase in capacitance changes the frequency of an oscillator which when measured can be used to determine where the screen has been touched. For multi-touch panels there is actually an array of conductors behind the glass which allows for the detection of more complex touches but the principle is the same. You still need a finger to operate it.


I had a pencil shaped touch screen stylus that I sometimes used with an iPad.  I found that it worked on the phone screen only when I was holding it by the metal body. When I touched the screen with the stylus insulated from my hand it did not register a touch. I had to find something that caused a change in the screen capacitance like a finger did. The stylus by itself could not do that.

I tried using a metal strap about the size of my finger hoping the metal would be enough to trigger a touch. That didn't work so I started adding larger and larger pieces of aluminum foil to the strap and it eventually did activate the touch screen. When a flat area of the metal strap with the added aluminum foil came in contact with the touch screen it acted like an artificial finger was touching the screen.


I built a frame for the setup out of wood that held the phone in place and used a hinge to make a swing arm for the artificial finger. I mounted the metal finger so that it touched the phone where the camera shutter button was on the screen. The solenoid pulled the finger over to the phone when activated and a small spring pushed it back when released. A junk box 30 volt printer power supply supplied enough power for the solenoid to operate the arm and a hook held it in place so that when released it was ready for the next picture cycle.

The critter only came at night so I would need to add lights as the cell phone did not have a built in flash. A quick trip to Harbor Freight netted an LED flashlight with 27 LEDs. I liberated the LED panel from the housing and mounted it to the front of the frame.

I now needed a small circuit board to provide for level conversion between the Arduino and the higher voltages and currents of the solenoid and LED panel. Some simple NPN switching circuits would do the trick so I grabbed some transistors from the parts bin, drew up, etched and drilled a circuit board using a sharpie, some copper clad and Ferric Chloride and then had what I needed to control the camera, the LED panel and the artificial finger.




I mounted a momentary switch on the dog food bin which would activate when the lid was opened and connected it to the Arduino. The phone was mounted on the frame and adjusted so the finger was lined up with the shutter button.  I then coded up an Arduino sketch to perform the necessary timing to take the pictures.  I placed the entire assembly on top of a table made of 2x10s and angled it down so the camera would be pointing where I thought the critters would likely be after turning over the food bin.



Here is a video showing Critter Cam operation.



Finally after a few nights of waiting I had pictures of those critters!


Also of Note: Trying to keep the phone from going to sleep while waiting to take pictures was a challenge. I tried simply taking a picture every few seconds but it would still sometimes shut the screen down and go into sleep mode. While fiddling with the phone charger I discovered that if I cycled the charger power while the phone was in sleep mode it would wake up and reset the sleep timer. So, all I had to do to keep the phone from going into sleep mode was to have it on a charger and cycle the power to the charger before it timed out and went to sleep. A solid state 110 volt AC relay connected to the Arduino did the trick. The Arduino sketch cycled the charger power every 90 seconds and that kept the phone camera application open and ready to take pictures all night long.

3 comments:

Anonymous said...

You can use an Android service that runs in the background to control the camera to eliminate the need to keep the screen on.

Unknown said...

Hi, I need to aticate a touch screen inside an environmental chamber at -30degrees Celsius (would not be cool to go inside). So, I will need an artificial finger to do the job for me. I am trying to replicate your system, but without any good results so far. Could you give more details about how you bilt your finger? My one works onely sometimes, it is not realiable.

Art Barrios said...

Kyvia, what type of screen are you working with? If it is a capacitive touchscreen like on a modern cell phone then you should be able to activate it with a large enough piece of metal or aluminum. If it is a resistive screen then you may have to apply more pressure.