Introduction: Webcam to Security Cam (movement Detection + Email Alert)

Security in Mexico City is quite an issue, even more when you live in a quite unsafe street like I do. Recently I felt the need of having a way of knowing if someone was breaking into my house ...who knows... maybe it would give me enough time to go back home fast or to send the cops directly there...

This is a low-cost project if :

  • you already have a computer with a webcam,
  • you're ok with letting it turned on all day long,
  • and of course if the webcam can face the zone you want to look out.

What we will use :

  • a computer with Windows connected to the internet
  • a webcam
  • iSpy (we will use v6.5.3.0)
  • a little bit of code

You don't really need to know how to code, you can just download the files and edit them to change some informations.

Step 1: Installing and Configuring ISpy Part 1

Let's start ! download iSpy here and install it

iSpy is an open source software it's free for most of it, but if you want email notification you have to pay a monthly fee...here we will have a way to have this feature for free. You can still pay if you want sms and twitter notification features.

  • First let's delete the default camera by right-clicking on it and select DELETE.
  • now ADD you camera (ADD > LOCAL CAMERA > OK).
  • It takes you directly to the settings for your camera :
    • Camera Tab : you can rename it, change the timestamp, I didn't change anything in this beside setting the "Ignore Audio" option ON
    • Motion Detection Tab : here let's change the trigger range, let's say it's the sensitivity of your detector mine is on the range 10->100, maybe you'll have to make a few try to find the range corresponding to your environment in order to avoid false detection...
    • Alert Tab : uncheck Messaging, change Intervals time to 60s, then in the action window let's create an action :
      • in When select Alert
      • in Select Action select Beep
      • press Add
    • Now let's create another action : "When AlertStopped Select Action Beep" let's Add this action 2 times. So now when a movement will be detected we will here a beep from the computer and when it will stop we will here 2 beep.
    • Recording Tab : Select No Recording (unless you also want video recording, I dont' use it), change Max. Calibration Delay to 60s (it will be the time you will have to go out of the way when you turn the alarm on)
    • Images Tab : Select Local Saving Enabled. We will be able to change the saving folder later. You can also change the Overlay text.
    • You can also configure FTP so your images will be transferred automatically and manage a schedule (I don't use it, I turn on the system when I leave home and turn it off when I come back).
    • now click on FINISH

Step 2: Installing and Configuring ISpy Part 2

So now normally, you should here a bip when you move in front of your camera. And if you wait a few seconds with no movements you should here 2 bips !

Now let's go on the SETTINGS button.

  • in the first Tab : turn on the Run on Startup option (if you want to of course), turn on Minimise on Close option (again not mandatory).
  • Storage Tab : edit the Media Directory, you can change the folder where images and videos will be saved, I use my DropBox folder so that I can have access to the images from anywhere. Also you can turn on Storage Management option, I use a Max media Folder Size of 20 MB.
  • inside the folder you chose you can find the saved pictures in \Media\Video\GXPNW\grabs (where GXPNW can be any mix of letters)
  • that's all for the settings

Now let's send some mails !

Step 3: Let's Send a Mail

First we will start creating 2 files that will permit us to send the alert mail.

First file will be a powershell file and Second file will be a batch file to trigger the first file with iSpy.

The first file send a mail attaching the last picture took from the webcam since the alert.

$dir = "C:\Users\USER\Dropbox\Cam\video\BJRIU\grabs" here put the directory "grabs" where every picture are saved, I use my Dropbox account so that I can have access to every pictures easily from anywhere.

You can save the files anywhere you want and name theme the way you want

---------------------------------First file name "ALERT.ps1" ---------------------------------

$EmailTo = "yourmail@yourprovider.com"<br>$EmailFrom = "yourmail@yourprovider.com"<br>$Subject = "INTRUSION"<br>$Body = "ALERT"<br>$SMTPServer = "smtp server of your provider (ie. smtp.live.com, smtp.gmail.com)"<br>$dir = "C:\Users\USER\Dropbox\Cam\video\BJRIU\grabs"<br>$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1<br>$filenameAndPath = $dir + "\" + $latest.name<br>$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)<br>$attachment = New-Object System.Net.Mail.Attachment($filenameAndPath)<br>$SMTPMessage.Attachments.Add($attachment)<br>$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true<br>$SMTPClient.Credentials = New-Object<br>System.Net.NetworkCredential("mail user", "mail password");
$SMTPClient.Send($SMTPMessage)

--------------------------------------------------------------------------------------------------------

in the second file just put the path to your first file.

---------------------------------Second file name "ALERT.bat" -------------------

powershell C:\Users\USER\Documents\ALERT.ps1

--------------------------------------------------------------------------------------------------------

You can download both files from this instructable but you still have to modify them with you data.

You can just try it and click on the .BAT file, it should send a mail without problem !

Step 4: Final Touch on ISpy

Back to iSpy, let's go back to your camera configuration, you will find a little EDIT button when you put your mouse over the camera.

Let's go back on the ALERT tab and let's create a new Action like we already did with the beeps :

WhenALERT Execute File, clic on ADD and select your .BAT file.

click on Finish and we're done !

Now when you want to activate your alarm you can just click on ALL ON and when you want to deactivate it click on ALL OFF, that's all... normally with gmail I receive the mails on my phone between 1 and 3 minutes after the cam was triggered.

I hope everything was clear, english not being my native language I bet there are some mistakes ... I hope this trick will be useful to somebody !


Any comment more than welcome, the system can still be improved (ie. VNC server to watch the cam live from anywhere)