Posts Tagged homebrew

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

, , , , , , , ,

18 Comments