element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RIoTboard
  • Products
  • Dev Tools
  • Single-Board Computers
  • RIoTboard
  • More
  • Cancel
RIoTboard
Blog Riotboard: IoT based intrusion detection & alert system: Part2 : Capturing image
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RIoTboard to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: tusharp
  • Date Created: 28 Oct 2015 9:49 AM Date Created
  • Views 1104 views
  • Likes 3 likes
  • Comments 3 comments
  • tusharp
  • alert
  • Ubuntu
  • gpio
  • pir
  • freescale
  • imx6
  • riotboard
  • embedded
  • riot
  • intrusion
  • camera
  • iot
  • logitech
  • c310
  • arm9
  • sensor
  • linux
Related
Recommended

Riotboard: IoT based intrusion detection & alert system: Part2 : Capturing image

tusharp
tusharp
28 Oct 2015

In this mini blog series we will build an IoT based intruder detection and alert system.

 

Blogs:

Part1 : Connecting Pir Sensor

Part2 : Capturing intruder image  <--- this blog

Part3 : Email Alerts

 

In previous blog we integrated a PIR sensor to Riotboard for human movement detection.

 

In this very short guide we will try to capture image once an IR detection is made.

 

I am using a  Logitech C310Logitech C310 USB camera for this purpose.


logitech c310 camera

 

Connect pir sensor HC-Sr501 and Camera to Riotboard.

image snapshot

 

to capture image we will use fswebcam tool.

 

in terminal type:

    apt-get install fswebcam

fswebcam

 

Now we determine the usb device

 

type "ls /dev/video*" without pluggin camera.

Now pluggin camera to Riotboard, and type "ls /dev/video*"

check for video device in /dev.

the camera hardware is accessible at the device /dev/video2

riotboard camera device

 

now add below line to previous code  below ln28.

system("fswebcam -d /dev/video2 capture.jpg");

 

Next we will compile the below code and test.

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main()
{
int ret =0;
int fd=0;
char buf[1];

system("devmem 0x20E00A0 w 0x5  ");
system("echo 113 > /sys/class/gpio/unexport");
system("echo 113 > /sys/class/gpio/export");
usleep(100000);
system("echo in > /sys/class/gpio/gpio113/direction");
usleep(100000);

fd = open("/sys/class/gpio/gpio113/value",O_RDONLY);
while(1)
{
ret = read(fd,buf,sizeof(1));
if(lseek(fd,0,SEEK_SET) < 0) return 1;

if(ret>0 && (atoi(buf)==1))
    {
        printf("\n\033[031;43m HUMAN DETECTED \033[0m ");
        fflush(stdout);
        system("fswebcam -d /dev/video2 capture.jpg");
        usleep(500000);
    }
else
    printf("\nNo Detection");

fflush(stdin);
fflush(stdout);
usleep(500000);

}
close(fd);
}

 

Now perform some hand movement infront of Pir sensor, it will show human detected and captures image as "capture.jpg".

pir camera capture

 

before capture:

hukhh3.jpg

 

after capture:

neyn3s.jpg

 

Now with every pir interrupt we can capture the image of the intruder.

 

Next time we will add an image based email alert for the above.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 9 years ago +1
    Nice post. You could use the same design to capture critters in the wood or around the house, or even your attic. DAB
  • tusharp
    tusharp over 9 years ago in reply to DAB +1
    I have to battery power this kid and make it portable then.
  • mrpipes3
    mrpipes3 over 7 years ago in reply to tusharp

    I'm trying to do something similar for a college project.  We want to mount it on a Roomba create 1.  I currently have the provided Android BSB image installed on my Riotboard and was trying to find a way to download the Logitech camera app (I'm really new to all of this). I can't seem to get the GooglePlay store working?  Any thoughts? administrator

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tusharp
    tusharp over 9 years ago in reply to DAB

    I have to battery power this kid and make it portable then.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Nice post.

     

    You could use the same design to capture critters in the wood or around the house, or even your attic.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube