Introduction: Camera Trap Upload Twitter With Intel Edison

Picture of Camera Trap Upload Twitter With Intel Edison

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.

Step 1: Things You'll Need:

Picture of Things You'll Need:

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

Step 2: Set Up and Install Intel Edison on PC

Picture of Set Up and Install Intel Edison on PC
  • 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.

Step 3: Designing Wifi Connection on Intel Edison

Picture of Designing Wifi Connection on Intel Edison
  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.

Step 4: Accessing Root by Using WinSCP

Picture of Accessing Root by Using WinSCP
  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.

Step 5: Updating Information to Twitter

Picture of Updating  Information to Twitter
  • 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);

Step 6: Using PIR Motion Censor

Picture of Using PIR  Motion Censor

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

Step 7: Installing Camera

Picture of Installing Camera

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.

Step 8: 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);

}

}

Step 9: Packing Camera Trap

Picture of Packing Camera Trap

  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

:)

Comments

SobrunA (author)2015-10-16

woah.. you have nice idea, we can see our home from twitter so we are not worry again when we going out from home.. so easy to make it. thank you so much for sharing bro.. :)

tsusanto (author)SobrunA2015-10-21

you'r welcome sir.... now you don't worry to leave your home

eric dirgahayu (author)2015-10-15

the complete tutor i have ever seen on Intel edison contest...your the winner ...

tsusanto (author)eric dirgahayu2015-10-15

:) thank you sir @eric

Muhammad AsdiantoO (author)2015-10-15

It can be use for security cam in your house while you were away from home.

yes i can sir... you can use for security cam in your house....

go on to try it sir

yes i can sir... you can use for security cam in your house....

go on to try it sir

khuclukz (author)2015-10-15

nice instruction.

"Camera traps are specially designed cameras to capture images of animals in a wildlife"

i am interest to make it soon, but i have a question about internet connection, such as i want to install in forest. so i am not sure in forest can get wifi signal, how i can do it

tsusanto (author)khuclukz2015-10-15

thx for attention...

good question.

yap in forest we don't get wifi signal, may be i will try to use modem external to internet connection. i will try now, wait me sir. i can shared new project with internet conection byusing modem external...

i hope, i can finish it... :)

thank you

Muhammad AsdiantoO (author)2015-10-14

Good job.

thx ma bro.. :)

Still trying

thx ma bro.. :)

DonguahJ (author)2015-10-14

Thank for sharing

tsusanto (author)DonguahJ2015-10-14

:) your welcome...

DindaD (author)2015-10-14

Awesome !! ??

tsusanto (author)DindaD2015-10-14

Thank you :*

seamster (author)2015-10-14

Very nice! Thanks for sharing, and welcome to instructables! :)

tsusanto (author)seamster2015-10-14

Thank you @seamster... I will try to make another tutorial