Brewing with the Raspberry Pi

A few years ago, I set up a temperature controller on my fermentation refrigerator with an Apple II, a little add-on board I designed that plugged into the joystick port, and some software I wrote:

the previous controller hardware, installed in an Apple IIGSIt worked with a DS18B20 1-Wire temperature sensor added inside the refrigerator and a relay to switch the fridge on and off.  It got the job done and helped make lots of good beer, but it managed to “kill off” one or two computers along the way.  (Probably just dead power supplies, but still…)  I thought it’d be a good idea to come up with something newer, and possibly more compact and that would use less power.

The Raspberry Pi sounded like the ideal candidate.  Linux has pretty good 1-Wire support, I’d now have the ability to see what the fridge is doing from anywhere (and control it, too) thanks to its network connectivity, and you can power one from an iPhone charger (read: it doesn’t use much power).

I wanted a touchscreen interface, so I picked up a PiTFT:1601-00I needed a 1-Wire interface to talk to the temperature sensor.  Also, I decided to replace the relay I had installed in the fridge (which needed 12VDC to switch on, which wouldn’t be available) with a solid-state relay (which only needs 5VDC). I figured the best way to implement this would be a board that could be sandwiched between the Raspberry Pi and the display, with the stack connected through the GPIO connector.

While I was at it, I included a real-time clock with battery backup (something I didn’t have with the Apple II) and brought out I2C as well as 1-Wire.  Both are level-shifted to 5V.  A DS2406 1-Wire addressable switch on the board controls the solid-state relay.

I ended up with this:

rpi_i2c_1w

I had boards made, ordered the parts, assembled it, and ended up with this:

DSCN1639

DSCN1634DSCN1635DSCN1628

Software proved to be a bit more involved, as while Linux supports plenty of 1-Wire devices, the DS2406 wasn’t among them. The beauty of open source, though, is that you can fix it yourself if it doesn’t do what you need it to do. With one of the other 1-Wire drivers as a starting point, I wrote a driver, debugged it, and it’s available in Linux 3.17-rc1 (and later). For earlier versions, you can apply this patch to whatever kernel you’re currently using.

The “action shot” at the lower right shows some of the features of the control software. (It’s web-based, running in Chromium under Ratpoison on the PiTFT, and accessible across the network.) In addition to setting the temperature to maintain, the software implements a “go to” temperature. Let’s say you’re making a pilsner. Fermentation might start out somewhere in the 50s, but you might want to bring it up to the 70s for a diacetyl rest for a few days before dropping the temperature into the upper 30s for lagering. If you try changing temperature too quickly, you’ll shock the yeast and it won’t do its job. By telling the controller you want to go to a higher or lower temperature, it’ll make the change for you gradually.

This is an open hardware project, with open-source software running the show. I used Upverter for schematic capture and PCB layout, which works anywhere you can get a browser running:

https://upverter.com/salfter/b0ef63c2cd7a37c7/rpi_i2c_1w/

The Gerbers for the latest revision of the board (which fixes some minor issues with the board shown above) are on file at OSH Park:

https://oshpark.com/shared_projects/e7OaI1G2

The BOM is on file at Digi-Key:

https://www.digikey.com/classic/RegisteredUser/BOMBillOfMaterials.aspx?path=1&exist=1&id=1729468

Boards are $36 for 3; parts for one board were about $15 when I built mine.

Software for using the board as a temperature controller is at GitLab:

https://gitlab.com/salfter/pifridge

Since the board is basically just a 1-Wire/I2C interface, it should have applicability beyond switching a refrigerator on and off. In the brewery, it could be reconfigured as a PID controller to control temperatures in the hot liquor tank, mash tun, or brew kettle. It could conceivably be set up to control pumps and valves in a larger setup. Beyond brewing, it could be used for whatever monitoring or control you might need. If the PiTFT isn’t large enough for your purposes, larger screens are available, with or without touch. Plug in a keyboard or mouse, if your application would benefit from them. The possibilities are endless.

Leave a Reply

Only people in my network can comment.