A home intrusion detection setup (sort of)
Mutt Ain't No Shaggy Dog
Mutt is a classic in Unix-like operating systems and probably offers the easiest way to send an email with attachments (your photo) from the command line.
To install mutt, enter:
sudo apt-get install mutt mutt-patched
Suppose you want to send the picture to your Gmail account: You create a configuration file in the /home/pi
directory called .muttrc
containing the following,
set smtp_url="smtp://yourgmailusername@smtp.gmail.com:587/" set smtp_pass="yourgmailpassword"
where yourgmailusername
is the username you use to access your account, and yourgmailpassword
is your password. As you won't be using mutt for anything but sending, you don't need any other parameter.
Now you can send a picture by typing the following at the command line:
echo " " | mutt youraddress@gmail.com -s "Test" -a /path/to/picture.png
The echo
command provides the text body (otherwise, mutt will open a text editor for you to type in, and you don't want that) which is piped over to mutt proper. Mutt takes as a parameter the destination address (youraddress@gmail.com
). You can give your message a subject with the -s
option, and -a
creates an attachment out of a file on your disk.
After you hit Enter, the email is sent on its way.
Bearing in mind all of the above, your surveillance_mail.sh
will look something like the following:
#!/bin/bash echo " " | mutt $1 -s $2 -a $3
If you look at the content of the incrontab
file described above, you'll see that
$1
contains your email address.$2
sets the subject to Intruders!!!$3
is the path and name of the file you want to send.
Conclusion
You're done. All you have to do is run the Python script in Listing 4, and your surveillance system will start, first scanning, and later taking pictures of anything it considers abnormal. Incron and mutt will send pictures of miscreants automatically in the background to your inbox (Figure 8).
Although this project is more a thought experiment than an effective safety system (there are much better ways to create a surveillance system), it serves as an example of what a maker can achieve with stuff lying around the house.
If nothing else, it will help you understand how several technologies, including hardware that is affected by or affects the real world, can be combined to create a complex project.
Infos
- Adafruit 16 channel servo controller: https://www.adafruit.com/products/815
- Article code: ftp://ftp.raspberry-pi-geek.com/pub/listings/raspberry-pi-geek.com/04
- The Motion program: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome
- "Analog Pi" by Paul Brown, Raspberry Pi GEEK, Issue 3, pg. 56.
- "Controlled Files" by Paul Brown, Linux Magazine, Issue 158, pg. 42, http://www.linux-magazine.com/Issues/2014/158/Monitoring-with-incron
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 8
(incl. VAT)