Tuesday, April 21, 2015

Fermentation Detector

This is a follow up to my posts on automated home brewing:
Automated Home Brewing
Improved Home Brewing Controller

In the second post I mentioned that I would be adding a "bubble detector" to my interface. Now I have finally gotten the time to do it and am using it to monitor the fermentation stage of a lager. This sensor detects bubbles in the air lock and if you have ever seen an airlock in action you will understand why I call this a "bloop-ometer."

The sensor uses this photo interrupter with a simple circuit to trigger an interrupt on the Raspberry Pi which records how many bubbles per minute are produced. The photo interrupter has a gap with an infrared LED on one side and an infrared sensor on the other. Voltage is provided to the output pin until an object enters the gap and breaks the infrared beam.

In this case the object to block the beam is a small amount of water which is mostly transparent to infrared.  To overcome this the circuit has a potentiometer to adjust the voltage applied to the LED. It must be adjusted down until the sensor is just on the edge of triggering.  In this configuration, the water will block the infrared enough to trigger the device, but when a bubble passes, the infrared can pass.

The circuit is very simple - an interrupter and a potentiometer is all that is really needed. To make it easier to adjust, I added a red LED. I also added an inverter since the output from the sensor is not enough to drive an LED and trigger the Pi. The potentiometer that I used was 5K ohms and I added an additional 100 ohms for safety. If you use less than 100 ohms then too much current will flow into the LED and it will die. (I know this from experience.)

Here is the pinout for the GP1A57HRJ00F.

And here is the circuit as I built it.

And finally, a video of it in action.



  1. Dose the circuit just go to one pin on the gpio? Are you powering the circuit from the pi? and do you have the programming to count the interrupts per minute? Just I'm trying to copy your idea, which I think is a great idea.
    any help would be greatly appreciated. Thank you

    1. Yes, it only uses one gpio pin. i am powering it from the same supply that powers the Pi, but you could easily power this circuit from the Pi since it uses very little current.

      The best way to handle this input is with an interrupt. See my post
      for a description of how this is done. There is example code in that post that you could use almost directly. Just change delay(1000) to sleep(60) to delay one minute. I use the C language and the WiringPi API, but you could do this in Python just as easily.

  2. Thanks for your help. I'm just collecting all the components together, then ill give it a go. I've got no clue about programming the pi. Just hope I can follow your post with no problems. Thanks again, Jason

  3. Hey A Million thank yous, Got it all up and running. and now with the raspberry pi zero released even better. Thanks ever so much.

    thanks Jason

  4. Would love to see a complete part list on this, I see the Raspberry pi, the interrupter, and the inverter but not the potentiometer. Also, the wiring picture from the underside, and maybe that board part number? Love the idea. The code in the link is all that is needed?

    1. any 5K ohm pot will work. I used something like this:

      The board is from radio shack - catalog # 2760148 (I just used half)

      I don't think I ever posted my code, but what I did is way more than you need for monitoring this - it's just one GPIO pin status.