Camera Trap Upload Twitter With Intel Edison

by tsusanto in Circuits > Sensors

5050 Views, 96 Favorites, 0 Comments

Camera Trap Upload Twitter With Intel Edison

1IMG_20151011_183932.jpg

Camera traps are specially designed cameras to capture images of animals in a wildlife. It is aimed to study the ecosystem of those animals in the forest. This camera is equipped by motion cencors that use censor pir. If there is a movement from the spot that the cameras set, the camera will automatically capture it. After that, the image will be sent to twitter as an information. In this project , the controller that will be used is Intel Edison.

Things You'll Need:

1IMG_20151014_084945.jpg
1IMG_20151015_000540.jpg

You can buy these stuff from online shop like amazon or other:

  1. Intel Edison
  2. PIR Sensor
  3. USB Camera

And for packing You can buy these from your local hardware store:

  1. Screw 4x
  2. Nut 4x
  3. Spacer 4x
  4. BOX
  5. Glue gunGlueGun

Set Up and Install Intel Edison on PC

1.png
2.png
3.png
4.png
6.png
  • Updating las firmware edison:
    1. Donwload the latest firmware and driver software on the official website of intel edison. In this project, I use windows 64-bit.

    2. Connect micro usb cables to intel arduino breakout board as the picture.

    3. Instal Driver sofware. If you have not installed java, please download in here

    4. Extract the files that have been downloaded into the edison folder.

    5. After extracting the files, enter the root via SSH byusing putty.software. You can download it in here :

    6. Set PuTTY

    7. Next, write "reboot ota" so that files that have been extracted will be uploded automatically into edison board.

Designing Wifi Connection on Intel Edison

111.png
7.png
8.png
9.png
10.png
  1. Open PuTTY
  2. In ssh root , write “configure_edison–setup”. Blank it if you do not need to change the password and the

    username. Press enter until it shows set up wifi, and type Y, then enter.

  3. Next choose wifi connection that is available and type the password if it is needed. From the picture shows that the connection has been successful and You will get the IP in intel edison. To make sure that intel edison has conected to the internet, please ping google.

Accessing Root by Using WinSCP

11.png
12.png
  1. Download and run the freeware WinSCP. You can download it in here
  2. Input the IP, write username and password. Use the same username and password as you log in ssh. And click login.

Updating Information to Twitter

13.png
14.png
15.png
16.png
17.png
18.png
19.png
20.png
  • Install twitter javascript package from
  • In SSH write npm install twitter
  • Next open notepad. Write the code below and save as twitter.js

var Twitter = require('twitter');
var client = new Twitter({

consumer_key: 'your consumer_key',

consumer_secret: ' your consumer_secret ',

access_token_key: ' your token_key ', access_token_secret: ' your token_secret '

});

client.post('statuses/update', {status: 'I am a tweet'}, function(error, tweet, response){

if (!error) {

console.log(tweet);

}

});

  • To get the consumer / key token, you can open here, and then create new apps.
  • Upload twitter.js file that has been created in notepad to intel edison root by using WinSCP.
  • Run twitter.js in ssh by typing "node twitter" . Then you will see stattus in your twitter.

Note : To show the newest one, you have to change the latest
postings. Because twitter can’t post your stattus if you write same satattus in one day.

client.post('statuses/update', {status: 'I am a tweet'}, function(error, tweet, response

){

if (!error) {

console.log(tweet);

Downloads

Using PIR Motion Censor

21.png

Test the censor by the movement. If there is a movement, the LED will be on for 5 seconds, then it will be off after that.

Video Demo Censor

Here are the listing programs that will be entered into edison :

  • Open the notepad and write this code and save as testmotion.js.

//Set up our GPIO input for pin 8

var mraa = require('mraa');

var motionSensor = new mraa.Gpio(8);

var led = new mraa.Gpio(13);

motionSensor.dir(mraa.DIR_IN);

led.dir(mraa.DIR_OUT);

periodicActivity();

function periodicActivity()

{

//Read our sensor

var motionSensorTriggered = motionSensor.read();

//Do stuff if our sensor is read HIGH

if(motionSensorTriggered){

led.write(1);

setTimeout(periodicActivity, 5000);

}else{

led.write(0);

setTimeout(periodicActivity, 100);

}

  • Next Upload the files to edison board. And run in ssh typing “node testmotion” if you close to program hold Ctrl+C

Downloads

Installing Camera

22.png
23.png
24.png
25.png
26.png
27.png
28.png
31.png
29.png
30.png
32.png
33.png
34.png
36.png
37.png
38.png
39.png
40.png

We have to choose a camera that support UVC. You can see in Here , I use a usb camera genius F100

Here are the Next processes:

  • Use an external supply
  • Set the switch towards usb
  • In software PuTTY, write lsusb to check if the usb camera has already conneced to the device. in the first line, it shows that the camera has already connected.

  • Next, install the camera driver that support UVC so that it can be compatible with Linux UVC driver.

  • Install unofficial OPKG repo in Here

  • Open the command in PuTTY and write : vi /etc/opkg/base-feeds.conf

  • After that, write

src/gz all http://repo.opkg.net/edison/repo/all

src/gz edison http://repo.opkg.net/edison/repo/edison

src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

To save it, hold ESC and “shift

:” next write wq Enter

  • Then, install uvc driver

Write:

Opkg install kernel-module-uvcvideo


  • Unplug usb camera. Reconnect, and write dmesg –c

Make sure the uvc camera is detected as UVCvideo as shown this picture

  • To make sure, write ls -1 /dev/video0

If Root shows
" v/dev/video0: No such file or directory", it means the device is not connected or is not installed.

  • Install ffmpeg

To install ffmpeg navigate to bin by typing:

Cd edi-cambin

And write:

./install_ffmpeg.sh

Wait the process until it is done.

Next, write Cd to close it to go the next step

  • Install node.js package

direct to web/server by typing:

Cd edi-cam/web/server

Next write "Npm install" to install node.js package

The command will form the bin folder and its contents.

  • Test Capture

To try to capture some pictures from the USB camera, you can do by writing listing program as below: And

save as testcapture.js and upload to edison.

console.log("Start capture");

function run_cmd(cmd, args, callBack ) {

var spawn = require('child_process').spawn;

var child = spawn(cmd, args);

var resp = "";

child.stdout.on('data', function (buffer) { resp += buffer.toString() });

child.stdout.on('end', function() { callBack (resp) });

}

//delete file gambar.jpg in same folder

run_cmd( "rm", ['-f', '/home/root/gambar.jpg'], function(text) { console.log (text) });

console.log("Remove last capture");

run_cmd( "/home/root/bin/ffmpeg/ffmpeg", ['-s', '800x600', '-f', 'video4linux2', '-i', '/dev/video0', '-vframes', '1', 'gambar.jpg'], function(text) { console.log (text) });

console.log("capture done");

Next,run the node testcaptur in PuTTY

You can see the result in edison folder and you can directly download it.

The results of the image depends on the quality of the usb camera itself.

Downloads

Finally to Combining the Three Programs That Have Been Tested to Become a Camera Trap That Can Be Directly Uploded to Social Medias Like Twitter.

Finally Video

Write this Program and Save as Combine.js:

//Set up our GPIO input for pin 8
var Twitter = require('twitter');

var client = new Twitter({

consumer_key: 'PZSlqMDYLx00qYi9RhW7yoI0r',

consumer_secret: 'NFM6ydkdJ5cM4SB8cNR0YU2hraROzZTUrMD6F8xSxM8xkYn5gb',

access_token_key: '3838434318-lOfl9zj8gaNxxYXupIrVm5eOhEA0Tjs0Z4oYVyJ',

access_token_secret: 'cqmYv4LRABph3LL2dO1ROJi9teN5HZqldq9GHWryVlx1e'

});

var mraa = require('mraa');

var motionSensor = new mraa.Gpio(8);

var led = new mraa.Gpio(13);

motionSensor.dir(mraa.DIR_IN);

led.dir(mraa.DIR_OUT);

console.log("Start capture");

function run_cmd(cmd, args, callBack ) {

var spawn = require('child_process').spawn;

var child = spawn(cmd, args);

var resp = "";

child.stdout.on('data', function (buffer) { resp += buffer.toString() });

child.stdout.on('end', function() { callBack (resp) });

}

periodicActivity();

function periodicActivity()

{

//Read our sensor

var motionSensorTriggered = motionSensor.read();

//Do stuff if our sensor is read HIGH

if(motionSensorTriggered){

var data = require('fs').readFileSync('/home/root/picture.jpg');

client.post('media/upload', {media: data}, function(error, media, response){

if (!error) {

// If successful, a media object will be returned.

console.log(media);

// Lets tweet it

var status = {

status: 'New image from #intelEdison #IOT ',

media_ids: media.media_id_string // Pass the media id string }

client.post('statuses/update', status, function(error, tweet, response){

if (!error) {

console.log(tweet);

}

});

}

});

//capture

run_cmd( "rm", ['-f', '/home/root/picture.jpg'], function(text) { console.log (text) });

console.log("Remove last capture");

run_cmd( "/home/root/bin/ffmpeg/ffmpeg", ['-s', '800x600', '-f', 'video4linux2', '-i', '/dev/video0', '-vframes', '1', 'picture.jpg'], function(text) { console.log (text) });

console.log("capture done");

led.write(1);

setTimeout(periodicActivity, 5000);

}else{

led.write(0);

setTimeout(periodicActivity, 100);

}

}

Downloads

Packing Camera Trap

1IMG_20151014_093314.jpg
IMG_20151011_162340.jpg
1IMG_20151011_162531.jpg
1IMG_20151011_163650.jpg
1IMG_20151011_164908.jpg
1IMG_20151011_165415.jpg
1IMG_20151011_170216.jpg
1IMG_20151011_170720.jpg
1IMG_20151011_170904.jpg
1IMG_20151011_172330.jpg
1IMG_20151011_174531.jpg
1IMG_20151011_174727.jpg
1IMG_20151011_181826.jpg
1IMG_20151011_181939.jpg
1IMG_20151011_182738.jpg
1IMG_20151011_182804.jpg
1IMG_20151011_183626.jpg
1IMG_20151011_183932.jpg

  1. Adjusting the position of censor, intel edison and camera
  2. Make a hole with a drill to position Intel Edison
  3. Cut the Box With Cuter to position USB Port and Power Supply
  4. Make Hole to Camera Position
  5. Create a square-shaped hole to PIS Censor.
  6. Sticking sensors and cameras on the hole by using a glue gun

Thank you for visiting

:)