brewing ale with pi
DESCRIPTION
I'm an avid home brewer and what better than to combine your hobbies in the service of home brewing? The Raspberry Pi is a low cost computer with some very nifty interfaces for interacting with the real world. We can utilize that to monitor all things home brewing to make sure our brews come out great! Join me for a whirlwind tour of brewing beer and hacking Erlang on the Raspberry Pi. Agenda: The Raspberry Pi Erlang on Pi using Erlang/ALE (Actor Library for Embedded) Beer Brewing Monitoring temperatures Target audience: Anyone interested in Raspberry Pi and how you can get started with Erlang on it. Anyone interested in beer and how it's made.TRANSCRIPT
![Page 1: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/1.jpg)
Brewing ALE with PiKristian Kristensen
@kkristensen
![Page 3: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/3.jpg)
Agenda
• Beer Brewing
• Raspberry Pi
• Erlang/ALE
• Monitoring temperatures
![Page 4: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/4.jpg)
![Page 5: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/5.jpg)
![Page 6: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/6.jpg)
![Page 7: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/7.jpg)
![Page 8: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/8.jpg)
![Page 9: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/9.jpg)
![Page 10: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/10.jpg)
![Page 11: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/11.jpg)
![Page 12: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/12.jpg)
![Page 13: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/13.jpg)
![Page 14: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/14.jpg)
![Page 15: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/15.jpg)
![Page 16: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/16.jpg)
![Page 17: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/17.jpg)
![Page 18: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/18.jpg)
![Page 19: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/19.jpg)
![Page 20: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/20.jpg)
![Page 21: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/21.jpg)
![Page 22: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/22.jpg)
![Page 23: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/23.jpg)
Raspberry Pi
• ARM 700 MHz CPU
• 512 MB RAM
• 10/100 Ethernet
• HDMI, Comp. Video, Audio.
• $40!
![Page 24: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/24.jpg)
Interface Real World (I)
• GPIO
• I2C
• SPI
• <Others>
![Page 25: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/25.jpg)
Interface Real World (II)• Memory Mapped
• /dev/mem
• Fast, needs root, dangerous!
• Kernel modules
• Slow, doesn’t need root, easier, safer
• Can Erlang help us?
![Page 26: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/26.jpg)
Erlang/ALE
• Actor
• Library for
• Embedded
https://github.com/esl/erlang_ale
![Page 27: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/27.jpg)
Erlang (hearts) Embedded
• Soft real time
• Concurrency and Parallelism
• Fault tolerant & Robust
• Hot-code loading • (http://www.erlang-embedded.com/2013/10/minimal-downtime-in-flight-drone-firmware-upgrade-in-erlang/)
![Page 28: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/28.jpg)
Architecture
• Fix the mess we saw earlier
• Familiar abstractions
• Clean model
![Page 29: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/29.jpg)
What works
• GPIO and GPIO interrupts
• Basic I2C and SPI
• Erlang Solutions actively working on it
![Page 30: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/30.jpg)
GPIO
A
GPIO
pin 17
{init, 17, output}
![Page 31: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/31.jpg)
GPIO
A
GPIO
pin 17
{state, 17, high} B
C{state, 17, high}
{state, 17, low}
![Page 32: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/32.jpg)
GPIO Supervisor
• Replaces locks
• Access Control, Mutual Exclusion
• Safety constraints
• Toggling, sequence detection, direction control, etc.
![Page 33: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/33.jpg)
Blink some LEDs
{ok, _} = gpio:start_link(?LED_PIN, output), !blink() -> gpio:write(?LED_PIN, 1), ! timer:sleep(1000), ! gpio:write(?LED_PIN, 0), ! timer:sleep(1000).
![Page 35: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/35.jpg)
Interrupts{ok, _} = gpio:start_link(?IN_PIN, input), !ok = gpio:set_int(?IN_PIN, rising), !handle_info({gpio_interrupt, _Pin, _Condition}, State) -> blink().
![Page 36: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/36.jpg)
![Page 37: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/37.jpg)
1-wire
• Creates a network of sensors all communicating using 1 single wire
• Great digital thermometer sensor available
• DS18B20
![Page 38: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/38.jpg)
![Page 39: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/39.jpg)
![Page 40: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/40.jpg)
Raspberry Pi & 1-wire• Kernel module
• /sys/bus/w1/devices/28-0000044719d7/w1-slave
• =>
• 4b 01 4b 46 7f ff 0e 10 d8 : crc=d8 YES4b 01 4b 46 7f ff 0e 10 d8 t=26125
![Page 41: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/41.jpg)
Read temperature• read(<<A1:16,_,A2:16,_,A3:16,_,A4:16,_,A5:16,_,A6:16,_,A7:16,_,A8:16,_,CRC:16,_,$:,_,”crc=",CRC:16,_,"YES",Rest0/binary>>
• read(<<A1:16,_,A2:16,_,A3:16,_,A4:16,_,A5:16,_,A6:16,_,A7:16,_,A8:16,_,CRC:16," t=",Rest/binary>>
• http://bit.ly/1cst0ah
![Page 42: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/42.jpg)
![Page 43: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/43.jpg)
![Page 44: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/44.jpg)
Projects
• Kegerator control
• Boil Wort
• Strike water, Hot Liquor Tank
• Mash temperature
• Fermentation Chamber Control
![Page 45: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/45.jpg)
Thank you
![Page 46: Brewing ALE with Pi](https://reader034.vdocuments.us/reader034/viewer/2022052301/5400e7c08d7f72c1628b45ca/html5/thumbnails/46.jpg)
Links
• https://github.com/esl/erlang_ale
• http://www.erlang-embedded.com/
• Blink LEDs: http://bit.ly/18KP8xF
• Read Temperature: http://bit.ly/1cst0ah