About me

Music producer, (ex-)DJ, electronics tinkerer, Linux enthusiast and coder.

Infrared motion sensor camera with Raspberry Pi Zero W, part 1


I've been planning to build a prototype battery-operated motion sensor camera using the latest addition to the Raspberry Pi family tree, the Zero W, which is quite a remarkable device for something smaller than my thumb. Even the wireless antenna seems quite revolutionary. With WiFi and Bluetooth built in, this tiny computer will be more than perfect for many IoT projects.

I've ordered a NoIR (No Infrared filter) camera with IR lights and a bag of IR leds just in case those prebuilt ones aren't satisfactory. Note that IR leds come in two wavelengths, 950nm and 850nm. The latter is so close to the (human) visible spectrum that some of the light can be seen with a naked eye, but it also produces a brighter image, so I guess it's best to buy both and experiment.

On the software side I'm considering motion, which I've used a few times before. I'll also test others such as motioneye and PiKrellCam that interestingly uses motion vectors for detection.

I'm also using a self-compiled version of ffmpeg to gain hardware-accelerated video encoding on Raspberry Pi devices and to avoid the bloaty dependencies of the regular Debian package.

I'll try to split this project into parts small enough to comprehend and blog about, but I have no idea what kind of obstacles await me – most likely various bugs and accidents accompanied by loud cursing.

Goals (may change)

  • Infrared lighting for nocturnal videos and photos. This is completely new to me.
  • Protection from the elements. This gadget would be perfect for catching wildlife in action. Batteries don't like cold, and a CPU starts crashing when it overheats, so it may not be easy in a country like Finland with temperatures (mostly) between -30°C and +30°C. Fortunately the CPU in Zero W doesn't seem to produce much heat. Water and especially condensation may also become a problem.
  • Connecting to any preconfigured wireless hotspot to allow live monitoring on a nearby mobile device. A GPIO button to attempt connecting instantly would be nice.
  • Conserving battery by switching IR lights intelligently. Hardware is easy, with a single GPIO pin driving a MOSFET to provide power for a bunch of leds, but I haven't found any software with suitable event triggers.
  • Self-sufficiency using a solar panel would be great, if not too bulky. I'd love the irony of a device like this documenting events long after mankind has foolishly driven itself to extinction.
  • Security. I've seen numerous bad tutorials, and one can tell that many developers come from either preschools or Windows environments, as they lazily run things with root privileges and generally do irresponsible stuff. That's the IoT nightmare that infosec experts are expecting to blow up in people's faces, so I'll do my best to avoid neglecting security. It'd be rather nasty if a nearby evil hacker could use your own camera to invade your home.

Hints and tips are more than welcome, so please comment if you know better.

2 comments:

  1. I've created a solar-powered timelapse system using an A+ (slightly more efficient than the Zero).

    I think you'll find that the current draw of any Pi will be too much as it's sitting there idling waiting for something to happen. You're going to get tired of dealing with the battery. Solar power it.

    Consider using a 16-bit ADC to monitor the battery. This will let you reschedule more power-hungry activities if you have a spell of bad weather and the battery is low. You can just program the Pi to wait until the voltage is back up to your desired threshold.

    Don't try to completely seal the system. You won't be able to keep out air no matter what, and where there's air, there's condensation and moisture. Better to have airflow and just try to keep out rain and snow and bugs.

    Don't worry about overheating. I'm in the desert and the Pi can handle 50°C.

    Dealing with the camera is tricky. Shooting through a plexiglass bubble will protect it but you'll sacrifice image quality and have condensation issues. My solution is a linear actuator that lowers the camera through a hole at the bottom of a chassis. If the weather is inclement, the turtle remains in its shell.

    ReplyDelete
    Replies
    1. Thanks for your ideas! The "turtle camera" sounds brilliant, so I'll definitely try that.

      I came to the same conclusion about sealing, so I built just enough cover to keep rain away from the circuitry. Condensation hasn't become a problem, so a semi-open design works fine, except that one time when something (a rodent or bird, perhaps) decided to sabotage some wires inside.

      Actually I've managed to keep the Zero W running on relatively small batteries for incredible time periods, but even carefully controlled IR lighting eats so much power that I decided to use a car battery for now, as I only need to test the system for a couple of days at a time. A desert environment surely provides enough solar power, but this far north sunlight is so scarce (esp. in wintery forests) that it takes a huge panel and a big battery to keep even a tiny system powered.

      Delete