Homebrew bubble counter


Counting bubbles during secondary fermentation

For a while now, my friends and I have been brewing beer at my house.  I was inspired by an old Sparkfun tutorial about a bubble logger for Nate’s terrible wine.  I figured that while logging bubbles is interesting and all, wouldn’t it be more useful to have real-time information on the fermentation process?  I basically copied the optical gate method of counting bubbles, added a sensitive pressure sensor, and an AVR development board (Yes, Arwen, that’s your old TekBots board! 🙂 ).

Just like the Sparkfun tutorial, I used an IR photogate sensor on an S-shaped airlock.  One thing that I thought was really interesting is that the water in the airlock doesn’t block the IR path, it actually improves it.  I ended up needing a potentiometer to adjust the LED brightness on the photogate, this is because it has to be just the right brightness to detect bubble transitions.

Counter closeup

The programming on the microcontroller was really simple.  All it does is keep a clock, and when there is a rising edge of photogate signal (bubble passed) it prints the time and a bubble count to the serial port:

01:20:16:16,01646
01:20:16:18,01647
01:20:16:20,01648
01:20:16:22,01649
01:20:16:24,01650
01:20:16:26,01651
01:20:16:28,01652
01:20:16:30,01653
01:20:16:32,01654
01:20:16:34,01655

I chose to use whole seconds as the time step.  That was certainly an oversight.  When I designed the software, the brew was in second fermentation.  There was a bubble once every 20 seconds or so.  I thought “It couldn’t be that much more during primary fermentation, right?”  Wrong.  During the beginning of primary fermentation, there can be 3 or 4 bubbles a second.  I made up for this oversight in the Ruby script I wrote on the server:

# Get an interval from the last to this bubble in seconds
interval = seconds - last_record_seconds
last_record_seconds = seconds

if interval == 0
	bubbles_per_second += 1
else
# if, in the last second, we counted more than one bubble
# find the frequency by multiplying the bubbles per second
# to bubbles per hour
	if bubbles_per_second > 0
		frequency = bubbles_per_second * 3600
		bubbles_per_second = 0
	else
	# Convert the interval into fractions of an hour
		interval = interval / 3600.0
		# Convert the interval to bubbles per hour
		frequency = 1.0 / interval
	end
		printf("%f bubbles per hour\n", frequency)
		RRD.update(rrd_name, "N:#{frequency.to_s}")

I’ve left out the parts where I initialize the serial port and the RRD database and parse the messages.  I’ve attached the whole script, including the script that generates the graph, at the end of the post.

Chocolate porter brewing record (primary fermentation)

Here is the bubble record from one of our beers.  I was very surprised by the 14,000 bubbles/hour rate achieved a half-day after pitching the yeast.  I adjusted the graph many times to make everything visible.  I absolutely had to use a logarithmic scale on the value access, there is just no other way to be able to see a 14k+ value while still being able to see where 60 bubbles/hour is (this is about when the brewing is finished).  These graphs are always updated, and are available online.  Of course that is only meaningful when there’s a brew going at the moment!

Sensitive pressure sensor

I had grand plans of adding a pressure sensor to try and measure the volume of co2 escaping out of the airlock.  I figured that if I subtracted the pressure after the bubble from the pressure before I could use the ideal gas law and measure the moles of co2 that escaped.  This was all fine and good during secondary fermentation (when I first tried it).

Pressure delta during slow fermentation

During slow fermentation, when bubbles happen less than once per 15 seconds or so, it’s easy to see and measure the pressure difference before and after the bubble.  In the image above, there is about 40 mV of swing before and after.  The time represented in this image is a full minute, so you can see the slow buildup of pressure.

Pressure measurement during fast fermentation

During very fast fermentation, on the other hand, individual bubbles don’t contribute to much difference in pressure.  In the image above, you can see general trends of pressure.  Sometimes, i assume, due to surface tension there aren’t bubbles for a while.  When pressure builds up to a sufficient level bubbles begin.  The pressure drops again and the cycle repeats.  I’m not really sure how much I can do with this data.  The time represented in this graph is 12 seconds, and the bubbles per hour is about 18,000 bubbles per hour (5 * 3600).

Close up of a bubble during fast fermentation

This is just a close up of a single bubble.  There isn’t really any measurable difference in pressure before and after the bubble.  Ultimately, the pressure measurement stuff is on hold for the moment.  If someone reads this that’s really good with the ideal gas law has ideas let me know!

The next step for me is to figure out an elegant way to support many brews.  We’ve got a wine, apple cider, and a beer going at the moment, so I would like to have 3 channels.  Oh well, another project for another day.

Supporting files:

firmware

ruby script

Development board schematic

, , , , , , , ,

  1. #1 by Arwen on October 21, 2011 - 7:20 am

    Woohoo, tekbot lives on! And in such a cool way

  2. #2 by Brad on October 24, 2011 - 9:49 am

    But a bubbling airlock has no direct link to “level” of fermentation. Simply that co2 is escaping. It’s a neat little bubble counter and fun project none the less, but it’s doesn’t tell you anything about the progress of your beer.

  3. #3 by hpux735 on October 24, 2011 - 10:11 am

    I suspect that’s true. It is fun, though. 🙂

  4. #4 by Stefan on October 24, 2011 - 5:31 pm

    I have an idea on how you could better measure flow. Attach a balloon with a hole in it to the top of your airlock and put a pressure gauge on that side of the airlock. (Using only a balloon is a ghetto airlock substitute.) The amount of air escaping should then be a function of the pressure in the balloon. Perhaps you could find a good function with a known air source, like a CO2 tank.

  5. #5 by nevermore78 on October 24, 2011 - 9:00 pm

    Hi William!

    Nice device setup! I really love this kind of hacks! The more you measure, the better!

    However, I highly doubt the pressure difference would be of much help in estimating the amount of CO2 produced. If you think about it, the presure differences you are recording roughly corresponds to the difference in heights of both water columns to each side of the “bubble tube”. The higher the flow speed, the smaller the time the sistem has to stabilize, and you end up with a very small, fluctuating difference, with a magnitude comparable to the bubble tube diameter. That’s of little use.

    You can, nevertheless, make good use of the bubble counter to estimate the amount of gas escaping the fermenter. To make that, you should *calibrate* the device with different (know) flow rates. Then you can plot “bubble frequency” vs. “flow rate”, fit a nice curve to that and transform your bubble count data.

    If you are interested, drop me a line and I can give you some tips for measuring gas flow rates in a simple, inexpensive manner, so you can make a basic calibration. I’d be glad to help.

    Cheers!

  6. #6 by hpux735 on October 24, 2011 - 9:17 pm

    Thanks! I’ll probably hit you up at some point. I’m going to omit the pressure sensor from now on, I don’t think it’s useful either. The enhancement first on my list, however, is to add multiple channels. I’ve got a wine, apple/pear cider, and beer brewing at the moment, so I had to choose just one of them to measure. I chose the cider because I’m most concerned about that one. I have no idea when to expect that it’s finished.

  7. #7 by Dave Eno on October 24, 2011 - 10:36 pm

    I don’t really understand what the point of this is other than good fun. The counting of bubbles and pressure over the liquid wort is a complex situation. I guess you could maybe measure roughly how much of the sugar has been consumed thus far in the process … I’m not sure of what that would accomplish, but I guess it would be one more fact to know about the beer. If you could find a cheap DIY electronic way to measure and monitor specific gravity however that would be of much more interest. I looked into that problem for quite a while, and the answer to that was extremely none-trivial. If you could do IBU then that would be mint, but that would cost thousands.

  8. #8 by Dave Eno on October 24, 2011 - 10:41 pm

    You also should rebuild the airlock around the counter.

  9. #9 by Joe C on October 25, 2011 - 8:45 am

    @Brad
    It tells you how frequently its producing enough CO2 to pass through the airlock. The frequency could be a good indicator of when fermentation is coming to an end.

  10. #10 by Karl Gutwin on October 26, 2011 - 7:45 pm

    I’ll give you my idea, which should be able to be even more precise than the bubble counting method (which might be inaccurate at high flow rates). Start with a large “blowoff” type container such as a soda bottle. This container has three connections: one to the fermenter, one to a pressure sensor, and the last to a solenoid valve. Most of the time, the entire system is sealed closed. The pressure sensor measures the rise in pressure from fermentation, and assuming the gas volume in the entire system is known (or calibrated) and that most of the gas is CO2, the ideal gas law can be used to calculate the molar quantity at any given point in time.

    Now of course if we left the system sealed it would explode quickly! The solenoid valve therefore is triggered by the microcontroller to exhaust the system when the pressure exceeds a threshold. Assuming that the valve is open for a brief time relative to the time needed to build up to the pressure threshold, very little gas will escape unmeasured. Before exhaust, the molar quantity is calculated and added to a running total. This running total is a direct measurement of the CO2 evolved during fermentation.

    The system operates on the same principle as the bubble-type airlock, except that the pressure differential between the fermenter and the air is allowed to build up to a higher (yet controlled) level. This allows for fewer “exhaust events” which means greater accuracy. The “blowoff” container increases system volume which lowers “exhaust events” even more, and traps liquids — preventing your pricey pressure sensor from getting clogged with krausen.

    The one downside is that it is not fail-safe — if the power goes out or the pressure sensor gets clogged, the valve stays closed and something’s going to blow! A normally-open solenoid valve would be somewhat safer.

  11. #11 by Michael Burton on October 26, 2011 - 8:47 pm

    Keep up the good work hpux!

    Sure the old salts will say counting bubbles means nothing, but don’t listen to them. I use a similar design to log bubble rates and temperatures when I brew. It’s nice to know how long it took for your brew to start bubbling and also to observe variations that may stress the yeast like temperature drops at night. Yest happiness is a primary factor in the quality of your finished beer so the more you know the better!

    I like your idea of measuring the pressure too, you could also use that sensor to count bubbles, though it could get messy in a blowover 😉

    PS. This guy (Johan Liljencrants) did a great write up of D.I.Y anemometers which may also be a nice way to measure the rate of CO2 production until you get a blowover and wreck the sensor… http://www.fonema.se/anemom/anemom.html

  12. #12 by Tom Hargrave on April 8, 2012 - 10:41 pm

    I love this idea – I’ve been using a baloon at the end of my brews to tell if they are still active.

  13. #13 by Tony Blighe on October 16, 2013 - 5:07 pm

    I worked on a similar system for measuring the rise (gas production) in bread dough. Timing is important with bread, but I make sourdough which has good days and bad days, so the fermentation time can vary quite a bit.

    I put the dough in a sealed container and measured pressure. When pressure exceeds a certain amount a valve opens to release the pressure. This is controlled by an Arduino Nano.

    I was hoping to have a readout to show the estimated time until the dough (or starter) is ready, and perhaps heat/cool the dough to achieve a target fermentation time.

    My pressure sensor was not very sensitive so there had to be quite a high pressure in there and leaks were a problem. I need a very sensitive pressure sensor, or perhaps make one using an airlock as a manometer.

  14. #14 by hpux735 on October 16, 2013 - 5:25 pm

    Very interesting! I’d be interested in any advancements in this endeavor.

(will not be published)

Please complete this capcha. I get almost 1000 spam comments a day! * Time limit is exhausted. Please reload CAPTCHA.