Quantcast

Can it even be done? Measuring Specific Gravity using Arduino or Raspberry Pi

HomeBrewTalk.com - Beer, Wine, Mead, & Cider Brewing Discussion Community.

Help Support Homebrew Talk:

Ayuir

Well-Known Member
Lifetime Supporter
Joined
Mar 31, 2012
Messages
59
Reaction score
5
Location
Black Diamond
Time to come out from lurking mode I suppose! I did an experiment a while back using a differential pressure sensor:
Is it possible to get the details of your setup so we have a starting point on our own experiments rather than starting from scratch? Yours looks like it already has the accuracy necessary to determine when fermentation is complete.:rockin: I'd be interested in seeing both the hardware setup and code.
Thanks.
 

Oyvindt

Member
Joined
Jun 21, 2012
Messages
7
Reaction score
3
Location
Bergen
I haven't really put too much work into it, so there's not a huge amount of stuff to share.. I'll write up what I have though. It comes without any warranties :p

The hardware setup is as simple as it can be:



The differential pressure sensor is hooked up to two metal tubes though thin silicone tubing. The tube ends was placed about 15cm apart. The hoses going from the metal tubes to the sensor needs to be completely air tight before lowering the tubes into the wort, or you'll have to implement some sort of bubbling device to push the wort out of the tubes to get a correct reading. For ultimate stability and the best readings, I suspect this might be the best way to do it anyway as you don't have to worry then about stuff clogging up the tubes. Getting the tiny tubes properly air-tight was really the biggest challenge of the setup, so I think I am going to find a sensor with bigger inlets.

I used a BeagleBone Black (http://beagleboard.org/Products/BeagleBone+Black) to read the analog sensor, but you could of course use your own favorite microcontroller / single board computer / Arduino / whatever. I like the BeagleBone as you get easy access to a little local DB, and can use stuff like Ruby (which i use in my day job...). The beaglebone just stores values (i think I stored a value every minute or so) to a database (SQLite), and I just used jsfiddle to generate a plot from values dumped from the database.

I don't have the ruby stuff right here, but on the Beaglebone, reading an analog pin is as easy as just reading a file. I don't remember the default paths to the analog pins, but it would be the same as reading a 1-wire temperature sensor:

Code:
value = File.read("/sys/devices/w1_bus_master/<serial>/w1_slave")
.. I'll have to do some digging for more details ;) And the Beaglebone stuff probably wouldn't be that useful if your more used to Arduino or the like, but I'm up for helping out and doing more experiments with this! :D
 

bonebrews

Active Member
Joined
Jan 28, 2014
Messages
25
Reaction score
2
This is the best idea I've seen for measuring OG using a BB/raspi. I'm going to look into it if I get around to building a fermenter. Have you done anything else with your BB?

Sent from my Nexus 7 using Home Brew mobile app
 

Oyvindt

Member
Joined
Jun 21, 2012
Messages
7
Reaction score
3
Location
Bergen
I think it's certainly one of the more viable options for the home tinkerer :)

I've done mostly sensor stuff (like temperature / pressure / switces) with the BB so far. Seems like you also use 1-wire sensors with yours?
 

Oyvindt

Member
Joined
Jun 21, 2012
Messages
7
Reaction score
3
Location
Bergen
Yep. I took gravity readings along with my experiment, and I think it was fairly linear. The wort started out at 1,35 volts @ 1,043 SG and ended at 1,05 Volts @ 1,050 SG. 300 mV on a 0,025 SG range. So for 0,001 change in SG the AD reading would change 300 / 25 = 12 mV.

You would probably need to just calibrate it with a couple of points after you set the vertical distance between the tubes.
 

Ayuir

Well-Known Member
Lifetime Supporter
Joined
Mar 31, 2012
Messages
59
Reaction score
5
Location
Black Diamond
Thought that was likely how you'd calibrated it (measure, compare to test sample and adjust). Did you notice any variations for temperature or any other conditions (or have you tested any other conditions)?
 

Oyvindt

Member
Joined
Jun 21, 2012
Messages
7
Reaction score
3
Location
Bergen
I've not tested different conditions thoroughly, but the temperature did drop a few degrees (Celsius) during the fermentation without any big change in the measurements.

I was hoping that having two tubes would counteract any change in temperature or external air pressure from changing weather or just the internal pressure in the fermentation vessel, as the differential pressure would be the same. Just one tube would quickly lead to off measurements I think.

More experimentation needed :mug:
 

scottmizo

New Member
Joined
Apr 3, 2014
Messages
2
Reaction score
0
I was hoping that having two tubes would counteract any change in temperature or external air pressure from changing weather or just the internal pressure in the fermentation vessel, as the differential pressure would be the same. Just one tube would quickly lead to off measurements I think.

More experimentation needed :mug:
Do you think something like a pitot tube would work for this application?

http://www.rangevideo.com/en/osd-autopilot/284-rangevideo-pitot-tube.html
 

Oyvindt

Member
Joined
Jun 21, 2012
Messages
7
Reaction score
3
Location
Bergen
That looks like a nice solution! The only thing I would worry about would be proper sanitation of it. Can it be disassembled and can it handle boiling?

The holes seem to be a bit small too? There might be a risk of clogging it up. Maybe there are other pitot tubes with bigger holes available. Other than that it certainly looks a lot cleaner than my crappy setup :)
 

neumeon

Member
Joined
Feb 29, 2012
Messages
15
Reaction score
6
Location
Bay City
This could also be done by placing 2 static pressure sensors at 2 different heights in the fermenter wall (easy with stainless) and subtract the values. The greater the spacing, the better the resolution. For home brewing applications, use a pressure sensor designed to measure low pressures, e.g. under 5 psi. (1 psi = 27.679904843 inches of water at 4degC).

To be most accurate, the temperature of the wort/beer should measured and used to compensate for density changes with temperature just like a hydrometer measurement should be corrected.
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
Haven't got my feet wet with my Uno yet, and I am excited by the differential pressure sensor idea that was proposed above. But I have been thinking about this for a while, in a general sort of way, and I am surprised no one mentioned flex or stretch sensors. If you attached one to any kind of floater, that should give you a pretty good handle on specific gravity. You could run one through the side or bottom of your rig, seal with silicone, and have a submerged sensor that won't be affected by krausen. You could change the buoy size to meet resolution requirements. Of course you'd need a waterproof sensor or to do some creative waterproofing, but that doesn't sound totally imposing to me.
 

justaguy

New Member
Joined
Jan 29, 2012
Messages
4
Reaction score
0
There's some similarity with this to what oscsys with OpenTroller are doing using the MPX5010DP to measure wort level in the BK. Again a differential pressure sensor.
 

creekrat

Active Member
Joined
Apr 30, 2014
Messages
40
Reaction score
1
It can be done. May be expensive but yes. Several companies make a stainless, food grade, coreolus sensor that can not only measure SG but can measure temp, viscocity, rate of flow, and several others.
 

Tytonegro

Active Member
Joined
May 19, 2014
Messages
28
Reaction score
0
Location
Portugal
There was a kickstarter project of a couple of guys who did a electronic gravity msr thingy. They used a float swimming in your fermenter. They measured the angle of the float which indicates the spec. gravity of the wort. Output (gravity + temperature) was sent out with bluetooth I believe.

Could not find it now on kickstarter, but it was there very recently.

I'm into automation, but this is what I'm working on now:)

https://www.homebrewtalk.com/f235/single-pot-small-automated-brewing-system-design-475811/
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
Dang, no one here thought of tilt, huh? I can't figure out what the BeerBug's mechanism is for sure. Looks like Brewometer will come in about $20 cheaper. I think I like the Brewometer accelerometer/weighted tilting vessel idea more, but it's hard to say without more info from BrewBug about how their model works.

In terms of reproducibility at home I think tilt is going to be cheaper and sturdier, less moving parts, less @#$# to fiddle with than differential pressure and other methods, but correct me if anyone thinks I'm wrong. I think you could rig one of these up for well under $100 in a weighted PET bottle. Accelerometers are cheap, the most expensive part would probably be the microcontroller.
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
I could be wrong, but there are accelerometers out there for $5-15 that claim to measure tilt. Their proof of concept was a Wii remote, that's a cheap sensor.
 

mbbransc

Well-Known Member
Joined
Oct 4, 2007
Messages
671
Reaction score
111
Location
Winston-Salem
Many ppl here smarter than me. If someone can prototype an effective design and effectively writeup some DIY instructions, I'm sure many here would like to build one.

If something like this can be linked to a BrewPi type solution, that may be the dream. Then change temp control via style profile. The whole fermentation process would be automated with real-time data.

Nice dream.
 

chris2012

Active Member
Joined
May 25, 2014
Messages
26
Reaction score
9
I'm working on a specific gravity meter using ultrasound currently.
I'll be charting my progress on http://hackaday.io/project/1231-Zymeter

The idea is to measure both the speed of sound and the amplitude of the returned pulse, in order to calculate the specific gravity.
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
That's an exciting approach, too. Could the abundant chinese range finders even be suitable for that?* I'm wondering if you might get (reproducibly) different point-blank readings from different materials based on density, and then it's just a question of resolution.

*(I'm guessing the answer is "no, but it will cost me all of $4 and shipping to prove it")
 

chris2012

Active Member
Joined
May 25, 2014
Messages
26
Reaction score
9
You could certainly try, I'm not sure how accurate that would be though.

I'm trying to measure the speed of sound using a 100MHz ADC to try and get fine grained information.
 

creekrat

Active Member
Joined
Apr 30, 2014
Messages
40
Reaction score
1
Chris, that is very similar to the coriolis effect sensors. If one could measure volume with precision, the weight options would be very inexpensive
 

chris2012

Active Member
Joined
May 25, 2014
Messages
26
Reaction score
9
creekrat, I'm not sure what you mean exactly by weight options. Do you mean where you dangle a weight in the beer, like beer bug, if so I've tried that approach, but found massive problems from creep from the load cell.
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
Volume precision shouldn't be necessary with a load cell/weight system, right? And if it were you should be able to use known OG as a baseline.

Also inelegant, but maybe you could account for creep with a second load cell, with a matching weight above the beer line? Nothing says they'll be exactly the same but I gather load cell creep is fairly consistent and depends on materials.

I guess slight buoyancy might mean less creep than the control weight (depending on how little weight we're talking), but if you lightened the second weight slightly assuming the "in liquid" weight was in 1.000 or 1.060 or whatever assumed SG... I don't know at this resolution that might not even be necessary.
 
Joined
Feb 24, 2013
Messages
1,621
Reaction score
1,800
Location
New Brighton
Wouldn't this all be simpler if you use the principal of bending light like a refractometer? It's certainly a proven and reliable concept. The difficulty is in automating it and getting it to work over a period of time in the fermentation environment.


Sent from my iPhone using Home Brew
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
I think once you're looking at a digital refractometer that can interface with arduino you are passing the cost of more expensive, tested methods (coriolis or off the shelf)
 

chris2012

Active Member
Joined
May 25, 2014
Messages
26
Reaction score
9
I'm skeptical on the accuracy of refractometers in general once there's fermentation.

Ideally spectroscopy would be the solution, but the sensors are ridiculously expensive (currently).
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
Actually... I mean why would you do this with tilt when you could install a stationary rotation sensor, which should be more accurate and cheaper?

As far as I can tell you'd just need a waterproof port with a rod that can spin, and a unit on the outside with a rotation sensor. You could calibrate with water before each brew.

Thanks for bearing with my kindergarten drawing (and possibly kindergarten engineering)

Untitled.jpg
 

fearwig

Well-Known Member
Joined
Sep 2, 2013
Messages
1,111
Reaction score
193
You should be able to overcome friction without a problem and still have a seal. I can't figure out what kind of off-the-shelf seal to use, but vinyl/silicone tubing with a food safe lubricant should do the trick if you can get a rod to fit snugly.
 

pilotniq

New Member
Joined
Nov 30, 2014
Messages
1
Reaction score
0
The wort OG was 1.043, and it ended at 1.018 (it was fermented in a too cold basement with too little WLP400, which is probably why it stopped early. No oxygen added or shaking wort either..) The values on the graph is voltage * 1000 so there is a 300 mV difference from start to finish.
Hello Øyvindt!

I just found this thread and was very interested in your post.

I'm trying to make sense of the numbers, please help me out!

Your sensor has a pressure range of +-25 mbar, which should be represented by 80% of the Vsupply of your chip, which I'm guessing is 3.3V. That would mean that 2.64 volts is 50 mbar, or about 19 mbar per volt.

Your reading of 300 mV between the start and end of fermentation would mean a pressure difference (or difference of difference of the pressure) of 5.7 mbar, or 570 Pa.

Static pressure in a liquid as I can tell is density * depth * accelleration of gravity. The difference in pressure between two depths is density * depth difference * accelleration of gravity.

The initial pressure difference should be 1043 kg/m^3 * 0.15m * 9.81 = 1535 Pa or 15,35 mBar. The final pressure difference should be 1018 kg/m^3 * 0.15m * 9.81 = 1498 Pa or 14.98 mbar. The change in pressure difference should be 37 Pa or 0.37 mbar.

Yet you seem to be getting 5.7 mbar (15 times more than expected). Have I calculated something wrongly? Or could there be a change in pressure in the CO2 between the beer and the airlock or something else causing the change?

Regards from Stockholm.
 

JKoravos

Well-Known Member
Joined
Jul 24, 2009
Messages
1,206
Reaction score
77
Location
Chelmsford, MA
You should be able to overcome friction without a problem and still have a seal. I can't figure out what kind of off-the-shelf seal to use, but vinyl/silicone tubing with a food safe lubricant should do the trick if you can get a rod to fit snugly.

You wouldn't even need to seal it, just have the entire assembly immersed and install a sight glass to see the position of the unit. You could even integrate the fitting/sight glass/'sensor' into one unit.
 

aangel

Well-Known Member
Joined
Oct 18, 2010
Messages
568
Reaction score
65
Location
Toronto
Good luck with this. I'd be curious if you managed to get it done cheaper than a beerbug :)
 

JKoravos

Well-Known Member
Joined
Jul 24, 2009
Messages
1,206
Reaction score
77
Location
Chelmsford, MA
I've been playing with this on and off for a few years now.

The most effective solution I've come across so far is to use a mass flow meter to track the total quantity of CO2 blown off. This is an imperfect (though quite good) correlate to gravity and a perfect correlate to ABV. I use a mass flow controller that I got off ebay for around $65...works a treat and makes a great spunding valve for pressurized fermentations (if you're into that).

I could never get the floats and suspended stuff to work properly. Fermentation is just too gunky.

Bringing up an old post here, but i thought I'd ask. I have a couple of mass flow meters I bought years ago to do exactly this. I've always felt like it would be the most painless method for real time fermentation monitoring. Did you ever put together a thread/post on how you implemented? Are you totalizing the CO2 or just getting the live readings? Do you have any temp correction for CO2 saturation in the beer? How are you keeping gunk out of the meter? Sealed knockout?

Sorry lots of questions. I want to get my system implemented this summer so I'm gearing up.
 

kiteD

Member
Joined
Jan 13, 2015
Messages
24
Reaction score
0
I really should put my money where my mouth is before posting. Especially when I want to try something a lot of people have tried, but it never caught on. But, if anyone reads this and wants to run with my ideas, you'll probably outpace my trying to find time for the project.

I want to use a microcontroller for fermentation temperature control, and I've wanted to try my hand at Peltier thermo electric coolers. I know, sounds like there are some moderate successes at this, but not enough it's taken off. My take is this. I want to ferment directly in a cooler in order to insulate from outside temperature. I also want to use an aluminum heat transfer plate in the wort to directly couple the heat out of the cooler. (Many just use the fans to cool air above.)

With that background info, the relevance to this post topic is that I had considered fermentation monitoring since you have the microcontroller there anyway. That was to be an add on project *if* the TEC succeeded. Then I realized, fermentation should produce an amount of heat proportional to alcohol production. The thought is, if I (or you) can characterize the amount of heat that the TEC has to pump out of the cooler in order to maintain a temperature difference, you can then subtract that from the amount of heat you are pumping out of fermenting wort and get an estimate for free.

One more explanation? If you build a device that will keep water at a specified temperature, and you measure how much power it is taking to do it. Then if you use it to keep fermenting wort at that same temperature and count how much more power is required, the difference is an indication of heat produced and is proportional to alcohol production.

I'd never thought of it, but duty cycle on everyone's chest freezers might do the trick as well?

Any thoughts?

I am accumulating some parts for the experiment, and will post if I have any success, or maybe even a failure post.
 

crane

Well-Known Member
Lifetime Supporter
Joined
Sep 20, 2011
Messages
1,163
Reaction score
398
Location
San Diego
I really should put my money where my mouth is before posting. Especially when I want to try something a lot of people have tried, but it never caught on. But, if anyone reads this and wants to run with my ideas, you'll probably outpace my trying to find time for the project.

I want to use a microcontroller for fermentation temperature control, and I've wanted to try my hand at Peltier thermo electric coolers. I know, sounds like there are some moderate successes at this, but not enough it's taken off. My take is this. I want to ferment directly in a cooler in order to insulate from outside temperature. I also want to use an aluminum heat transfer plate in the wort to directly couple the heat out of the cooler. (Many just use the fans to cool air above.)

With that background info, the relevance to this post topic is that I had considered fermentation monitoring since you have the microcontroller there anyway. That was to be an add on project *if* the TEC succeeded. Then I realized, fermentation should produce an amount of heat proportional to alcohol production. The thought is, if I (or you) can characterize the amount of heat that the TEC has to pump out of the cooler in order to maintain a temperature difference, you can then subtract that from the amount of heat you are pumping out of fermenting wort and get an estimate for free.

One more explanation? If you build a device that will keep water at a specified temperature, and you measure how much power it is taking to do it. Then if you use it to keep fermenting wort at that same temperature and count how much more power is required, the difference is an indication of heat produced and is proportional to alcohol production.

I'd never thought of it, but duty cycle on everyone's chest freezers might do the trick as well?

Any thoughts?

I am accumulating some parts for the experiment, and will post if I have any success, or maybe even a failure post.
This all sounds good theoretically if your ambient temperature never changes. My wild guess is it becomes difficult to determine exactly how much energy is being used to maintain 65F at different ambients versus how much is used to offset the small amount of heat energy generated from fermentation activity. This may work during the most rigorous part of fermentation but as fermentation activity slows down the heat generated goes to almost nothing for the small batches us home brewers make.
 

kiteD

Member
Joined
Jan 13, 2015
Messages
24
Reaction score
0
Agreed, but a temperature probe outside the cooler should be able to track the temperature difference. I suspect temperature difference will be the deciding factor (ie it takes x amount of energy to keep the inside at 30 degrees in a 60 degree room and x amount of energy for 60 in a 90 degree room.) If that curve can be modeled and is reliable, then you're in. Much experimentation will be required, of course.
 

Latest posts

Top