Your SlideShare is downloading. ×
Using Erlang on the RaspberryPi to interact with the physical world
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Using Erlang on the RaspberryPi to interact with the physical world

3,606
views

Published on

Embedded linux systems are gaining in popularity in the maker/hacker communities. Platforms such as the BeagleBone and RaspberryPi have created new interest in systems which can interact with the …

Embedded linux systems are gaining in popularity in the maker/hacker communities. Platforms such as the BeagleBone and RaspberryPi have created new interest in systems which can interact with the physical world. However, interacting with the physical world can be a challenge. Luckily, we have Erlang to help us out. This talk covers new hardware platforms, embedded linux systems, why Erlang is a good fit, and how you can get started hardware hacking the world with Erlang.

Published in: Technology, News & Politics

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,606
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
51
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Have some Erlangon your RaspberryPi(Using Erlang in embedded linux systems)Friday, June 21, 13
  • 2. But first, some context(i.e. Why running Erlang on theRaspberryPi might be interesting...)Friday, June 21, 13
  • 3. nowyears agodecades agoa long time ago(in a galaxy far, far away...)The progressionmainframedesktoplaptopsmartphonetablet?We all are aware of the inevitable progression towards more diverse, smaller, andpowerful software enabled devices. It is pretty obvious. In addition to this, it’s clear thatdevices are designed around certain modes of interactions and interaction duration.However, there is a new space in consumer devices which allows for entirely differentways of interaction (and in some cases no interaction at all).Friday, June 21, 13
  • 4. The quantified self/internet of things?FitBit/Fuel BandWiThings BodyScaleScoutAlarmSmartThingsPebble WatchPhilips Hue/ Blink(1)NinjaBlocksBelkin WeMoSwitchThis new space is based onthe idea that devices can bepassive observers of humanbehavior, the environment,or other sources of data.This is the central idea ofthe quantified self/internetof things. Initially devices arefocused around health andactivity.There will be anincreasing growth in otherareas.Friday, June 21, 13
  • 5. GamesInformationEnvironmentSecurityHealthThe quantified self is part ofthe “Internet of Things”There are more and more devicesentering the market every month.To date, a large number have beenfocused on health (e.g. FitBit,Nike Fuel) and security (e.g.ScoutAlarm). Over time thesedevices will enter other aspects ofhuman activity. Some sense andcontrol the home environment(e.g. Nest), others provideinformation from internetservices (e.g. Philips Hue), andsome might be purely forentertainment and a platform forgames.Friday, June 21, 13
  • 6. In addition to lots of interesting consumer products.There are lots of new and interesting hardwareplatforms. Almost all run embedded linux.Friday, June 21, 13
  • 7. What are people doing withthese boards?Friday, June 21, 13
  • 8. Friday, June 21, 13
  • 9. Friday, June 21, 13
  • 10. Build your own Google Glass perhaps?...Friday, June 21, 13
  • 11. Ok, but what does this have todo with Erlang?Friday, June 21, 13
  • 12. Small, cheap hardwareLinux=Lots of internetconnected, linuxpowered, small, cheap,embedded devices+Expensive, big hardwareErlang=A massively scaleable,fault tolerant systemwhich runs on embeddedsystems+The Internet+The phone network+Well, there are some parallels betweenthese “internet of” devices and ErlangFriday, June 21, 13
  • 13. What is Erlang?(hint: It’s pronounced “Air-lang” not “Errr-lang”)Friday, June 21, 13
  • 14. • Creating and destroying processes is very fast• Sending messages between processes is very fast• Processes behave the same way on all operating systems• We can have very large numbers of processes (1,000’s to 100,000’s)• Processes share no memory and are completely independent• The ONLY way for processes to interact is through message passingLike some languages are object oriented,Erlang is “process oriented”. For example,in Erlang:Erlang is a general purpose concurrent programminglanguage and runtime system. It is a functionallanguage which has strict evaluation, singleassignment, and dynamic typing. Originally designedby Ericsson to support distributed, fault-tolerant,soft-real time, non-stop applications. [from wikipedia]Friday, June 21, 13
  • 15. This is a sample of code from the demo portion of this presentation. It defines a modulecalled “net_led” which controls an LED over the local network. Erlang code is composedinto modules which expose certain functions via the “export” directive. In this module, Iexport methods to spawn the LED light process on one machine.Then have a switchfunction which controls the light via a different process running on a separate machine. Inthe sample below there are two functions defined,“decouple” and “switch.” These takeparameters about the LED light process and then send messages to that process.The “!” isthe message send operator.Full source can be found here: https://gist.github.com/breakpointer/5799847Friday, June 21, 13
  • 16. What does Erlang look like?Friday, June 21, 13
  • 17. Object Oriented Process OrientedRuby Erlangclass Foodef barputs “hello!”endendDefinition-module(foo).-export([bar/0]).bar() ->io:format(‘hello!~n’,[]).Instantiation >f = Foo.new>f.bar#=> hello!>foo:bar().hello!>F = spawn(foo, bar, []).hello!<0.34.0>Simple comparison of Ruby to ErlangOrientationFriday, June 21, 13
  • 18. How does one use Erlang?Friday, June 21, 13
  • 19. process processspawnreceiveErlangVMprocessprocessspawnspawn{messages}receiveA typical application will use many processes, andmessage passing for inter-process communicationsFriday, June 21, 13
  • 20. How is Erlang usedon the RaspberryPi?Friday, June 21, 13
  • 21. The components of the RaspberryPiYour interface to the world!Friday, June 21, 13
  • 22. Friday, June 21, 13
  • 23. Accessing the GPIO pins through Linux SysFsOS mapping location of pins:Exporting a pin for use:Reading the value of a pin as that pin is toggled high/low:Friday, June 21, 13
  • 24. Imagine a product calledThe Baconator*How might this system bemodeled?(*patent/trademark/startup pending...)Friday, June 21, 13
  • 25. SysFsDispenseprocess{messages}receiveMakeBaconprocessButtonprocess{messages}receiveGPIOio:Readio:WriteThe Baconator!A.K.A. the most awesome bacon dispensing machine in the world!Baconsupervisor Instructions:Step 1) Push buttonStep 2) Receive baconStep 3) NomNomNomsoftware hardwareFriday, June 21, 13
  • 26. Demo: Erlang poweredLED light and “switch”(Sorry, no bacon will be auto-dispensed tonight)Friday, June 21, 13
  • 27. erl shellprocessswitchprocessspawnreceiveErlangVMerl shellprocessLEDlightprocessspawnreceiveErlangVM{messages}{messages}LaptopRaspberryPi{{local networkFriday, June 21, 13
  • 28. Next steps for the Erlang andembedded systemsFriday, June 21, 13
  • 29. A website to watch for progress on embedded erlangFriday, June 21, 13
  • 30. Side Project: Dash-dot-com(a sass-talking web controlled animatronic puppet)Friday, June 21, 13
  • 31. How to get Erlang runningon the RaspberryPi?(It’s incredibly easy, I swear)Friday, June 21, 13
  • 32. deb http://binaries.erlang-solutions.com/debian wheezy contribIf you have the latest Raspbian distro...add the package location to /etc/apt/sources.listadd the public key for apt-secureInstall the packagewget -O - http://binaries.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -sudo apt-get updatesudo apt-get install esl-erlangFrom the console, fire up the Erlang REPLerlFriday, June 21, 13
  • 33. ResourcesFriday, June 21, 13
  • 34. • http://www.adafruit.com or http://www.sparkfun.com• http://www.erlang-embedded.com/• http://www.erlang-solutions.com/section/132/download-erlang-otp• https://github.com/omerk/erl-hw/• http://www.infoq.com/interviews/kilic-erlang-embedded• http://www.erlang-factory.com/upload/presentations/451/Wiger-erlangforembedded.pdf• http://www.1011ltd.com/web/blog/post/embedded_erlangFriday, June 21, 13
  • 35. Questions?!Brian Chamberlainblchamberlain@gmail.com@breakpointerhttp://breakpointer.coFriday, June 21, 13