Native Python BrewPi controller

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
In case anyone is interested, I have been working on a native Python version of the BrewPi controller. Basically I am converting the Arduino v0.2.11 code to Python so that it can run on the Pi itself and use the Pi GPIO pins to read temperatures and drive relays. This means that an Arduino is not required. Or it should mean that if the code is ever finished.

I want to thank Elco for making BrewPi a reality. When I was looking for some sort of temperature control it kept popping up everywhere with glowing reviews. I understand why a separate microcontroller was considered necessary, but I feel that most, if not all, of the early problems with the Pi have been fixed. As a purely personal project I decided to see if it was possible to run the code on the Pi itself. Thanks to Elco releasing the code as open-source I was able to look at it to see how it worked, and copy it so that I could convert it to Python. Unfortunately, as I wasn't immersed in BrewPi development from the beginning I don't understand everything about it, so some parts I guessed, and some parts I ignored. Still other parts are not implemented, but they are not all necessary.

If anyone wants a brewing controller that is affordable, reliable, and well-supported then I recommend you to buy a BrewPi Spark from Elco (www.brewpi.com). It is well-designed and has a clear roadmap for becoming much more than a simple temperature controller. If instead you want something flaky, unpredictable, and a bit rough around the edges then read on.

Firstly, I disclaim all liability for the code. It's not finished, and I am not committing to finish it. It has bugs. There are bits missing. It might ruin your beer. However, if there is enough interest then I hope others will be willing to inspect the code and submit bug fixes, and some intrepid DIYers to have a go at building one and giving feedback. If there is no interest than I'll just let it languish on github with a million other failed projects.

Secondly, it is not a plug-and-play solution. As you probably know there is a long-running thread on this forum for building a DIY BrewPi for cheap using an Arduino. It contains a wealth of information about the necessary hardware, how to hook it up, how to get the software installed and running and so on. Everything you need is there, and you will end up with a working system. For this project there is very little, so it has to be started from scratch. Curious builders will have to make a lot of effort themselves with no guarantee of success. It may turn out to have been a bad idea after all, in which case everyone's time and effort (and beer) will have been wasted. Sorry about that.

Having said that, I have it sort-of working on my Pi and I started running it yesterday in Beer Constant mode with actual beer (I had tested it only with water previously). I don't have a fridge so I am using a Son of Fermentation Chiller chamber with a heater added. It has just enough functionality to do what I want, which was my original goal.

I would like to thank FuzzeWuzze for taking the initiative to promote the first DIY BrewPi project on this forum, and for his willingness to test my code and offer feedback. The code worked for him (that is to say, it runs), which gives me confidence that it is possible for anyone else to download it and make it run. FuzzeWuzze has also helpfully pointed out some glaring errors. In a nice way, of course. Thanks.

At the moment it is a direct port, with no optimisations or too many Pythonic idioms. My first goal was to get something working. Optimisations and feature-creep come later.

Please feel free to ask questions or make comments here. I will answer as best I can.

Attached is the graph from the last 24 hours:

fuscustest5.png
 
Cool! I've just got a Raspberry Pi 3 (I have a Pi B as well) and started building up my basement brewery - moving from propane in the garage to indoors, and an STC-1000 controller on the fermentation fridge. I was looking around for a pure Python/Pi setup, as I'm most familiar with Python. At work we're just starting to use Python on Pi's in our upgrade of our main telescope project, and I use it all over the lab for talking to instruments.

I'll be watching this very carefully - not quite ready to jump in and help yet as I'm still sorting hardware for manual operation. It'll probably be a month or so before I can start putting the fermentation controller together.

Now; is there a pure Python brewery control panel out there as well?
 
Cool! I've just got a Raspberry Pi 3 (I have a Pi B as well) and started building up my basement brewery - moving from propane in the garage to indoors, and an STC-1000 controller on the fermentation fridge. I was looking around for a pure Python/Pi setup, as I'm most familiar with Python. At work we're just starting to use Python on Pi's in our upgrade of our main telescope project, and I use it all over the lab for talking to instruments.

I'll be watching this very carefully - not quite ready to jump in and help yet as I'm still sorting hardware for manual operation. It'll probably be a month or so before I can start putting the fermentation controller together.

Now; is there a pure Python brewery control panel out there as well?

Strangebrew Elsinore
 
Excited to see this announcement! There's a bit of work left to make it ready, but overall im very impressed with Ame's work here.

Ame is very humble in his warranty's for the software but overall ive found it to be quite reliable, and the issues I've found are moving along quickly.

While Arduinos are cheap, they are not necessary for BrewPi to function. On top of that they create a larger burden for those wanting to create multiple chamber setups.

In theory when everything is complete i believe a single RPI Zero($5 to $30 depending on if you need a whole kit) could run up to 4 different BrewPi chambers. Not only that but only needing a RPI zero for a single chamber setup will allow people to make smaller more elegant single box enclosures.

For those that care expect me to make a new large HOWTO thread to build this RPI only BrewPi up in the coming weeks as Ame "officially" releases the code, and when i feel 100% confident in its capabilities as i do the current BrewPi code. It is very similar, but there are a few key wiring and setup differences.
 
Well, after 3 days it's still running. The latest graph is attached below. There are a ton of FIXMEs in the code that I ought to look at, but it's working for me.

Thanks to FuzzeWuzze for catching a bug. I've fixed it but of course the fix is not present in the code I am running. It only causes trouble under a certain condition, so I am hoping I don't get that condition otherwise it will crash and burn and ruin my beer.

I am using Beer Constant mode at 18 °C and the airlock is bubbling nicely. Not vigorous, but it's going. I have never used temperature control before, just ambient, so I'm not quite sure what to expect. I'll just leave it going for 10 days or so, or until the software crashes.

fuscustest6.png
 
Looking pretty cool. I'll be to trial also. Just picked up a pi3 to play with. Been running the brewpi fuzze model for well over a year now.
 
Thanks for your comment. It's not ready for prime-time yet. It's really just a curiosity at the moment.

It ought to run on a Pi 3, but I don't have one to test it with yet. I am currently running it on a Pi 2 but it does run on a Pi Zero too.
 
Looking forward to the detailed HowTo. I've got a Pi3 and a TRUE GDM7 just sitting here waiting to be utilized.
 
To be honest, you may be waiting for a while. If you want something that works well, then buy a BrewPi Spark from Elco. If you want to get your hands dirty then build an Arduino version based on the instructions on this forum. My software is not at all ready to plug and play.
 
We're gettin there but yea its probably weeks and weeks away at this point. The Arduino just adds a small extra cost that you can later refactor out of your solution if you do want to move to the RPI only mode.
 
After 6 days it's still running, and has held the temperature nicely at 18 °C. I took a hydrometer reading today and it's 1.020, which is still quite high. I nudged the target temperature to 20 °C (using the rotary encoder and local LCD), so we'll see if that makes a difference.

Attached is the latest graph.

fuscustest7.png
 
Still going. Unfortunately, increasing the temperature a little and shaking the vessel did not restart fermentation, so I pitched some more yeast today.

You can see in the graph that the rise from 18 to 20 degrees was very smooth.

fuscustest8.png
 
So this is only mildly related: Are you running a fridge with a heat wrap? It's always amazed me how such a setup can control the temps. Probe in thermowell in wort?

Are you going to fix the display to actually read F if the user chooses F? :)

I'm subbed and watching, very interested in your progress.
 
Hi there,

Thanks for your interest.

I am not running a fridge with a heat-wrap. I have built a Son of Fermentation Chiller chamber because I am cheap. The controller outputs are connected to the chamber as follows: cooling- connected to the fan which moves air past the frozen water bottles (standard SoFC operation); heating- connected to a 30 W heating tape attached to the wall of the chamber (an addition to the standard SoFC design).

My beer temperature probe is a cheap Chinese DS18B20 waterproof sensor in the wort. The sensor is housed in a short stainless steel sealed tube, and I have covered the joint to the cable, and the cable itself, with silicone tubing, which I feel safer immersing continuously in the wort.

Regarding the Fahrenheit display, top men are working it. Top. Men. I decided not to implement it initially as a) I don't need it, and b) it is a well-defined chunk of code that can be added later.

Actually, I am really happy with its behaviour so far. It has maintained the temperature accurately, but I know that if a bug should occur it will crash and burn, not fail gracefully.

Cheers!
 
Last edited:
Thank you ame. I should have seen you already told us you use the Son of Fermentation chiller - apologies. I even went back and read again but I apparently skimmed too lightly.
 
Here we are after two weeks. The software hasn't crashed, and it's kept the beer at the specified temperature quite nicely. It has been mostly heating, which is a worry as fermentation is supposed to be exothermic, which might mean that it has stopped. Last time I posted that I nudged the temperature up to 20 °C, and then added more yeast. Now the SG is 1.013. This is an improvement from last time, but there is no airlock activity and no heat given off (which I would see in the graph when my software tried to cool it). I do have a bit of a leak on my chamber door, and the room is colder than the target, so it is possible I am getting just enough background cooling after all. Anyway, I think I'll just have to wait. My target is 1.008.

I recently acquired a Pi 3, and I am using it right now as a PC to submit this post. It's pretty cool! I am logged in to HBT in this browser tab, and I am viewing the BrewPi web server in another one (running on another Pi on my home network). I took the attached screenshot so you can see how it's doing.

In general I am happy with my software. I have demonstrated that it is possible to rewrite the core functionality of BrewPi in Python. I have demonstrated that the temperature sensors and relay (and LCD and rotary controller) can be connected directly to the Pi GPIO. I have demonstrated that the Pi will run unattended for at least two weeks, and wifi stays connected during that time. I will leave things going at 20 °C for another week and check SG again then.

Thanks for reading.

2016-03-27-161219_1440x900_scrot.png
 
Glad it's all working so well!

Any thoughts yet on releasing this code for wider testing? I'm getting a relay board, one-wire sensors and an Arduino uno (for the original brew-pi setup with my Pi B or Pi 3) in the mail tomorrow, and I'll have a free fermentation chamber for testing with water when I keg the current batch today.
 
Glad it's all working so well!

Any thoughts yet on releasing this code for wider testing? I'm getting a relay board, one-wire sensors and an Arduino uno (for the original brew-pi setup with my Pi B or Pi 3) in the mail tomorrow, and I'll have a free fermentation chamber for testing with water when I keg the current batch today.

While hes had good success, i have had a few problems that i wouldnt want anyone of you to run into (like getting stuck on cold or stuck on hot). Im hoping its just a probe issue but while hes had no issues with his probes i cant seem to get mine to function properly all the time, but never have this issue with the same probes in the Arduino BrewPi...so theres some work to be done still.

I just got a RPI zero earlier this week so i can start testing again without messing with my current RPI BrewPi.
 
Hi dyqik,

Thanks for your comments. FuzzeWuzze is right. He has exposed some issues which I have never seen, so the code needs to either fail gracefully under those conditions, or detect them and keep going. In my case, everything seems to be running as expected, so it chugs along and does its thing. I have to say however, it is the most-watched project I have done in a while. I check it often just to make sure, so I could turn it off immediately if I thought it was going to ruin my beer.

In some respects, having a low-wattage heater (only 30 W) and a simple cooler (frozen water bottles) means that it takes some time to cause damage. Running the heater for 8 hours would cause the temperature to increase by 6 °C or so. Running the cooler for 8 hours would eventually melt the ice, so it would just stop cooling. If you were using a higher-wattage heater, or a real fridge, then it could do more work in that time and really mess things up.

Unfortunately I haven't had much time to work on the code recently. I'll see how things are when this batch of beer is done.

Cheers!
 
I fixed an obvious bug and uploaded it to github a couple of weeks ago, but I didn't put the fixed code on my controller. I decided I didn't want to interrupt it, and the path through the buggy code would occur rarely. So, after two weeks and three days this rare event happened.

My controller stopped for about 2 hours until I noticed. I fixed the bug locally and restarted it. Maybe it'll go for a while now, although I am hoping I will get to FG soon.

The graph is getting a bit squashed now, because it has over two weeks of data in it. Still looks quite nice.

fuscustest9.png
 
After just over three weeks I am declaring this beer (Muntons Export Stout) done. It did not reach its target FG of 1.008, and instead is stuck at 1.013. I turned up the temperature by another 2 degrees a couple of days ago, but the SG did not change. So, it'll sit at room temperature until the weekend, when I will bottle it. It'll be 4.3% abv, which is not too bad.

So, below is the final graph of temperature. Apart from the one bug that bit me (which I knew about, but didn't do anything about) my implementation of Elco's software has done a great job. This surprises me as I know there are still more bugs, and chunks of code missing, but I thought it ought to "mostly work".

I'll do a Belgian kit next, now that I know it works.

After bottling, I'll also inspect the beer temperature sensor, which I made incredibly cheaply by covering a 'waterproof' temperature sensor from China with a length of silicone tube. The stainless steel part of the sensor is directly in the wort. About 40cm of silicone tubing is covering the joint with the sensor cable (I removed the heatshrink on this joint), and the cable itself. The tubing also forms a seal in the hole I made in the lid of the fermentation vessel.

2016-04-04-224646_1440x900_scrot.png
 
I know many people are keen to hear about how this project is going. :)

The Pi ran for one month with no problem, however after that time the PSU failed. Fuscus (my software) was still running, but when I logged in to the Pi I couldn't do anything and it seemed that the SD card was corrupted. I opened the enclosure and noticed the familiar smell of burnt electronics, and a faint buzzing sound coming from the PSU. So I think my $3 USB PSU is no good.

I have kept the SD card in case I can get my fermentation log off it, but probably I can't.

I bought a new SD card, only 4Gb is required, and installed Jessie Lite and Fuscus from github. Everything is fine, and I am now using a $4 USB PSU, which will surely be 33% better.

Regarding the silicone tube 'thermowell', it seems to have done the job. The silicone is discoloured from immersion in the dark wort, but the stainless steel tip is undamaged and there is no metallic taste in the beer. I had already immersed it in water for a couple of weeks to see if the stainless steel really was corrosion-resistant, so I am happy it is still okay immersed in the wort.

Probably I will start the Belgian beer this weekend. I will post on the general stability of the code for that run too.

I haven't done much to the code other than tightened up some error handling for the temperature sensors, and modified things so that it is possible to specify no LCD and no rotary encoder. This frees up those GPIO lines so that a) other programs on the Pi can use them and b) several copies of fuscus can run at the same time and not clash because they are all expecting an LCD on the same lines.
 
Ok, a new brew is ready to go. This time it's Brewferm Abdij. I made it up to 9 litres and added 450g of sugar, according to the instructions. I am using Mangrove Jack's M47 yeast instead of the supplied yeast.

Currently I am waiting for the wort to cool down so I can pitch the yeast. The specified range of temperature is 18 to 25 °C, so I think I'll let it sit at 21 °C for the entire time. I'll post the occasional graph and comment on whether the software works properly.

Thanks for reading.
 
Pretty much nothing to report. I set the beer termperature to 21 °C and left things alone. It's been going for two days and I have some regular activity in the airlock, which started yesterday. I have to open the chiller every day to change the ice bottles, but it's not too hot here yet, so they aren't melting completely and they re-freeze again quickly overnight.

Again, I am using my silicone-tubing-sleeved temperature sensor in the wort. This time with just 9 litres in the vessel only the stainless steel and a short bit of silicone tube are immersed.

Here's a graph of the starting activity. On the left you can see where I cooled the wort, then I pitched the yeast when it hit 21 °C.

snapshot1.png
 
Well, temperature has been maintained for about 10 days. I am going away for a couple of days, so I can't change the ice regularly. I have set the controller to 'OFF' so it will log temperature but not attempt to cool or heat.

I am very happy with the software. I have done very little to it since the first alpha version, and it does what I want.

Attached is a graph from the last 10 days. Temperature was set to a constant 21 degrees.

This particular beer needs another few weeks in 'secondary' but I am not going to rack it. I'll leave it in the vessel. I might turn temperature control on again if the weather gets hot, but the ambient temperature is about right just now and I am expecting the thermal mass of the wort combined with the insulation around the chamber will be enough to even out the external temperature swings.

Thanks for reading.

2016-05-05-102837_1440x900_scrot.png
 
Recipes --- this is the direction i want to see BrewPI go.. i think they are getting off track and what us brewers that already have a manual brewsystem want is a cool - DYI - ferment controller. i have been using brewpi with an Rpi1 and arduino for over a year. while it works there are some major things i think could be added. i agree fully with where you are going and think that it could/should be contained within just the Rpi itself. I think that in order to send this to the next level there needs to be three things... NewPiOnly version needs to be working 100%, a purchasable either as a ribbon/usb/Ethernet connected board for temp control (say like up to 8 inputs) and another ribbon/usb/ethernet board/box with 8 relays ...
*** why 8 relays?? -- well... Heat/cool/fan ... light, outside air fan, time delayed fan for fridge compressor, and two spares for serving fridge and something else.

**four major things that kill me with the current setup
-- if the outside air could be use to heat/cool chamber let me use a fan to push air in instead of a heating/cooling device
-- there needs to be the ability to add more temp sensors, if i have four carboys in my fermentor then pull all the temps and avg them
-- we need a website where users can submit profiles for types of beer so you can get a good idea of what to set your ferment plan to
-- the system should learn your chamber by running a post install test like any other good PIDs can do

i an not a big python guys as i don't program in it but i think with power of Rpi3 and some things out there we could start on a new version dedicated to only fermenting and serving ... bring in Rpints to the mix so you have one device that does both!!!

Thanks for the rant, i have been thinking about this a lot the past few weeks as my brewing is gearing up for summer... PB
 
Um....wow?

- Averaging doesn't sound optimal.
- You can already use a fan to pull air into your chamber to heat or cool.
Just replace either your heater or your chiller with the fan. Et voila!
- Why does a recipe matter? What matters is the yeast, and how you want to run it.
And how you want the result may be different from someone else.
I think that gets a bit too esoteric to actually code - and for sure I'd never use some random user's Profile at this point.
- I run BrewPi and RaspberryPints on the same RPi2 systems. They serve unrelated functions.
I don't think I'd want to see the code commingled, it's a recipe for nothing ever working again...

Cheers!
 
so.... a bit more thoughts...
--averaging the carboys because there is really on one cooler/heater
-- you can use a fan to pull in air in but if have the heater and cooler plugged in it would be nice to use outside air before or to help
-- not the brew recipe but as a profile template... for 14day ferment of an IPA with 1.065OG i used this profile
-- I run rpints on the same Rpi but if i could have the same config area for both it would be nice. like if wanted to call my brewery a name or have a common background image or had sensors for pours... etc and as you input the beer in the ferment side it would carry over to rpints .. OG/FG, days fermented and you could put your temp data from the brewpi into the rpints page..(i have this running on mine)

Cheers!!
 
so.... a bit more thoughts...
--averaging the carboys because there is really on one cooler/heater
-- you can use a fan to pull in air in but if have the heater and cooler plugged in it would be nice to use outside air before or to help
-- not the brew recipe but as a profile template... for 14day ferment of an IPA with 1.065OG i used this profile
-- I run rpints on the same Rpi but if i could have the same config area for both it would be nice. like if wanted to call my brewery a name or have a common background image or had sensors for pours... etc and as you input the beer in the ferment side it would carry over to rpints .. OG/FG, days fermented and you could put your temp data from the brewpi into the rpints page..(i have this running on mine)

Cheers!!
Have you looked at the STC1000+ thread?
 
A quick update. Luckily the ambient temperature this weekend was around 21 or 22 degrees, so there was little effect on the beer temperature. It crept up by about a quarter of a degree. Later in the summer I would not be so lucky. You can see on the graph where I turned the controller mode to "Off".

When I came back I loaded up another couple of frozen water bottles and switched the mode back to "Beer Constant". According to the instructions for this beer I have to keep it around 20 to 23 degrees for another week. I have kept it at 21 degrees for the whole process. Next week I'll check the specific gravity then get on with bottling.

The next beer is going to be Muntons Smugglers. If I have time I'll build up a Raspberry Pi Zero version of the controller. The software works (it's just Python, after all) but I really ought to test it with actual beer.

2016-05-09-192540_1440x900_scrot.png
 
Is it fair to assume that this could run off anything that can run Jessie? I've got Chip $9 computer which has GPIO so in theory it should work on that right?
 
Hi there,

I don't know anything about the CHIP, but if it runs Jessie then it should run Python 3, so my code will run.

Can you hook up the temperature sensors to the CHIP? I am using the w1-gpio driver for those. I am also using the RPi.GPIO driver for the relay pins. You might need to modify the code a little.

Is the CHIP powerful enough to run the webserver too? You need to run BrewPi, and the webserver and my software on the same device, otherwise there's no point.

You are welcome to try.
 
I'll PM you.

It's no secret, but I'd rather chat to people before they download it, just to be sure their expectations are not too high. It's also not really plug-and-play, so you'll need to do some fiddling to get it going.
 

Latest posts

Back
Top