Thursday, March 20, 2014

Automated Home Brewing

Brewing Controller User Interface
I have been a “home brewer” in the electronic hobbyist sense for decades, but I am also a “home brewer” of beer.  I mentioned this in my post on Reading Temperature With Thermistors.

I now use digital temperature sensors (typically the DS18B20) read over an I2C bus.  Adafruit has a good tutorial on how this is done located at http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/overview

It is fairly common to control a refrigerator and heater to keep a constant (or slowly changing) temperature during the fermenting process, especially with lagers.  I have done this using the Raspberry Pi, thermistors, and an A/D convertor.  Now, I decided to get a lot more ambitious.

I won’t go into all the details of the brewing process since there are many resources on the web to provide that.  For a quick look at this process, see the article on my photo blog.  I wanted to be able to control at least the following items for one of the simpler methods of brewing (called partial mash.) 


  • Valve to a tank of propane
  • Grill ignitor to light the burner
  • Sensor to detect if the burner actually did light
  • Temperature sensor for the wort (the brew of water, malt extract, and hops)
  • Pump for circulating water through the wort chiller

What I needed to do this:

  • A relay to output 12V to control the propane valve
  • Another relay to output much higher amperage of 12V to run the pump
  • A relay connected in place of the button on the grill ignitor
  • A connection for one or more DS18B20 temperature sensors

The hardware is described below.  I also wrote software for the Raspberry Pi (in C, my language of choice) to manage this hardware and the brewing logic.  C# .Net provides the user interface on a Windows laptop. That is the image at the top of this post. The laptop and the Pi communicate via socket calls over wifi.

There were three major problems that had to be overcome once I started testing.  One is that I tried using a DS18B20 to detect the flame.  Well, the maximum for that sensor is 125°C and I did not use a high temperature version.  The flame is VERY hot (duh!) and the sensor eventually melted, shorting 5V to ground and shutting down the Pi.  Fortunately it was not damaged.  I doubt changing to a high temperature version will help, but I will try that next.  Another option is to do what every furnace, stove, and hot water heater does for its pilot light – use a thermocouple to detect the heat.  I may have to investigate this to see if I can devise a simple interface for one.

The second problem was that the wiring for the ignitor kept shorting out and creating a spark too far from the flame to light it.  Additional insulation and a change in how it was mounted solved this problem.

The third problem was that the EMI created by the ignitor caused massive interference on the I2C bus that made it unusable.  This was corrected by re-wiring my temperature probes with well shielded cables.  I used shielded audio cables commonly used for microphones.  I am also a musician so I had some of this already.  If you have to buy a small reel you may find that it is rather expensive.  Cat-5 cable may also work well.  That is what I use for my hot tub controller, but it is not subjected to the massive EMI of this system.

I disabled the flame detection logic. This is a critical safety feature and must be corrected for this system to be trusted.  However, this did allow me to successfully use this system to brew.

This is a good place to state that 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.

Hardware

Control of all of the above components is pretty straight-forward.  Search my blog or the web and you will find how to control relays.  The Adafruit link above will show you how to connect the I2C temperature sensors.

I used audio connectors since they are cheap and readily available.  ¼ inch mono for the relays and stereo for the I2C bus.  Using an audio connector for the I2C bus gives the added benefit of being able to use pre-made splitters and extension cables and these tend to be well shielded and relatively inexpensive.


The 5V line from the GPIO connection is only used for the I2C bus.  I already required 12V (which is actually 13.8V) for the valve and pump.  However, the relays I used were controlled with 5V.  This voltage does not need to be accurate, so I made a simple voltage divider using three 100 resistors.  Two 100 resistors are used for R1 and one 100 resistor is used for R2.  This divides the input voltage by 3 to provide 4.6V, which is adequate to control the relays.





The final interface box looks like this. The red and black power connector you see is called an Anderson Power Pole.  I chose to use this since I already have 12V supplies for my HAM radio equipment.  (I think maybe I have too many hobbies.)





Modified Grill Ignitor

The ignitor can be found in many hardware stores as a replacement for repairing gas grills.  The cheaper versions of these use a spring and a piezoelectric voltage generator to create the spark.  These are not suitable for this application.  You must get the more expensive type that uses a battery.  I removed the push button and made my own connection that runs to the relay in the interface box.

I still have a few kinks to work out in this system, but I am sure that this automation will make the process of brewing much easier and more consistent.  This is definitely the most enjoyable project that I have done so far with the Raspberry Pi, and that is not just because I end up with great beer.

The system set up for brewing

The temperature sensor is a water-proof high temperature DS18B20 covered in food grade shrink tubing.  These are available at Adafruit.com







Here, the system is set up for chilling the wort.  
The cooler has water and 10 pounds of ice cubes.

29 comments:

  1. i've embarked on almost an identical journey with DS18B20 + spark ignition. all of my stuff is attached to an arduino+lcd until i get the electrical bugs & cabling worked out. i'll eventually upgrade to an arduino + RasPi combo where the Arduino does all of the data acquisition/control and the RasPi takes care of the user interface and data logging.

    on my first iteration i used the exact same AA-powered spark ignitor. I used thermocouple + instrumentation amplifier for flame detection. I had the same EMI/EMC problems even with shielded cables and i hated the fact that i had to run an extra negative voltage supply rail for the instrumentation amp.

    on the second iteration, i looked to the appliance industry for help. I found a tytronics re-ignition spark module with flame rectification (use those buzz words to find one) in a discarded gas stove. This unit will provide you a spark until it senses the presence of flame. It senses flame by passing some voltage through the flame (that's the flame rectification part).The beautiful part is that these units work on 120VAC, so they'll never touch the DC power your digital devices use. Hook them up to the same relay that your gas valve uses (well assuming your valve is 120VAC) and you're good to go. One unit will do multiple burners. I'm using a 4 burner unit on a two burner system.

    Note that this unit just provides spark when flame is not present. it cannot shut off your gas valve. It isn't as intrinsically safe as other systems, but if reliably wired it will do the job.

    http://www.amazon.com/Genuine-Viking-Pa020047-Invensys-Re-ignition/dp/B005SM9TI4

    After installing this, i still had to do proper shielding/grounding, but the problems were much less pronounced. After i upgraded to shielded microphone connectors, all was easy sailing.

    ReplyDelete
    Replies
    1. Thanks for the ideas. I still plan on using a thermocouple (already ordered it) and that should be trivial to amplify with a LM386 amplifier to a voltage level that I can use. I will have to add an A/D converter, which I have built before. I am thinking there will be a separate box for the thermocouple that connects to the Pi via SPI bus. I have some other ideas on how to reduce the EMI problems and will report on my results in a later post.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. http://www.robotshop.com/en/dfrobot-flame-sensor.html

    ReplyDelete
    Replies
    1. Thanks for the suggestion. This is a very interesting sensor, especially because of the low price. Unfortunately this won't work any better than the sensor that I already tried using. The specification gives it's operating range as -40C to +85C. I need a sensor that can survive in very close proximity to a propane flame. (500C to 1000C) and the only thing I have found for that purpose is a JK thermocouple.
      I believe the flame sensor could survive if mounted some distance from the flame, but it would probably give false positive readings due to the heated steel of the burner frame and the pot of boiling liquid.

      Delete
    2. Look up flame sensor rods. I think they work by passing a current from the burner to the sensor rod via the flame.

      Delete
    3. Those use a thermocouple to sense the flame. I did look in to using a replacement sensor rod for a furnace, but the price was higher that simply getting a generic type JK thermocouple, and the one I found allows me more flexibility in mounting it.

      Delete
    4. http://www.faqs.org/patents/imgfull/20120288806_02

      Delete
    5. I'm seeing flame detector rods for less than $20.

      Delete
    6. Does that include the detection circuit?
      In any case, I think you've gotten your point across.
      I will check them out and if they work any better or easier than a thermocouple I will include them in the follow up post that I will do in a few months. There are other minor issues in the hardware to work out and a lot more to improve in the software,

      Delete
    7. It seems like http://www.robotshop.com/en/dfrobot-flame-sensor.html posted above would work as long is you didn't mount it directly in the flame. The sensor is designed to direct a robot towards flame, so presumably it could be some distance from the actual flame. You could probably find a suitable nearby location (like the burner leg) to mount it on.

      Delete
  4. Ted,
    Congrats... I see you finally made the "Cover of the Rolling Stone", at least as far as the Raspberry Pi world is concerned.

    ReplyDelete
    Replies
    1. Yeh. Front and center on raspberrypi.org
      Guess I'm done here now. :)

      Delete
    2. My stats went from a typical 500 to 600 views per day to over 2600 yesterday. Fortunately the comments have been pretty easy to keep up with. And very informational. I have at least three good ideas on how to detect a flame. I may have to try them all just to be able to report on them.

      Delete
  5. Couldn't you coil a copper wire around the sensor and run the end of it over to the flame and measure the lesser increase in temp but a guaranteed increase if the flame is heating the end of the wire in a flame?

    ReplyDelete
    Replies
    1. The response time would be too slow. I need to know if the flame is on within a second or so and then cut the gas off if not.

      Delete
  6. Why not use an LDR to see if the flame is working?

    ReplyDelete
    Replies
    1. I assume you mean a Light Dependent Resistor. That may work, but the flame would need to be noticeably brighter than the ambient light and I would rather not work in the dark.

      Delete
  7. What did you use for the electronic valve control on the propane?

    ReplyDelete
    Replies
    1. Yes. This is used to turn the propane flow on/off

      Delete
  8. A safer way to control the propane gas is using a controller and the rpi to a relay to put the gas on, via the controller, its only 18 usd and more professional
    http://www.aliexpress.com/item/110V-transformer-high-voltage-output-transformer-gas-ignition-controller-pulse-igniting-device-for-burner-oven-grill/1557286713.html

    ReplyDelete
    Replies
    1. You may want to check that again. It is $180. That is an order of magnitude more than I paid for the entire system.
      Anyway, I see no advantage to this over what I am doing already. All of the logic built into this device is already handled in software on the Pi on my setup.

      Delete
  9. Okay let me explain it another way : you can't use a RPI or even a PLC to implement safety features as flame detection and personal protection, just read basic machine safety guidelines they are not invented for nothing....
    I use a RPi and PLC for controlling coffee roasting machines, yes also use LPG gas, All safety features are implemented in hardware (not RPI ) independent from software or the plc, you can use a fail safe contact of a plc or rpi in the emergency stop loop for additional safety.

    You can also use a big size rice cooker >= 25Liter and a temperature controller with thermocouple + a relay to switch the rice cooker on and off.
    example a toky ai808 controller has pid, and 50 programmable times and temperatures ,plus communication to the rpi for data logging and or setpoint adjustments

    Safety First

    ReplyDelete
    Replies
    1. I don't disagree - there is certainly a safety issue here. This type system should use a proper flammable gas valve - the type that has a built in thermocouple interface to detect flame and shut the valve off if not detected.
      Since I am aware of this issue, I do not use the system unattended. If I am present during operation then I can intervene when things don't work, and in fact I have had to do this a couple of times. Operated in this manner it is only nominally more dangerous that total manual operation.
      The only real advantage this automation gives me is preventing over heating (or cooling) of the wort and more consistent temperature holding. I don't have to constantly watch a hard to read thermometer.

      Delete
  10. as your setpoint is only 70'c its easier to control with an electric heating element but not directly in the worth but use a kind of water bath (or get another pan as in the picture ,and put the worth pan inside it, put 5cm water in the plus the heating element 700w...1000w
    by this way the heat from the hot water is spread evenly.
    I suppose your goal is making a nice beer yourself for hobby , so why not invest a little more for a good industrial grade temperature controller (25...30 usd)(ebay) it saves much headache , it will not burn down your house....and so on, and it will look good too
    Use the RPI for logging and web interface, if you want i have written a modbus program for the RPI in python and use a usb to rs485 converter to connect the RPi to the controller, so you can change setpoints via the rpi and log the curve whatever you want
    The final result is pure happiness, your self brewed beer, small scale ,but in a quite professional way. It taste better when it all looks good.
    Another advance is you can use the same controller setup to distillate....to give you some ideas :)

    ReplyDelete
    Replies
    1. There are actually several set points including the need for a full boil and an ice water chill to return it to room temperature quickly. Your suggested method would take several times longer than my current system. There is a good reason that I use propane instead of electric - I can get 15000 BTUs (about 4400 Watts) of heat. This is far more than I can get from typical electric burners.

      And the judges scoring my beer don't care what my setup looks like. All they see are unmarked bottles with an entry number on it.

      Delete
  11. Just drop me a note when you're ready for an upgrade, in the meanwhile please be careful , for yourself and others around you.
    My experience with the RPi is that it often freezes after/during the ignition of the flame even when using optocouplers ,filters and shielding.



    ReplyDelete
  12. Hi congrats for the idea and all that you accomplished. Did you think in making the system all eletric?
    I´m starting now doing something very similar, but all electric. Using a AC-DC SSR to load the heather. In theory would work flawless. I´m very concerned about the amount of energy drawn from RPI during SSR ignition if you know what I mean.
    Anyway, i just bookmarked your blog for future references. Thanks and keep up RPI brewing!!!

    ReplyDelete
    Replies
    1. An SSR typically draws very little current. That is one of the benefits of using an SSR. However, I would still recommend powering the relay from an external power source and controlling that with a relay. See one of my earliest post for instructions on how to do that.

      I never considered using an electric heater because I already have a propane heater and need to keep the cost down. Another consideration with an electric heater is how much heat it provides. The ones I have seen are 1000 to 2000 watts. Propane burners can easily get up in to the hundreds of thousands of watts. You can expect to spend a very long time (close to an hour) getting a couple of gallons to boil with only 1000 watts.

      Delete