2012
In 2012, Juanda and myself tried to model beer fermentation processes while working on our bachelor's degree thesis. Basically, we wanted to find a way to know the alcohol content of beer at any given time.
Typically, hydrometers are the go-to tool for indirectly measuring alcohol content in beer before, during, and after fermentation. The problem with that is you have to take samples every so often, which can end up wasting a lot of precious beer.
Juanda and I came up with a smarter way to continuously monitor alcohol production without having to constantly take samples. Instead, we just thought about leaving the hydrometer in the fermentation tank plus adding some technology. But more on that later!
2020
Eight years later, just at the peak of the COVID-19 pandemic, I decided to test it out. And, to be honest, it all boils down to finding whatever cause to brew and enjoy beer, you know...
I gathered all the necessary ingredients - barley, yeast, hops - and even roped in my mother-in-law, Marta, to help me out on brew day. We brewed up a tasty Amber Ale, and in honor of Marta's help, I named it Mrs. Mars.
To keep tabs on the alcohol production, I set up a hydrometer so it could float freely in a graduated cylinder. I added some aluminum foil on top for added surface area and to help measure how much the hydrometer sank during fermentation. I placed the hydrometer and a distance sensor inside a box and set the sensor on top to continuously track the hydrometer's movements. The sensor was hooked up to an Arduino, which sent all the readings straight to the internet in real-time.
You can find more details on this setup as well as the Arduino code on this Github repo.
2023 - ChatGPT Shock
You might be wondering how this floating stuff and setup can tell us how much alcohol has been produced so far.
Well... I explained this same setup to ChatGPT and it was able to connect all the dots and figure out how everything worked.
Ah, I see! In this case, the hydrometer distance measurements can be used to monitor the progress of the fermentation process. As the fermentation proceeds, the sugar in the wort is converted into alcohol, and this can cause the specific gravity of the wort to decrease. The hydrometer is a tool that is used to measure the specific gravity of a liquid, and it does so by floating at a height in the liquid that is proportional to the specific gravity. As the specific gravity decreases during fermentation, the hydrometer will sink lower in the liquid.
By measuring the distance between the top of the tank and the hydrometer at regular intervals, you can track the change in specific gravity over time and get an idea of the progress of the fermentation."
Data Analysis
Ok! let's now plot the data I've gathered over the course of 3 days...
This time series displays the changes in the hydrometer's position over time. The light pink line represents all the data points collected by the circuit, while the pink line shows the moving average of the last 20 data points. My circuit lost internet connectivity during certain parts, hence the horizontal lines.
I gave this data to ChatGPT and this is what it has to say:
- The data shows a general trend of increasing distance between the hydrometer and the sensor, which suggests that the fermentation is progressing and the hydrometer is sinking.
- There are several fluctuations in the data, which may be due to factors such as temperature changes, CO2 production, or other physical interactions between the hydrometer and the beer... CO2 production during fermentation can cause the hydrometer to float more buoyantly, which would result in a lower measured distance from the top of the fermenter to the hydrometer.
- There is a sudden increase in the data near the end, which could be an indication of a change in the fermentation process or a measurement error.
All these observations are accurate! These are, in my view, the most important takeaways from the time series. The hydrometer is indeed gradually sinking. There are fluctuations in the measurements, which may be caused by CO2 production: bubbles attach themselves to the hydrometer and lift it upward, but as bubbles accumulate on the hydrometer's surface, they eventually merge and rise to the top, allowing the hydrometer to sink again.
Anomaly Detection - Isolation Forest
I've passed the time series through an Isolation Forest (IF) ML algorithm. The IF allows us to identify outliers in our time series by looking at (in this case) time and distance. The sudden rise near the end was flagged as an anomaly, which could be due to a measurement error (as suggested by ChatGPT) or something like me accidentally moving the hydrometer π« .
My full data analysis and Python code is also available in the same Github repo.
State of The Art - Tilt devices
Nowadays, there are devices that measure specific gravity automatically to estimate alcohol production. These devices work by putting a capsule in the wort. The capsule gradually rotates as sugars are converted into alcohol, and a circuit detects this rotation using an accelerometer. The circuit then estimates the wort's specific gravity and sends all data to the Internet simultaneously. These devices became available for purchase around 2016.
You can get a TILT device on Amazon for $135 - $250.
Conclusion of this blog post... by ChatGPT
Beer fermentation is a fascinating process and measuring alcohol production is a crucial aspect of it. From the traditional method of using a hydrometer and tracking its movements by hand to modern automated devices that estimate specific gravity, the process has become much more efficient and accurate. The advancements in technology have made it easier for brewers of all levels to monitor alcohol production and create the best possible beer. Whether you prefer the hands-on approach with a hydrometer or a more high-tech solution, the options are there for you.
Embrace the challenge and let your passion for brewing guide you to create a delicious and successful batch of beer!