Brewing ALE with Pi

46
Brewing ALE with Pi Kristian Kristensen @kkristensen

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 of Brewing ALE with Pi

Page 1: Brewing ALE with Pi

Brewing ALE with PiKristian Kristensen

@kkristensen

Page 2: Brewing ALE with Pi

Get $5 to start:!http://bit.ly/

VenmoKristian

Page 3: Brewing ALE with Pi

Agenda

• Beer Brewing

• Raspberry Pi

• Erlang/ALE

• Monitoring temperatures

Page 4: Brewing ALE with Pi
Page 5: Brewing ALE with Pi
Page 6: Brewing ALE with Pi
Page 7: Brewing ALE with Pi
Page 8: Brewing ALE with Pi
Page 9: Brewing ALE with Pi
Page 10: Brewing ALE with Pi
Page 11: Brewing ALE with Pi
Page 12: Brewing ALE with Pi
Page 13: Brewing ALE with Pi
Page 14: Brewing ALE with Pi
Page 15: Brewing ALE with Pi
Page 16: Brewing ALE with Pi
Page 17: Brewing ALE with Pi
Page 18: Brewing ALE with Pi
Page 19: Brewing ALE with Pi
Page 20: Brewing ALE with Pi
Page 21: Brewing ALE with Pi
Page 22: Brewing ALE with Pi
Page 23: Brewing ALE with Pi

Raspberry Pi

• ARM 700 MHz CPU

• 512 MB RAM

• 10/100 Ethernet

• HDMI, Comp. Video, Audio.

• $40!

Page 24: Brewing ALE with Pi

Interface Real World (I)

• GPIO

• I2C

• SPI

• <Others>

Page 25: Brewing ALE with Pi

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

Erlang/ALE

• Actor

• Library for

• Embedded

https://github.com/esl/erlang_ale

Page 27: Brewing ALE with Pi

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

Architecture

• Fix the mess we saw earlier

• Familiar abstractions

• Clean model

Page 29: Brewing ALE with Pi

What works

• GPIO and GPIO interrupts

• Basic I2C and SPI

• Erlang Solutions actively working on it

Page 30: Brewing ALE with Pi

GPIO

A

GPIO

pin 17

{init, 17, output}

Page 31: Brewing ALE with Pi

GPIO

A

GPIO

pin 17

{state, 17, high} B

C{state, 17, high}

{state, 17, low}

Page 32: Brewing ALE with Pi

GPIO Supervisor

• Replaces locks

• Access Control, Mutual Exclusion

• Safety constraints

• Toggling, sequence detection, direction control, etc.

Page 33: Brewing ALE with Pi

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 34: Brewing ALE with Pi

Blink some LEDs

• http://bit.ly/18KP8xF

Page 35: Brewing ALE with Pi

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
Page 37: Brewing ALE with Pi

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
Page 39: Brewing ALE with Pi
Page 40: Brewing ALE with Pi

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

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
Page 43: Brewing ALE with Pi
Page 44: Brewing ALE with Pi

Projects

• Kegerator control

• Boil Wort

• Strike water, Hot Liquor Tank

• Mash temperature

• Fermentation Chamber Control

Page 45: Brewing ALE with Pi

Thank you

Page 46: Brewing ALE with Pi

Links

• https://github.com/esl/erlang_ale

• http://www.erlang-embedded.com/

• Blink LEDs: http://bit.ly/18KP8xF

• Read Temperature: http://bit.ly/1cst0ah