Topics I'm Exploring:
Pi/Arduino/Photon Sensors: Temperature,
Devices: Darlington array,
MCP3008 (analog input),
A variety of motors,
Programming in Shell, C, Python,
Security camera app,
Unifying Pi software structure,
Pi access and control from the Internet,
Wireless device control.
Sunday, January 18, 2015
71: My Pi as a Time Lapse Camera
I used raspistill taking 1 still per minute. Moved the JPEGs to my Mac and turned it into MP4 at 10fps. 450 minutes crunched to 45 seconds.
70: PWM -- Another Reason to Front-end Your Pi with an Arduino
I just discovered the joys of Arduino PWM (pulse width modulation). Easy on my Nano, except for 1 GPIO pin is's a nasty kludge on the Pi. Ha! (I listed USB-connected source code for Pi and Arduino back in Post 66.)
BTW: PWM is useful for things like dimming LEDs. In my case, I wanted a user to notice differences in output of mini-motor vibrators (e.g., from Adafruit). You have 256 output levels: 0=none(OFF), 127=half, 255=full(ON).
P.S.: While Pi prices are pretty standardized, Arduino prices are all over the place. I've noted Internet-listed Nanos (my favorite model) at anywhere from over $30 down to $3.30 (no cable, soldering required, delivery from China).
69: To Catch a Thief (Raspberry Pi Security System)
My daughter's dog is an inveterate thief of any food left within even implausible reach. The previous time we dog-sat for him he managed to steal over a dozen home-made cookies. So I decided to catch him in the act using my Pi+camera+Python program. I have a (fairly) portable Pi system:
Notes on the configuration:
The 12,000mAh battery will power the Pi for about 10 hours. Unfortunately the battery can either charge or discharge but not both at once. Otherwise it would make a very nice UPS (uninterruptable power supply).
As shown, it has LED output, PIR and Pi camera input and a 7-segment display. On the side there is a Cat5 socket (provides 8 wires for remote sensors) and a pair of relay switches.
I use the speaker for text-to-speech output.
Anyway, I baited the kitchen counter with a piece of meat and set the porta-Pi aimed at the counter. On my first attempt my program just used the camera to detect motion. About once per second the Pi can take a grayscale 120x90 pixel image which the program compares pixel-by-pixel with the previous image. When more than an arbitrary number if pixels have changed by more than an arbitrary difference then the program takes a full-res image and saves it to the SD card filesystem.
This first test failed for 2 reasons: a) the dog ignored the bait; b) while we were away for about 3 hours the sun went under a cloud and back out about 100 times and my dumb program decided that each such change was "motion."
So, for my second try I added the PIR device -- logic as follows:
IF the PIR detects motion AND the 2 camera images differ THEN store the high-res image.
This attempt failed too: at a distance of about 12' the PIR didn't notice the 30-pound white dog (but he stole the meat).