Hackin' Devices with Ruby A Sensors to API to Feeds to Apps  “Show and Tell” Kit Plummer dozer software
Ubiquitous Computing <ul><li>Pervasive Computing </li><ul><li>Everything has a processor
Everything is connected </li></ul><li>Ambient Intelligence </li><ul><li>Sensitive to people
Context aware
Passive </li></ul><li>Embedded </li></ul>
Devices -> Producers/Consumers <ul><li>Internet of Things
Producers Push </li><ul><li>To Where? </li></ul><li>Consumers Pull </li><ul><li>From Where? </li></ul><li>Consumers get pu...
Devices -> Sensors/Actuators <ul><li>Sensors Push
Actuators Pull? </li><ul><li>In a Web world, Yes.
In a Web world, No.
Full-duplex is possible </li><ul><li>Chat protocols (XMPP)
Webhooks
Devices  ARE  servers </li></ul></ul></ul>
What if... <ul><li>There was a SaaS that could receive data updates and make them available to the public through a standa...
There was a SaaS that could provide a standard interface to publicly available sensors and actuators (from all over the wo...
Upcoming SlideShare
Loading in …5
×

Hackin' Devices with Ruby

1,679 views

Published on

Showing a model for sensor integration (called Pachube.com), based on every-day of-the-shelf (and cheap) devices, integrating through a simple interface language (DSL) based on Ruby.

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
1,679
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
12
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Hackin' Devices with Ruby

  1. 1. Hackin' Devices with Ruby A Sensors to API to Feeds to Apps “Show and Tell” Kit Plummer dozer software
  2. 2. Ubiquitous Computing <ul><li>Pervasive Computing </li><ul><li>Everything has a processor
  3. 3. Everything is connected </li></ul><li>Ambient Intelligence </li><ul><li>Sensitive to people
  4. 4. Context aware
  5. 5. Passive </li></ul><li>Embedded </li></ul>
  6. 6. Devices -> Producers/Consumers <ul><li>Internet of Things
  7. 7. Producers Push </li><ul><li>To Where? </li></ul><li>Consumers Pull </li><ul><li>From Where? </li></ul><li>Consumers get pushed to is probably more right </li></ul>
  8. 8. Devices -> Sensors/Actuators <ul><li>Sensors Push
  9. 9. Actuators Pull? </li><ul><li>In a Web world, Yes.
  10. 10. In a Web world, No.
  11. 11. Full-duplex is possible </li><ul><li>Chat protocols (XMPP)
  12. 12. Webhooks
  13. 13. Devices ARE servers </li></ul></ul></ul>
  14. 14. What if... <ul><li>There was a SaaS that could receive data updates and make them available to the public through a standardize API, producing XML, JSON, or graphic visualizations (or PLI)
  15. 15. There was a SaaS that could provide a standard interface to publicly available sensors and actuators (from all over the world), via a standardized format and open API </li></ul>
  16. 16. http://www.pachube.com
  17. 17. Need Hardware! <ul><li>Sensor </li><ul><li>Check: Vernier Go!Temp USB Temp Sensor </li></ul><li>Embedded Platform </li><ul><li>Check: Gumstix Verdex </li></ul></ul><?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?> <xsd:schema xmlns=&quot;http://www.eeml.org/xsd/005&quot; elementFormDefault=&quot;qualified&quot; targetNamespace=&quot;http://www.eeml.org/xsd/005&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;> <xsd:element name=&quot;eeml&quot;> ...
  18. 18. Need Software! <ul><li>I <3 Ruby! </li><ul><li>Got Ruby 1.8.6 running on Gumstix </li><ul><li>ruby 1.8.6 (2008-08-11 patchlevel 287) [arm-linux-eabi] </li></ul></ul><li>Pachube speaks EEML* over HTTP </li><ul><li>Wrote pachuber gem for Ruby access to API </li></ul><li>Access temp from Go!Temp via Ruby in Linux </li><ul><li>Thanks to Linux's USB “device bus”: </li></ul></ul>(*Extended Environments Markup Language) f = File.new(&quot;/dev/ldusb0&quot;) packet = f.read(8) f.close parsed_packet = packet.unpack('ccsss') temp = parsed_packet[2]/128
  19. 19. Posting to Pachube pachube_api_key = 'blahdyblahblah' LAT = 32.358098 LON = -110.980960 NAME = &quot;Dozer Software&quot; ELEVATION = 2545 temp = Temperature.temp() # Build the EEML XML env = EEML::Environment.new env.location = EEML::Location.new(:physical, :disposition => :fixed, :exposure => :outdoor, :ele => ELEVATION, :lat => LAT, :lon => LON, :name => NAME) data = EEML::Data.new(temp) data.tags << &quot;temperature&quot; data.unit = EEML::Unit.new(&quot;Celsius&quot;, :symbol => 'C', :type => :derivedSI) env << data # Create a connection to Pachube and update the feed pach = Pachube.new(pachube_api_key) resp = pach.update(&quot;/4077.xml&quot;, env.to_eeml)
  20. 21. Got GPS? <ul><li>GPSBabel ( http://www.gpsbabel.org/ ) </li><ul><li>Can pull GPS info from USB-device </li></ul><li>$ gpsbabel -i garmin,get_posn -f usb: -o garmin_poi -F - </li></ul>class Location attr_accessor :lat, :lng def initialize() get_coordinates end def get_coordinates begin coordinates = {} # gpsbabel will return CSV coordinates &quot;lng, lat, string, string&quot; data = ` gpsbabel -i garmin,get_posn -f usb: -o garmin_poi -F - ` data = data.chop.split(',') self.lng = data[0].to_s self.lat = data[1].to_s rescue self.lat = &quot;0&quot; self.lng = &quot;0&quot; end end # get_coordinates end
  21. 22. Phidgets!!! <ul><li>www.phidgets.com
  22. 23. USB-based Widgets </li><ul><li>Sensors
  23. 24. Servos
  24. 25. Controls </li></ul><li>phidgets4r </li><ul><li>Ruby wrapper for C lib
  25. 26. Need help with more devices! </li></ul></ul>
  26. 27. Driving a Servo... assert_nothing_raised { servo = Phidgets::Servo.new(-1, 2000) puts &quot;device_id: #{servo.getDeviceID}&quot; puts &quot;device_name: #{servo.getDeviceName}&quot; puts &quot;status: #{servo.getDeviceStatus}&quot; max = servo.getPositionMax(0) min = servo.getPositionMin(0) puts &quot;min: #{min} - max: #{max}&quot; servo.setPosition(0, 10.0) sleep 3 position = servo.getPosition(0) servo.close servo.delete }
  27. 28. Serve it Up! <ul><li>Sinatra: DSL for simple webapps
  28. 29. Live coding disaster to commence now... </li></ul>
  29. 30. Bug Labs BUG <ul><li>Modular Blocks for Base Processor Brick </li><ul><li>Hardware and software modularity </li></ul><li>Demo </li></ul>And Ruby ? Why Yes Please.

×