Brewing ALE with Pi

Post on 30-Aug-2014

408 views 1 download

Tags:

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

Brewing ALE with PiKristian Kristensen

@kkristensen

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

VenmoKristian

Agenda

• Beer Brewing

• Raspberry Pi

• Erlang/ALE

• Monitoring temperatures

Raspberry Pi

• ARM 700 MHz CPU

• 512 MB RAM

• 10/100 Ethernet

• HDMI, Comp. Video, Audio.

• $40!

Interface Real World (I)

• GPIO

• I2C

• SPI

• <Others>

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?

Erlang/ALE

• Actor

• Library for

• Embedded

https://github.com/esl/erlang_ale

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/)

Architecture

• Fix the mess we saw earlier

• Familiar abstractions

• Clean model

What works

• GPIO and GPIO interrupts

• Basic I2C and SPI

• Erlang Solutions actively working on it

GPIO

A

GPIO

pin 17

{init, 17, output}

GPIO

A

GPIO

pin 17

{state, 17, high} B

C{state, 17, high}

{state, 17, low}

GPIO Supervisor

• Replaces locks

• Access Control, Mutual Exclusion

• Safety constraints

• Toggling, sequence detection, direction control, etc.

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).

Blink some LEDs

• http://bit.ly/18KP8xF

Interrupts{ok, _} = gpio:start_link(?IN_PIN, input), !ok = gpio:set_int(?IN_PIN, rising), !handle_info({gpio_interrupt, _Pin, _Condition}, State) -> blink().

1-wire

• Creates a network of sensors all communicating using 1 single wire

• Great digital thermometer sensor available

• DS18B20

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

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

Projects

• Kegerator control

• Boil Wort

• Strike water, Hot Liquor Tank

• Mash temperature

• Fermentation Chamber Control

Thank you

Links

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

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

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

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