Wednesday, October 29, 2014

Improved Home Brewing Controller

This post is an update to my Automated Home Brewing post. See that post for more details on the project. After adding some new features haphazardly, I had an ugly conglomeration of old and new parts. It worked, but it wasn't pretty, and I sure didn't want to show it on this blog. So, I decided to build a whole new interface and include the new items:
  • thermocouple interface for flame detection
  • relay control for refrigerator
  • relay control for heater (these two are used for controlling lagering temperature during fermentation)
  • digital input for counting the bubble rate in the airlock during fermentation.
  • battery level monitor, since I usually run this on a small 12V battery
I also kept all the original controls:
  • relay for propane valve
  • relay for igniter
  • 1-wire bus for multiple temperature inputs
  • relay for circulation pump
The item that I struggled with the most was how to make a reliable flame sensor. This is covered in the Flame Sensor Update post. Note - the drawing for the amplifier circuit in that post has the resistor values reversed. Here is the corrected drawing.

The gain formula for a LM358 non-inverting circuit is

               gain = 1 + R2/R1

In this case, R1 = 1K and R2 = 200K, resulting in a gain of 201. This means that a thermocouple output of 5mv will produce an output of just over 1V. Using a gain of 500 would allow for better resolution of the temperature, but 200 is adequate for this purpose. I don't care about the actual temperature. I just need to see if the value is increasing to verify that the flame actually lighted.

I decided to build the interface on a circuit board that would plug directly into the GPIO pins on the Raspberry Pi and mount it with a Pi permanently in a project box. Here is the completed circuit board, in its enclosure, installed on the Raspberry Pi

Here is the project box with the Pi mounted inside. There are holes cut for the USB, network, and HDMI connections. I like this arrangement a lot and will use it again in the future.

Finally, this is the completed system with all the connectors labelled.

The "bubble detector" input was a last minute addition. I haven't actually built the detector yet but the design is straight forward. It will use an infrared LED and detector (sometimes called an IR gate) to see when a section of the airlock changes from water to air. Water is mostly opaque to IR light.

The pulses from the bubble detector will be very short and difficult to accurately count using a simple polling loop. I expect that it will need to be done using GPIO interrupts. I will post the code when I get that working.

Monitoring the "bubble rate" won't really produce any useful numeric data. It is only good for determining when the fermentation has completed. This is important since fermentation can stop early for various reasons and steps must be taken to correct the problem.

Finally, a warning: Working with flammable gas and boiling liquids can be hazardous. I take no responsibility for your use of the advice provided in this post.
BE CAREFUL!  And drink responsibly.


  1. Hi! Did you complete the bubble counter circuit/coding? Would be awesome if you shared :)

    1. I have not yet worked on the bubble counter, but when I do get it working I will certainly share.