This was my entry for the Connected Home Project Contest by Make Magazine
This project consists in a movement sensor (PIR) plus a camera and a wifi connected device (Arduino Yún was my choice, but it can be easily substitued with a RaspberryPi). Optionally, speakers can be connected to reproduce an alarm sound.
The purpose is clear. You don’t want your kids to steal your food from the cupboard, or from the fridge, or someone to open your locket, or you want to take pictures to your pet stealing food, or you are Dwight Schrute and you want to finally unmask the coworker that puts your stuff into jelly… so you hide the device into the cupboard/fridge/locket, and when the device detects some movement, it will take a picture and post it right to your email! And if you use IFTTT, then you can automatically post the picture of the thief to Facebook, Twitter and show the thief’s face to the entire world!
The project is very simple, it doesn’t require any soldering/electronics skills and it can be assembled in minutes.
As I said before, my platform choice is Arduino Yún, because it’s very easy to use, and it’s easy to configure the wifi settings. It’s a bit more expensive than the RaspberryPi, but if you use the Yún you can give you project to someone else as a gift, and anyone can configure the wifi settings, while this may be a difficult task with the RaspberryPi, without connecting it to a monitor/mouse/keyboard. But if you like it, I can easily make a Raspberry version.
So, here are the ingredients
UVC compatible USB Camera (don’t worry: almost all the USB cameras are UVC compatible)
Micro USB power adapter or USB Battery pack
Recommended: micro SD card
Optional: USB Sound card
Optional: USB HUB (if you want both the USB Camera and the USB Sound card)
Ok, let’s start!
Arduino basic configuration
First of all, you need to configure your Arduino Yún network settings. This should be pretty easy following this guide
Then test the connection to your Arduino: in your browser type http://arduino.local, you will see the Arduino web interface
If it works, open SSH session
the default password is “arduino”
Then let’s install some useful packages
$opkg update $opkg install openssh-sftp-server
Why the openssh-sftp-server? Because it would be easier for you to upload and download files from/to the Arduino: now you can use a generic SFTP client (filezilla, transmit or cyberduck) instead of SCP command
If you have one, I highly recommend to put a micro SD card into the Arduino Yún. It will be automatically mounted in /mnt/sda1
Then, we will install the USB Camera and USB Soundcard on the Yún
Installing and testing the USB Camera
The UVC package is already available fot Linino via opkg, so installing the Camera is a very easy step, just connect to your Yún via ssh and type
$ opkg update $ opkg install kmod-video-uvc
We also need a software for taking pictures, I used fswebcam that is supersmall and very easy to use
$ opkg install fswebcam
Take your first picture
First of all, be sure to use and SD card for storage or you will quickly fill the Arduino internal storage, and you don’t want to do that. If you are using an SD card, you should see it mounted in /mnt/sda1. If it’s not, put a FAT32 formatted micro SD card into the SD Card Slot, and reboot your Arduino
Now plug the camera to the USB host port, and type
$ cd /mnt/sda1 $ fswebcam test.png
If everything is ok, you took your first picture! Take a look to your SD card contents :)
This means that now we can take pictures from our Arduino sketch, via the Yún’s Bridge library, in this way
We use an Arduino to program other ATmega without bootloader . This technique allows you to use all flash memory for code and make boards using new ATmega, cheaper than those with bootloader. The qualities that have made the success of Arduino are undoubtedly the open-source software, many libraries, a good hardware and a virtually infinite Reference that explains each possible use of the platform. But if we use Arduino for a specific use, we can integrate it into a specific circuit and program the micro in a way that performs a single firmware. We may so remove the bootloader and leave to the firmware the entire program memory. The ATmega328 has 32 Kbytes of flash, that when the chip is mounted on Arduino are not all available, as a portion is reserved to the bootloader, the purpose of which is to communicate with the IDE Arduino to load programs (sketch) to be performed. The same bootloader, on each power on or reset of Arduino, verifies the presence of a [...]