Webcam to Security Cam (movement Detection + Email Alert)





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 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 = ""<br>$EmailFrom = ""<br>$Subject = "INTRUSION"<br>$Body = "ALERT"<br>$SMTPServer = "smtp server of your provider (ie.,"<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 + "\" + $<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");


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)



    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest

    39 Discussions

    I tested both iSPy and Contacam from Contaware (also Windows freeware) you should have a look to it, it do not have the tons of iSpy's features but is far simpler to use and integrate all features you need in your case.

    1 reply

    Thank you for mentioning Contacam, this one saved my day! Cheers o/


    2 years ago

    when you live in a quite unsafe street like I do.

    OMG Why you still living there?

    This is cool project to spy cheating your girlfriend,before you decide merry her...

    2 replies

    That's a good question, i just moved in there and didn't realize that this peculiar street was quite bad block away is much better...strange city...

    I too live in a 'quite bad area' but I have no choice but to stay there cause rent prices have shot up everywhere else :\

    Very nice instructable. Is it possible to configure this with arduino or any other microcontroller?

    2 replies

    Yes you can do this with a Raspberry Pi. The Pi runs a Linux OS and can interface with either a usb webcam or there is a camera add-on which is quite cheap.

    There is an app Motion which can be configured to do the motion detection and initiate sms or email etc.

    The latest Raspberry Pi has on-board wifi which is quite helpful.

    Its a bit fiddly to set up and will turn you into a Linux geek if you aren't one already, but mine gives good results now after quite a lot of messing with it.

    Check in the others comments, you'll find some answers ! ;)

    Sadly this instructable is impossible to do for mac users. Very interesting though, I have been looking for something like this because some dog owner has his/her dog peeing against my motorcycle for a long time now and today they even pooped in front of my doorstep. I guess I'll just buy an IP cam, cheaper than a windows laptop ;)

    But still, thanks for this very rich instructable!

    4 replies

    Ive personally been using unetcams for about 7 years now for viewing and recording webcams, ip cameras and ios cameras. On mac's, ios devices and android deviced

    Use umobile camera to turn ios devices, imac's and usb cameras into ip cameras.

    The reason I started using these apps was to catch our baby sitter at the time doing things in the house that she shouldn't have been. After it worked great doing that I started using the same setup on job sites to monitor my employees during the day and equipment at night.

    There may even be a windows version of these app. But I dont own any windows pcs so ive never checked.

    I am in no way affiliated with the developer of these programs. I've just found them to be very useful and reliable.

    This can be done with old smartphones too, eh?

    Try using athomecamera. Not in the itune store. Use your web browser. When prompted select get the app.


    2 years ago

    excelente ya lo probare gracias

    To Spy on You'r own privace's?

    Gee.. I don't get it. We in Finland just !!!!!!!...... them burgulers, (those coming in to your home) they try once and that's it

    2 replies

    FINLAND is cool and well thought of by Americans. I just want to know how to do the TECH- not talk politics. Please?

    Tech..Yeah.. it's "sooo..." wide area to cover. Example: in the brake from 70's to 80's (that's the dawn of electronical break-through for individuals). Tryed to launche an innovation of mine, a beeper to truck's, You know this "beep..beep.beep" sound when reversing. No way to get it accepted by the goverment with them law's (Finland). It got abandonned. Then I saw (lived in Sweden at that time) an "EXTRA" brake-light, LED's, installed in the rear window of a car, thought...WOW... what a ideable. Gee, NO, that could NEWER EWER be accepted of the traffic gov. TECH goe's mysterious ways. Nowaday's You'll by a controller+ shield's for hmm.. $<50 to create them most fantastic solution's Just look at bike instruct I've made with acontroller. Only You'r imagination is the limit of what You can acchive


    2 years ago

    I did this 15 years ago with a $5.00 cheapo webcam, a 486 motherboard, a 120MB HDD and Motion on Slackware. Worked great and sent me an email whenever it saw something. I still have it somewhere in the closet of ancient computers...

    Ohhh no double bad !!! I had been recently transferred to Mexico City for some months, do I have to concern more about security issues? I don't have a security system on my apartment. I am trying to setup a webcam like this, but my antivirus says there is a virus in this file, be careful ! What I have to do?

    1 reply

    And about the files, there is no virus, it's just that the file is an executable file (.bat). This kind of file is always flagged as "dangerous" because it could be dangerous !

    You can just right-click on it and edit it with a textpad and you will see there is no more code than the one indicated on the instructables.

    Anyway, sorry about that ;) y bienvenido a Mexico