All right, good.
Today, I'm going to be giving a presentation called Brewing Free Beer with ESP Home and Home Assistant.
This is free as in beer, as in freedom beer.
I love brewing.
My name is John Britton and I'm an amateur brewer.
This is a Belgian triple that I brewed this summer back at my house in western Massachusetts.
I'm also a contributor to Homebrew, the open source package manager.
I'm a cheer at that as well.
And I'm the co-founder of a company called Workbrew, which is a team for tools that use Homebrew at work.
Here's an outline of what we're going to be talking about today.
First, I'm going to give you an overview of something called All Green Brewing,
which is in contrast to something called Extract Brewing, which some of you may have heard of before.
Then we're going to talk about building a brewery, specifically a Hermes style three vessel system.
And then we're going to get into the open source stuff.
There's a really cool project called the Electric Brewery that if you're interested in this,
I highly recommend you check out their website.
They have tons and tons of DIY guides.
I would assume many of you have heard of an ESP32 before, but I'll give a little introduction to that
and a project called ESP Home, which is for writing firmware and programming ESP devices,
and lastly Home Assistant.
So let's start with All Green Brewing.
What is beer?
There's four main ingredients, water, malted grain, hops, and yeast.
The process of making beer is extracting the sugar from the malted grain,
adding in hops for flavor, and then using yeast to convert the sugar that's extracted from the grain into alcohol.
Water is the most abundant ingredient in your beer.
I think of it as like the canvas.
In my brewing, I use well water.
I just take the water right out of the ground and use it as it is.
Some people I know use spring water.
They buy it at the store.
Sophisticated brewers will do chemical testing on their water to get an idea of what salts are dissolved
and they'll add their own additives to make it the palette that they want for their beer.
And if you're really, really into this stuff, you can use reverse osmosis or distilled water
to start from a totally blank slate and add your own kind of salts and whatnot.
Next is malted grain.
Primarily barley.
Barley is malted in a process where you steep it in liquid, which starts a germination process.
During germination, the organism converts using enzymes, some starches into sugars,
and then you kiln the grain, which is kind of like toasting it to stop the germination, stop it from growing,
and it also imparts color and flavor.
Hops, probably the most famous of the beer ingredients,
added during boiling and during the fermentation process to add bitterness and aroma.
And then lastly yeast, which is used to convert sugar into alcohol.
Primarily there are two types of yeasts, ales and loggers.
I'm an amateur brewer so I won't tell you the difference between the two other than loggers are much more difficult.
So next, how is beer made?
There's a lot of steps.
One of these steps can be broken down into a whole day lecture.
So I'm going to give you a really high level overview of mashing, sparging, boiling, fermenting, and packaging.
So the first thing that you do is you take your grain that's already been malted by your maltster,
you crush it up, you put it in a pot, and you add hot water.
The hot water works like tea.
It extracts the sugars from the malt and then it releases them into the liquid.
The next step is sparging, where you add more liquid on top of this kind of grain bed
and strain the water through, extracting the sugar from your mash.
And in this picture you can see that it's kind of, the liquid on top is clear.
By the end of your sparge, the liquid that's going through basically has nothing in it.
You've extracted all of the sugars out of your mash.
The next step is boiling.
Boiling primarily exists to sterilize,
but it also removes volatile compounds that create off flavors in your beer.
During your boil you can add your aromatic and your bittering hops to extract the flavor.
And then the last step, after you boil you chill your wort down.
So basically all of the process we've talked about so far is making wort.
Then you put it into a fermenter, add yeast, and the yeast makes the beer.
So that's kind of the process.
After a couple of weeks, in my case I usually let this sit for about two to three weeks.
Take a couple of readings to see how the alcohol, the process has progressed.
And then lastly, packaging.
Beginner brewers will often use bottling because it's really easy, there's not a lot of equipment.
But it takes a lot of time.
Step by step you've got to put each bottle, fill it up.
Additionally you have to add more sugar into your beer at the end,
so that the yeast can then convert that sugar into more alcohol and produce CO2 to carbonate your beer.
After a new brewer gets into packaging their beer with bottles, inevitably they switch to kegs and they do forced carbonation.
So basically after you're done boiling, you chill down the beer, you put it in a keg,
you use a container of CO2 and you pressurize it to a high PSI and you let it sit for a couple of days,
and then you have carbonated beer ready to drink.
So this is all fine and good.
I wanted to go out and try this for myself.
I had some friends in university who did home brewing.
They did extract brewing, so basically on the stove in their kitchen.
And my friends and my family all know that I like to overdo everything,
so I decided I was going to do this all grain and build it from scratch myself.
There's lots of different systems you can use.
I decided to use something called the Herms three vessel system.
Herms stands for heat exchange recirculating mash system.
It's basically three kettles, so the three squares in the middle are each 20 gallons,
I don't know, like 40 liters or so, I guess.
That's my brewing set up on the right.
This is kind of like a diagram.
From right to left, you have the hot liquor tank, which is used for the starter water that you use to make the beer.
You heat it up to a certain temperature.
Then in the middle you have the mash louder ton, which is where the process of mashing happens.
You add your grain in there.
And then lastly you have the boil kettle.
And down below you see the two circular things, those are pumps.
Those pumps are rated for high temperature, food grade, etc.
And then in the bottom left you have a chiller, this kind of coil thing.
You run cold water in one direction and hot work through the other direction to cool it down.
All of this stuff is available online through the open source project called the Electric Brewery.
Now I say open source, they call themselves open source.
They have a shop, they sell all their stuff, but really it's just, there's a website,
it has tons of information, and they have two main guides, building your brewery and using your brewery.
And what's cool about the Electric Brewery setup is everything is off the shelf.
So you could go out, you could buy a brewery setup from a vendor, but if some part breaks, you're beholden to that vendor.
And if that vendor goes out of business, if you can't get the part anymore, you're kind of host.
With the Electric Brewery, everything is what you get in the plumbing section of your local hardware store.
And in the electronics section or in the electrician section of your home improvement store.
So when it comes to controlling this system, they have a control panel that you can build yourself.
It takes months to do.
And also the components alone cost, you know, 1500 US dollars or more.
And if you want to buy it pre-assembled, it's only 2300 dollars.
So totally out of the price range of what I was willing to do.
So I thought to myself, what actually is this thing doing?
Well, all it's really doing is turning on and off a high voltage, high amperage switch for a heating element.
So inside of my hot liquor tank and inside of my boil kettle, I have a heating element.
And it's the same heating element that you find in like a US like water heater, like a household water heater that's maybe 50 or 100 gallons.
It's the same kind of thing.
And all this does is let you set a temperature and turn it on and off according to a schedule.
It's a PID controller basically.
But because it's high voltage, high amps, you need to do a lot of stuff for safety.
So I thought, can I replace this with a microcontroller?
And I started to learn about ESP32.
I found the dev boards, you know, you could buy one of these dev boards for less than 10 dollars.
It has Bluetooth, it has Wi-Fi, it has a processor on it, it has tons of GPIO.
And it has a huge community of support for building things, you know, with it.
There are also lots and lots of devices out on the market that are built for consumers based off of ESP32.
So this device is called a Sonoff THR320D.
And it's a 20 amp relay with a display and a button and some LEDs and then nice terminals on the bottom where you can attach your electrical wires.
And so what I did is I basically bought one of these devices for less than 50 bucks, took it apart at home.
They don't have a UART on them, so I had to like solder in my own UART so that I could flash it.
But it's a normal ESP32.
And once I got my first firmware on there, I was able to do over-the-air updates.
So basically a $50 device now replaced a $2300 device.
So that was a pretty big savings for me.
The next project that I used with this whole thing is called ESP Home.
ESP Home, I believe, is made by the same folks that make Home Assistant, but it's a separate project.
And it exists to make it easier for people to build custom firmwares for their ESP32 devices without necessarily having to write C code.
I can write C code, I don't want to write C code, especially when I'm making beer.
Like, I don't think I can handle it.
So I took a look at ESP Home and learned that they have what they call components.
There's hundreds of these components.
Anything from Wi-Fi updates to PID controllers to switches to sensors to Bluetooth to long range radio without Wi-Fi, all kinds of different things you can do.
They're basically pre-made code snippets that you can piece together to make your own firmware.
So I'll give you just a tour of a couple of the core components that I used in my project.
One is GPIO component.
So this is just a code snippet that shows use the GPIO component, turn on pin number 27, and that powers up my temperature controller.
The Dallas component lets me read a digital output from the temperature sensor.
And then the most kind of valuable or biggest impact component that I used is climate.
Within the climate, this was made for, you know, managing a thermostat.
They have a platform called PID, which is proportional integral derivative.
And the idea is that it lets you set a set point of what temperature you want to reach, and then you can tune it with some algorithms so that rather than overshooting your target temperature and dropping and overshooting and dropping,
you can ease right up to your target temperature and hold it there within like 0.1 degrees Celsius very, very accurately.
So I wrote this, you know, it's not very many lines, 10 lines of code or so, put in my tuning parameters.
And you can see it says heat output, relay PWM output, and that connects to this component that I use, which is a P2M pulse width modulation.
So effectively what happens is the PID controller outputs a number between 0 and 1 indicating a percentage of power.
And then this PWM, what it does is I set it to a two minute period.
So if I set it to 50% in a two minute period, every two minutes, one minute the heater will be on and one minute will be off.
And it just pulses the relay on and off for me.
And the PID controller manages kind of the percentage automatically to hit the target.
And then there's another one that I used on here, so I showed that device has a button.
This is just a small snippet of the controls that I built, but it has on multi-click.
And you can just say when you touch the button down for one second and let go for at least 0.3 seconds, you can build whatever kind of gesture if you want, if you want to call it that.
I have a ton of them, but what's really nice is the firmware that I put on these devices runs totally locally without internet access, without network access.
And I can control the entire thing with one button by pressing a series of clicks.
Or I can open up my phone and do it with Home Assistant.
And then, for example, another one is interacting with LEDs.
So when the device is powered on, the power LED turns on or when the heating elements turn on.
The last kind of component to this is Home Assistant.
Home Assistant is a really awesome project that lets you control any kind of IoT device in your home.
And they have built right into it support for ESP Home.
So as you can see on the right side here, you can see my different brewery controllers, Brewery C.
I also have heat pumps that I'm controlling.
All of these are done in the same kind of gamel where I use a pre-existing module.
I have a couple of configurations and it automatically integrates.
And on the left side, that's my mobile phone.
So when I'm in the brewery, and this is what I see, I can drag the slider to set the temperature in my mash tun or in my boil kettle.
And then down to the bottom, I have on-off switches for my work pump and for my water pump.
And those are just done using smart plugs.
So the entire system costs maybe less than $100 in hardware with all the wiring and whatnot instead of $2,300.
So that's everything that I have to share with you.
Reference materials.
I definitely recommend it like Brewery, ESP Home, all of this stuff up there.
And then some photos of the finished products.
And that's it. Thank you very much.
We have time for just, I think, one question.
Okay, one question. Let's go to the guy in the front because it's just together.
He's in the front row, yeah.
Can you talk about all the sensors and...
Can you say it?
Say, you work with the Sonos device and I guess you have many other sensors.
Can you talk, did you do any reverse engineering or you just put them in ESP?
Yeah, so what's really great about this is the ESP Home community is huge.
And they have a directory on the ESP Home website of all of the devices that they know of that are ESP based.
So if you buy an off the shelf consumer ESP device, you can go to their website, see all the pinouts and everything.
And so, for example, when I said GPIO 27 is the...
There's like an RJ9 or RJ11 jack on top that's connected to that pinout.
I didn't have to figure that out. I just went to their website and it said the pinout for that pin is this number.
And it's all in a database.
The only thing that I had to kind of reverse engineer was off the shelf devices don't expect you to flash them so they don't have headers for the first flashing.
So once you get the first flash on there, you can do all over the air updates.
Thank you.
Okay, well, thank you.