At first, there was the idea to build a birdhouse with a camera for my son and my son’s kindergarten. After I started building that together with my three year old, I talked about it at my office. My CTO liked the idea very much and sponsored all the hardware needed:
- 1 Raspberry Pi
- 1 Raspberry Pi Camera without infrared filter
- 1 16GB microSD card
- 1 USB WiFi Adapter
- 3 infrared leds
- some jumper wires and a breadboard
The „two-story“ birdhouse is made from smaller pieces of wooden boards I had lying around, where the „second floor“ is obviously made for all the tec stuff and the ceiling in between has wholes for the infrared leds. After wiring it all together it was time to code. The setup is the following:
Motion detection on the Raspberry records videos and provides a live stream with Raspberry optimized version of motion „mmal-motion„. Whenever a video is recorded, a python script uploads the video to YouTube. I also added firebase to the stack to track the latest videos but as it turns out, the client was of course faster than the recoding on YouTube.
The client app is (obviously) written in Angular with the help of the yeoman generator cc-anguar and quite simple. It requests the YouTube API for the latest videos of my channel and provides a thumbnail grid view which embeds the YouTube player on click.
To save performance, I implemented infinite scrolling for the videos – and there are a lot of them. Especially since the blue tit is breeding the eight eggs. As an improvement I want to change the „upload on every video“ script to „concatenate all videos once a day and upload“.
The integration to wordpress is made with a shortcode that also triggers the embedding of the app and the app takes care of loading it’s CSS asynchronously.
Needless to say, that not only my son and his buddies but also everyone at the office was excited to watch the blue tit couple build their nest. We’re still looking for names, also for the baby birds – suggestions welcome via twitter @ or as comment.
If you’re interested in the actual building process, maybe the YouTube channel is a better place, otherwise you need to scroll endlessly…