build the internet of things with raspberry pi!
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 HaddadTRANSCRIPT
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 ++)
The recipeSoftware Stack
• Raspbian OS • Node.js (v 0.10.2 +)• Python (V 2.7)• Shell Scripts• Twitter Stream API• Google Drive API
Downloading weaponsNode.js on Raspberry Pi: https://github.com/DonaldDerek/rPi-cheat-sheet
WARNINGcoding mask on!
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]
* Testing USB CamResurrecting ancient technologies
#Test USB CameraLsusb
#Take images from RaspberryPi USB Camerafswebcam -d /dev/video0 -r 640x480 test.jpeg
Testing Rpi 2mp camTiny yet amazing camera!
raspistill –o test.jpg -w 640 -h 480
WARNINGcoding mask on!
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
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)});
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})
WARNINGcoding mask on!
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
WARNINGcoding mask on!
May The Source be With youhttps://github.com/DonaldDerek/GoogleBeam
DerekHaddadDonaldDerek r_hamzehrhamzeh