If you really want to use a seperate sensor to detect motion then a PIR sensor is a good choice. Best go for one with digital IC built in (like the one linked to by Michaelk) most have a simple high flag output that will pulse on detection.
There are some problems with PIR sensors:
- Odd blind spots (packaged lens dependent)
- False positive due to rapid ambient tempreture change.
- False positve due to stray white or infrared sources, the sun and car lights are the two biggest issues. You don't want to be taking a shot every time a cloud uncovers the sun. (this can be mitigated using a hood).
- False positive due to small animals entering FOV
To be able to read this you will have to either continually pole the sensor or come up with a way to make the GPIO give an interupt. Currently this is not in the vanilla kernal, a quick google gives at least one patch but I would go for polling.
I still like my idea of of capturing some frames with a time delay (say 10 frames with 100ms between each). These frames could be added to a circle buffer. If you take a bitwise average (I would guese geometric mean) and standard deviation of the previous 10 frames and compare it to the latest frame. If a cluster of pixels changes by more than 3 std deviations from that pixels average you call that a positive. Drop the frame buffer (10 shots) to the SD card and send a text/email. This would protect you from drifting ambient conditions. You could also apply some normalization for frame illumination, by normalizing each pixel to the the scene average. this would protect against false positive caused by rapid change in ambient lighting (frame being filled by a oncoming carlight. Nearby light coming on).
Best of all no need for additional sensor equipment.
No matter what you choose to do I would recomend against using bash for this project. I appreciate this is mainly due to personal choice but I find bash difficult to work with for much more than reasonable simple adminitritive scripts.
I personally would use python, although this is definatley personal choice. The best tool is the one
you can get the job done in