Build the internet of things with Raspberry Pi!

1,069 views
904 views

Published on

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

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,069
On SlideShare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Build the internet of things with Raspberry Pi!

  1. 1. The recipe Hardware 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 ++)
  2. 2. The recipe Software Stack • • • • • • Raspbian OS Node.js (v 0.10.2 +) Python (V 2.7) Shell Scripts Twitter Stream API Google Drive API
  3. 3. Downloading weapons Node.js on Raspberry Pi: https://github.com/DonaldDerek/rPi-cheat-sheet
  4. 4. WARNING coding mask on!
  5. 5. Connecting to your raspberry pi ssh-ing #Avahi Deamon should be installed ssh pi@raspberrypi.local #Static IP shh pi@192.168.5.10 Usefull Links: http://elinux.org/RPi_Advanced_Setup
  6. 6. * Testing USB Cam Resurrecting ancient technologies #Test USB Camera Lsusb #Take images from RaspberryPi USB Camera fswebcam -d /dev/video0 -r 640x480 test.jpeg
  7. 7. Testing Rpi 2mp cam Tiny yet amazing camera! raspistill –o test.jpg -w 640 -h 480
  8. 8. WARNING coding mask on!
  9. 9. App architecture Where 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
  10. 10. Twitter stream api The communication layer is built upon Twitter’s infrastructure var twit = new twitter(config); // Check Credentials twit.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 empty if (data.text !== undefined) { //Action Code here } }); //Catch errors stream.on('error', function (err, code) { console.log("err: "+err+" "+code) });
  11. 11. Child process Control anything you can do in the terminal child = exec("raspistill -o "+ image_path +" -w 640 -h 480", function (err, stdout, stderr) { //trigger another event })
  12. 12. WARNING coding mask on!
  13. 13. Google drive api Light-weight python script //Authenticate with Gdrive API try: 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
  14. 14. WARNING coding mask on!
  15. 15. May The Source be With you https://github.com/DonaldDerek/GoogleBeam DonaldDerek DerekHaddad rhamzeh r_hamzeh

×