build the internet of things with raspberry pi!

16

Upload: donald-derek-haddad

Post on 21-May-2015

683 views

Category:

Technology


2 download

DESCRIPTION

Arabnet Conf 2014 Code & Design Day. GDG Beirut Code Lab: Duration: 1h30min Project Files: https://github.com/DonaldDerek/GoogleBeam Given By: Raghd Hamzeh, Donald Derek Haddad

TRANSCRIPT

Page 1: Build the internet of things with Raspberry Pi!
Page 2: Build the internet of things with Raspberry Pi!

The recipeHardware Stack

• Raspberry Pi Model B (512 MB Ram)• Raspberry Pi Camera Module (2 MP) or

any compatible USB Cam *• Ethernet Cable• Wifi dongle: Edimax EW-7811Un -

150Mbps Wireless• SD Card ( 4 GB ++)

Page 3: Build the internet of things with Raspberry Pi!

The recipeSoftware Stack

• Raspbian OS • Node.js (v 0.10.2 +)• Python (V 2.7)• Shell Scripts• Twitter Stream API• Google Drive API

Page 4: Build the internet of things with Raspberry Pi!

Downloading weaponsNode.js on Raspberry Pi: https://github.com/DonaldDerek/rPi-cheat-sheet

Page 5: Build the internet of things with Raspberry Pi!

WARNINGcoding mask on!

Page 6: Build the internet of things with Raspberry Pi!

Connecting to your raspberry pissh-ing

Usefull Links:http://elinux.org/RPi_Advanced_Setup

#Avahi Deamon should be installedssh [email protected]

#Static IPshh [email protected]

Page 7: Build the internet of things with Raspberry Pi!

* Testing USB CamResurrecting ancient technologies

#Test USB CameraLsusb

#Take images from RaspberryPi USB Camerafswebcam -d /dev/video0 -r 640x480 test.jpeg

Page 8: Build the internet of things with Raspberry Pi!

Testing Rpi 2mp camTiny yet amazing camera!

raspistill –o test.jpg -w 640 -h 480

Page 9: Build the internet of things with Raspberry Pi!

WARNINGcoding mask on!

Page 10: Build the internet of things with Raspberry Pi!

App architectureWhere all your scripts belong

• node_modules/• ntwitter/• Request/

• bin/• atom/• gdata/• gdrive.py

• images/• App.js• Config.js• Controller.js• Package.json• tw-upload.js

Page 11: Build the internet of things with Raspberry Pi!

Twitter stream apiThe communication layer is built upon Twitter’s infrastructure

var twit = new twitter(config);

// Check Credentialstwit.verifyCredentials(function (err, data) { if(err) console.log(err);}).stream('user', {track:watch}, function(stream) {

console.log("Twitter stream is ready and waiting for inc tweets...")

stream.on('data', function (data) {

//Check if tweet is not emptyif (data.text !== undefined) {

//Action Code here}

});

//Catch errorsstream.on('error', function (err, code) {

console.log("err: "+err+" "+code)});

Page 12: Build the internet of things with Raspberry Pi!

Child processControl anything you can do in the terminal

child = exec("raspistill -o "+ image_path +" -w 640 -h 480", function (err, stdout, stderr) {

//trigger another event})

Page 13: Build the internet of things with Raspberry Pi!

WARNINGcoding mask on!

Page 14: Build the internet of things with Raspberry Pi!

Google drive apiLight-weight python script

//Authenticate with Gdrive APItry: docsclient.ClientLogin(username, password, docsclient.source);

except (gdata.client.BadAuthentication, gdata.client.Error), e: sys.exit('Unknown Error: ' + str(e))

except: sys.exit('Login Error, perhaps incorrect username/password')print 'success!'

Resources: http://planzero.org/blog/2012/04/13/uploading_any_file_to_google_docs_with_python

Page 15: Build the internet of things with Raspberry Pi!

WARNINGcoding mask on!

Page 16: Build the internet of things with Raspberry Pi!

May The Source be With youhttps://github.com/DonaldDerek/GoogleBeam

DerekHaddadDonaldDerek r_hamzehrhamzeh