Exploring the Internet of   Things with Ruby                 Lone Star Ruby Conf 2012
Man Versus Wild…
The Great Adventure
The Oh No Moment          (aka – I am going to have to drink my urine)
Whoami   Mike Hagedorn   @mwhagedorn   github.com/mwhagedorn
Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
Internet of Things?Objects-> Internet -> Servers“Listen to your world, talk to the Internet”                        http:/...
Things Talk back
@MarsCuriosity
Botanicalls
IOT Devices Arduino Rasberry Pi Twine
Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
The USB Lamp Project                 http://www.thekua.com
The USB Lamp Project libusb gem   open a context   browse for your device   NOT Easy!   open the device   send messag...
The USB Lamp Project Lots of Questions   How do you send messages?   What is the form of the messages?
Use The Source Luke…void USBLamp::init() {  char data1[8] = { 0x1f, 0x02, 0x00, 0x2e,             0x00, 0x00, 0x2b, 0x03 }...
Use The Source Luke…void USBLamp::send(char *bytes, int size) {  …  CALL(usb_control_msg(…))  …}
Array#pack & String#unpack pack   Array of numbers to a binary string     [97,98,99].pack("c*")     => "abc“  unpack   ...
Demo
Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
The IOT printer
The IOT printer
Arduino
Ethernet Shield
Arduino IDE
To Rad or Not To Rad
To Rad or Not To Rad
Tools You Can Trust
Use TextMate!
Use Terminal! You can monitor the serial port via Terminal> ls /dev/tty.*> screen <dev> <baud-rate> End with cntrl-A, cn...
IOT-Assistant    github.com/newsinternational/iot-assistant
ArchitectureOAuth       TweetsCalendars
Suiting It To MeCalendar   Tasks   News   Twitter                          (Oauth)
Omnifocus Challenges How can I get my tasks exported? How can I get them up to the server?
Applescript
Applescript Dictionary
Exporting Omnifocus tasks#!/usr/local/bin/macrubyframework Foundationframework ScriptingBridgeOFOC = "com.omnigroup.Omnifo...
How can the server get this? Omnifocus tried to solve this Have to expose your desktop on internet More work than most ...
Use HP Object Storage!
HpObjectStore Helper Uses Fog def tasks_dir   @connection.directories.get("omnifocus") end def update_tasks_file(content)...
Update Cloud Bucket Run a chron job from my desktop server All my omnifocus installs are already synced Server gets a c...
Outlook Need my calendar Don’t want to deal with corp security Use the same omnifocus technique
The Printout
The Arduino Code
Demo
Agenda Internet Of Things in General Ruby and USB Ruby and RFID The IOT Printer The IOT Display
The IOT Display                  Original Inspiration:                  http://bit.ly/vlMMvr
Arduino
32X8 Led Panel                 http://bit.ly/wyuE5V
WiFly
Fritzing Sketch
Using IOT-A Already had an infrastructure Already had a datasource Format didn’t make sense for LED Display
User-Agent Use two different User-Agent header values User-Agent:IOTDisplay User-Agent:IOTPrinter JSON representation ...
Memory and the Sad Panda Standard JSON parser took up too much  memory Char strings storage Had to give up a key feature
Demo
HP Cloud For Free!           https://www.hpcloud.com/free-trial                 @mwhagedorn                     Thanks!   ...
Exploring the Internet of Things Using Ruby
Upcoming SlideShare
Loading in …5
×

Exploring the Internet of Things Using Ruby

2,634 views

Published on

talk on the internet of things and how ruby can be used. Given at lsrc12

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

No Downloads
Views
Total views
2,634
On SlideShare
0
From Embeds
0
Number of Embeds
46
Actions
Shares
0
Downloads
20
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • How many of you have heard of Bear Grylls?
  • The Grand AdventureThe Exciting BeginningThe Oh Oh MomentThe Big Finish
  • Its not so important what those moments are..He overcomes, learns----- Meeting Notes (8/10/12 09:03) -----
  • Developer Experience – user tools, management consoleDistributed Team About 15Subtext – I am interested in ways to automate what it means to be a remote team
  • Also gonna talk about MacRuby, Automation using the scripting bridge
  • Quote from the twine guys
  • Contrast to 2004 yellowstone trip, when it was almost nowhere (JIWIre)Some kind of research about the growth of wifi availability
  • Not the same as a bar code, you can write information to it.. Shelf life for instance, date stockedActive Example – tollway tags
  • Industry, Retail – 3c per tag, hospitals
  • This is a great book BTW.Most people think about the IOT being objects actively talking back
  • Twine supermechincalWe arent gonna talk much the other stuff just due to time
  • ----- Meeting Notes (8/10/12 22:51) -----14 minutes at USB Lamp
  • My Episode 1
  • Worth noting that this happens once in the c codeCould never get that to work in the ruby codeAlso the control message
  • Worth noting that this happens once in the c codeCould never get that to work in the ruby codeAlso the control message
  • Format specifier indicates signed 8 bit val (-127 to 127).. Why is this? Why not unsigned----- Meeting Notes (8/10/12 22:51) -----Demo at 18:20
  • ----- Meeting Notes (8/10/12 22:51) -----Talk about the format of the color msg (37)
  • Kit from AdafruitCode that ships with pulls tweetsTook me about two hours to put togetherSimple soldering
  • Thermal printer, code that is listed for the kip pulls tweets
  • Small device, low power, easy to interface to sensors, programmed in a C variant.. Only 30K of sram. Doesn’t run mruby
  • Shields are expansion boards, they do lots of stuff, servo control data logging,
  • Builds, uploads, provides docs, serial monitor. NOT Ruby.
  • Code generatorGenerates C++ which gets pushed (arduino does this too)Problem is that step one part is kinda hard codedEvan Lights DSL generator -&gt; AST
  • Code generatorGenerates C++ which gets pushed (arduino does this too)Problem is that step one part is kinda hard codedEvan Lights DSL generator -&gt; AST
  • You can build, upload and view serial port all via textmate
  • Rails APPSource is availableSchedule printoutsSelect what prints Do on demand printouts
  • Google for OAUTHGoogle for CalendarTwitter for FeedsTimes of London for latest news
  • I don’t use google tasks.. What do I doDeployed it on nova hpcs
  • Old sample code omnifocus released (evan light worked on it)
  • Applescript EditorApplescript allows you to automate apps on the platformMost apps have a scripting interfaceBut Applescript is kinda weird, suboptimal
  • Allows you see if they have a scripting interface, and what commands are available
  • Don’t want to use Applescript?Use MacRuby and the Scripting BridgeHave to build support files (basically a header file)This doesn’t show the export part…This doesn’t show filtering by projectI had issues with grabbing the project and its tasks throwing an exceptionHad to get them all then throw away ones I don’t want
  • Putting my home machine on the net problematic. Omnifocus people gave you a rough howto and it was more work than people wanted to do
  • Connection details are in the file…
  • Show the omnifocus stuff added in
  • We use Outlook
  • You download the code from the website if you are an admin
  • Reset printer firstLogin via serialPull SerialThen resetShow front pageUsing twitter oauthShow printoutsShow Settings pageShow printer downloadDo an on demand printoutSwitch to omnifocusUploadHPCS OSShow fileSkip OutlookOn Demand PrintShow template for printerLet it print
  • I wanted a networked, display that listened on a socket and displayed messages.. Think CallerID. On demand messages
  • Wanted to use the most common paradigm, i.e. wifiXbee – need other hardware..Bluetooth – can be flakyLast one really interesting(cheap)
  • Yellow are controlRed powerBlack GndBlue DataGrey Read/Write
  • Uses constraints to set the format on inbound request, so that that respond to block can handle it
  • aJson wont fit… too little memory
  • Probably not
  • Time sensitive updates where getting dropped, mixing code for timing and logic.. Needed a solution
  • Also cosm, open source version, running on HPCS
  • On demand?, stop polling revisit rad?
  • Chad Fowler’s book, faraday probably was quoting Benjamin Franklin
  • Exploring the Internet of Things Using Ruby

    1. 1. Exploring the Internet of Things with Ruby Lone Star Ruby Conf 2012
    2. 2. Man Versus Wild…
    3. 3. The Great Adventure
    4. 4. The Oh No Moment (aka – I am going to have to drink my urine)
    5. 5. Whoami Mike Hagedorn @mwhagedorn github.com/mwhagedorn
    6. 6. Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
    7. 7. Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
    8. 8. Internet of Things?Objects-> Internet -> Servers“Listen to your world, talk to the Internet” http://supermechanical.com/
    9. 9. Things Talk back
    10. 10. @MarsCuriosity
    11. 11. Botanicalls
    12. 12. IOT Devices Arduino Rasberry Pi Twine
    13. 13. Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
    14. 14. The USB Lamp Project http://www.thekua.com
    15. 15. The USB Lamp Project libusb gem  open a context  browse for your device NOT Easy!  open the device  send message  close device
    16. 16. The USB Lamp Project Lots of Questions  How do you send messages?  What is the form of the messages?
    17. 17. Use The Source Luke…void USBLamp::init() { char data1[8] = { 0x1f, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x03 }; send(data1, sizeof(data1)); char data2[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x04 }; send(data2, sizeof(data2)); char data3[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x05 }; send(data3, sizeof(data3));}
    18. 18. Use The Source Luke…void USBLamp::send(char *bytes, int size) { … CALL(usb_control_msg(…)) …}
    19. 19. Array#pack & String#unpack pack  Array of numbers to a binary string [97,98,99].pack("c*") => "abc“  unpack  Binary string to array "abc".unpack("c*") => [97,98,99]
    20. 20. Demo
    21. 21. Agenda Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
    22. 22. The IOT printer
    23. 23. The IOT printer
    24. 24. Arduino
    25. 25. Ethernet Shield
    26. 26. Arduino IDE
    27. 27. To Rad or Not To Rad
    28. 28. To Rad or Not To Rad
    29. 29. Tools You Can Trust
    30. 30. Use TextMate!
    31. 31. Use Terminal! You can monitor the serial port via Terminal> ls /dev/tty.*> screen <dev> <baud-rate> End with cntrl-A, cntrl-
    32. 32. IOT-Assistant github.com/newsinternational/iot-assistant
    33. 33. ArchitectureOAuth TweetsCalendars
    34. 34. Suiting It To MeCalendar Tasks News Twitter (Oauth)
    35. 35. Omnifocus Challenges How can I get my tasks exported? How can I get them up to the server?
    36. 36. Applescript
    37. 37. Applescript Dictionary
    38. 38. Exporting Omnifocus tasks#!/usr/local/bin/macrubyframework Foundationframework ScriptingBridgeOFOC = "com.omnigroup.Omnifocus”@of = SBApplication.applicationWithBundleIdentifier(OFOC)load_bridge_support_file Omnifocus.bridgesupport@doc = @of.defaultDocumenttasks = []@doc.flattenedTasks.get.each do |task| tasks << taskend
    39. 39. How can the server get this? Omnifocus tried to solve this Have to expose your desktop on internet More work than most people want to do
    40. 40. Use HP Object Storage!
    41. 41. HpObjectStore Helper Uses Fog def tasks_dir @connection.directories.get("omnifocus") end def update_tasks_file(content) tasks_dir.files.create(:key => "tasks.json", :body => content) end
    42. 42. Update Cloud Bucket Run a chron job from my desktop server All my omnifocus installs are already synced Server gets a current task list
    43. 43. Outlook Need my calendar Don’t want to deal with corp security Use the same omnifocus technique
    44. 44. The Printout
    45. 45. The Arduino Code
    46. 46. Demo
    47. 47. Agenda Internet Of Things in General Ruby and USB Ruby and RFID The IOT Printer The IOT Display
    48. 48. The IOT Display Original Inspiration: http://bit.ly/vlMMvr
    49. 49. Arduino
    50. 50. 32X8 Led Panel http://bit.ly/wyuE5V
    51. 51. WiFly
    52. 52. Fritzing Sketch
    53. 53. Using IOT-A Already had an infrastructure Already had a datasource Format didn’t make sense for LED Display
    54. 54. User-Agent Use two different User-Agent header values User-Agent:IOTDisplay User-Agent:IOTPrinter JSON representation for display
    55. 55. Memory and the Sad Panda Standard JSON parser took up too much memory Char strings storage Had to give up a key feature
    56. 56. Demo
    57. 57. HP Cloud For Free! https://www.hpcloud.com/free-trial @mwhagedorn Thanks! https://github.com/mwhagedorn/IOTDisplay.git https://github.com/mwhagedorn/iot_printer_remote.git https://github.com/mwhagedorn/iot-assistant.git https://github.com/mwhagedorn/thingspeak.git

    ×