Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!





Ask MAKE is a weekly column where we answer reader questions, like yours. Write them in to mattm@makezine.comor drop us a line on Twitter. We can’t wait to tackle your conundrums!

ask_make_liquid_sensor.jpg

Brett writes in:

Hi, I am building an automated brewing system for home brew beer. It will be controlled via an Arduino and network interface. I am using 15 gallon stainless steel kegs as brewing vessels. What is the best method or type of sensor to use to accurately detect liquid levels in the kegs? The liquid won’t be water alone, and all three vessels will be heated. I was thinking of using an external sight glass + a pressure sensor of some kind. Maybe someone in the Make community has a better idea or has done this before?

I have been a Make subscriber for the last two years(since I found out about you guys) keep up the great work!

Thanks Brett! So, you want to measure the level of a liquid in a tank. These are some of the ways that I can think of to do this:

  • Capacitive: Measure difference in dielectric constant between air and water
  • Differential pressure measurement: Measure pressure at bottom of liquid
  • Optical: Use an array of light sensors to sense where liquid is/isn’t
  • Float: Put a float on a stick, then measure the displacement of the stick
  • Weight: Weigh the liquid, and calculate volume based on density
  • Conductivity: Measure liquid conductivity at a few discrete points

Out of these options, what would be best? I think for your project, the best way to go is probably to use a differential pressure sensor, like you suggested. It seems like it would be the most reliable and least invasive method. Also, it just so happens that the folks who wrote the Practical Arduino book have a Water Tank Depth Sensor project that might be a good starting point.

If you only want an approximation of the amount of liquid in a tank, a simpler way to go would be to test for conductivity at a few points along the side of the tank. You wouldn’t be able to sense the exact amount of liquid present, but it would be a fine way to check if the tank is half-full or not. The folks at electronics labs built a single-point Water level detector using a PIC microcontroller, which could be expanded to measure multiple points

Capacitive sensors might work, but might be hard to set up in a metal tank. Optical sensors work the same way as the conductivity sensors, and would be more expensive, so they probably aren’t worth the trouble. A float could potentially work, but could get gummed up by hops or dead yeast, so it might be unreliable. The weight sensor could also work, but I think it might be tricky to keep it calibrated.

Good luck, and remember to let us know when you have it working!

Have you attempted a system like this before? Have some experience to share, or a better way to accomplish this? Sound off in the comments!


Related

Comments

  1. Nick says:

    Search for ultrasonic distance sensors

    1. Colin says:

      That’s what I was going to suggest as well. The same sensors used on many robots to measure distance to a wall will happily measure the distance to the surface of the liquid from above. You might have to calibrate them for the temperature of the brewing vessel and the moisture content of the vapor, but they are safe (sometimes used to measure flammable liquids like), fast, and don’t take much power.

      1. Aaron says:

        You don’t really need ultra sonic sensors. Since he is filling stainless steel containers of a known volume all you need to do is create a device that taps on the side of the vessel and listens to the change in the pitch of the sound as the vessel fills up. A simple electric motor and cheap microphone mounted right at the top should do. The higher the pitch the more liquid. With a few tests you could calibrate it to a pretty exact volume.

  2. Odin says:

    I’ve been wondering about this: Why not use optical or sound? Sound may be a bad choice when trying to clean everything, so how about an IR sensor? Whenever I brew something, the liquid is brown and there is a significant number of particles on surface. You could place one distance sensor on the top of the container and face it downward to measure the distance, letting you know how full it is.

    http://www.acroname.com/robotics/info/articles/sharp/sharp.html

    Are you looking for accuracy, or existence? Do you want to know when you are full, or are you trying to guess how long until you are empty?

  3. the_case says:

    I did something similar to this:

    http://www.thegatesofdawn.ca/wordpress/homebrewing/sight-gauge/

    Mine uses clear plastic tubing instead of glass, and is supported with copper tubing that has a channel cut in it.

    The tubing does get cloudy over time (I’ve done dozens of batches without having to replace it yet), but as long as your level markings are on the copper tubing, replacement of the tubing is a snap.

  4. the_case says:

    I missed the part about automation.

    Perhaps a inline liquid flow sensor could be a better judge of how much liquid passes into the new vessel instead of measuring it after it enters…

  5. Anonymous says:

    Since he stated that different liquids would be used a float or optical sensor would be the best, since all the others require knowing specific properties of the liquid being measured(density, conductivity, etc). If it were me I would go with a float, cheap and simple to implement.

  6. Kyle says:

    I’m also a homebrewer who has started thinking about doing the same. I think the most important consideration is that these kegs will have direct flame on them and the liquid (wort) will be boiling for part of the process. Anything that resides near the bottom (which a tube connected to the differential pressure sensor will need to be) of the keg will need to be very heat resistant.
    A agree that a weight sensor would be a pain since the keg would have to sit on the sensor the exact same way every time unless you want to recalibrate every time.
    My money is on the ultrasonic range finder. It would be positioned at the top of the keg, much further away from the heat source. It may get a little iffy when boiling due to the rolling surface of the liquid and the steam coming off.

    1. Chris G. says:

      I’d have to agree with Kyle – thinks can get very dynamic during parts of the brewing process, and you need to have a very robust and heat-tolerant method. So far the best means of level detection I’ve found (from a human standpoint) has been to tap into the side of the brew kettle and run a clear flexible hose up the outside, away from (most of) the heat. Once it’s calibrated by pouring known amounts of water in and marking it with hashmarks it’s a very effective way to know how much wort is remaining in your kettle, even when that liquid is boiling like crazy.

      So, I’d suggest expanding on the ideas which get the heat, steam, condensation, and unfiltered grain/hops away from any sensor you use. Many of the above methods will work for detecting the level in that tube, rather than in the entire kettle. Plus as an added bonus you can use one modular sensor which swaps out easily in case of failure, even when you’re in the middle of brewing a batch.

  7. EthanZ says:

    I’ve seen capacitive sensing used successfully on some espresso PID mods, the only downside is that you need to be using a plastic container.

  8. Rob says:

    You’re measuring volume. The best way to measure volume is still good old math. You know the circumference of the barrel. The only variable you need to calculate volume is height, or in this case, depth of liquid. So, the goal here is to determine the depth of the liquid electronically.

    Fish finders seems to do a great job estimating depth, so the ultrasonic range finder seems promising. I know Hummingbird has a small, wireless fish finder that you cast out with a fishing pole. Not sure how hackable it may be, but something to look into.

  9. Ken says:

    I would use a sight glass and a set of optical interrupters. The wort should be able block out the optical signal. This will work since most brewers work in 5 gallon increments and you would not need sensors at every point.

    Make sure the sight glass is easy to clean or replace. One of the secrets to good beer is a clean fermentor.

  10. brandon says:

    Another homebrewer weighing in here…sorry in advance for the brewing jargon. I don’t think a float switch would be a good idea for what Brett wants to do, except for maybe in the case of controlling the sparge flow into the mash tun. I think you can get one of those at Northern Brewer or some other site, but I don’t think it would be as robust and flexible as he wants to set up the system to be.

    The differential pressure sensor idea sounds great, but that requires you to know the gravity of your wort, so that would just be another step. That might not be so bad, though, since an error of 1 point in gravity would be 0.1% in volume, so you can probably just use the expected OG from your recipe as calibration to the volume measurement and it will still give good results. I guess it just depends on how accurate you care for your volume measurement to be!

    Ultrasonic distance sensors would be awesome, but I can see that possibly getting messed up from steam coming off the hot water, mash, and boiling wort, or even from the rolling action of the boil. The software would have to be robust to transient foam buildup (maybe have it automatically spritz water on the foam in that case? :P). Anyway, you could try it and let us know!

    My money for the most robust (and unfortunately, kind of expensive) method would be on optical sensors in sight gauge tubes on the hot liquor tank, the mash tun, and the boil kettle. Since the liquid in the mash tun and boil kettle would be darkish, detecting the level should be straightforward. Maybe put a little black floaty ball to detect in the sight gauge of the hot liquor tank since it’s just clear water in there and would be trickier to detect a difference in light level at the sensors.

    Good luck!

  11. brandon says:

    @Ken: given that he’s using stainless kegs in his setup, he’s probably doing mostly 10 gallon batches. Yes, most homebrewers do batches in multiples of 5 for variety of reasons. However, you want to be able to measure volumes of water or wort in any amount in any of the vessels, not just “where is 5 gallons in the boil kettle?” If you wish to make consistent beer, you want to be able to know the following:

    1) how much water gets filled into the hot liquor tank,
    2) the water level on top of the mash during sparging,
    3) how much wort gets filled into the boil kettle,
    4) how much wort is left at the end of the boil, and
    5) how much wort gets transferred into the fermenter.

    These all vary from recipe to recipe, depending on your particular brewery setup, how thick you want your mash to be, how much water is absorbed by the grain (which varies a bit from malt to malt, so depends on the grain bill), how much loss there is in the mash tun when you hit your boil volume and stop sparging, your boiloff rate, and your trub loss.

    Having good volume measurements allows you to calibrate many of your brewery parameters and produce better and more consistent beer. And who doesn’t want that?

  12. James says:

    I agree with the_case. A flow meter on the water going into the kettle would be best way to automate this. In fact, there’s a brief article in BYO Magazine last month showing a home brewery where this was done. Optical sensors using a float in a sight glass attached to the side of kettle could also work. You’d have to keep that sight gauge pretty darn clean though, as hops and trub tend to stick to the sides of sight gauges pretty well.

  13. Aaron says:

    Hi i am an electrician in a brewery, the oldest in australia. our kettle uses pressure, because the density of the different brews is known/calculated a look up table is used to work out the level/volume. this could work at home however because of the experimental nature of homebrew might be alot of work calculating density every time. i agree with the other comments about a sight glass/tube this is very reliable but not very automatic unless optical sensors are used. in my experiance with industrial grade ultrasonic level transmitters, ultrasonic would not be very reliable in this process, a good one would probably do but not worth the $$. if you have the money go for guided radar, similar to ultrasonic in setup will work in steam areas and through froth, much better then ultrasonic, they replace ultrasonic alot in industry now, if you have the $. for a home setup though if you dont want to use a sight tube, i think resistive would be the best, it will tell you the level and then can calculate volume. have a look here http://en.wikipedia.org/wiki/Level_sensor#Resistive_chain

    or something like this you could make yourself and use the PIC adc to do the switching by making the rods adjustable for different brews. http://www.puretechenvironmental.com/shop/resistive-sensors.html

    Good luck

  14. Aaron says:

    Hi i am an electrician in a brewery, the oldest in australia. our kettle uses pressure, because the density of the different brews is known/calculated a look up table is used to work out the level/volume. this could work at home however because of the experimental nature of homebrew might be alot of work calculating density every time. i agree with the other comments about a sight glass/tube this is very reliable but not very automatic unless optical sensors are used. in my experiance with industrial grade ultrasonic level transmitters, ultrasonic would not be very reliable in this process, a good one would probably do but not worth the $$. if you have the money go for guided radar, similar to ultrasonic in setup will work in steam areas and through froth, much better then ultrasonic, they replace ultrasonic alot in industry now, if you have the $. for a home setup though if you dont want to use a sight tube, i think resistive would be the best, it will tell you the level and then can calculate volume. have a look here http://en.wikipedia.org/wiki/Level_sensor#Resistive_chain

    or something like this you could make yourself and use the PIC adc to do the switching by making the rods adjustable for different brews. http://www.puretechenvironmental.com/shop/resistive-sensors.html

    Good luck

    1. JM says:

      Thank you very much to Aaron for presenting a link to our website ;-)

      I agree regarding the ultrasonic sensor, the beam is easily disturbed by vapour/foam unless, powerful beam and enhanced electronic to process and filter the signal.
      Sight glass, why not but have you considered the fact that it is a dead zone in which you may have where deposit will occur?
      Resistive probe as suggested will work but again if the fluid contains particles that can deposit you may loose the signal.
      What about a good old cat&mouse system? it provides external level indication and if you are after automation at set point you can fit bistable switch such as BSM501.
      Anyway, if you have a look at http://www.bamo.eu/international/s4_cat410.htm you should find something suitable

  15. pcmofo.clavid.com says:

    Thanks everyone for the great comments! I am really liking the idea of installing a standard sight glass and retrofitting some type of sensors to the outside of that.

    Many of the home brewers out there were spot on with our needs. When complete this system will be able to do 10 gallon batches and be able to be upgraded up to 45 gallon batches by swapping out the vessels.

    We need to semi-accuratly measure the liquids going into and out of each of the 3 vessels. The liquid will vary in temperature from near freezing to boiling. The density of the liquid will vary from water to fully brewed wort full of sugar.

    Based on all of your suggestions I am thinking that some sort of floating colored ball/magnet etc that could float on top of the liquid and an array of sensors on the outside of the plastic/glass sight tube. This would mean we could detect the top of the liquid level regardless of the density, color, and temperature of the liquid.

    So some ideas…. an array of light sensors, magnetic sensors, some kind of captive coil, or some kind of IR/sonic sensor at the top of the tube measuring the distance from the top of the tube to the top of the sight tube float.

    Pouring in measured gallons of liquid you could auto calibrate each sensor individually.

    Based on this setup does anyone have a specific sensor to try out?

    For more info on our brewing system check out our web site http://blackheartbrewery.com/index.php?page=22107124 or check out some of our videos on youtube under Black Heart Brewery

  16. Don Hersey says:

    The best way to measure liquid level in a quantized manner is to intentionally overheat (self-heat) a (sealed) lm335 temperature sensor. The profound difference between the specific heat of air and liquids provides an easy distinction. There is an application note about this somewhere at National Semi, I think.
    The massing idea is a good one and is surprisingly cheap to implement. Get a modern postal scale with a USB interface, and talk to it. You can obtain these at stationary stores for, like, $150. The different brands are similar functionally, as their internals all come from the same place. Analog Devices has a wonderful discussion of the internals of these, search their page with the term ‘load cell.’
    If you are shameless, you could rig a float attached to an Archimedian screw, than measure the rotation with a Hall-effect sensor. If your liquid isn’t clear, there are some possibilities to use optical methods, but these can be hinky.
    Something as simple as a spring and contact plate may be possible.

  17. Becky Stern says:

    I recognize that yard! =]

  18. pcmofo.clavid.com says:

    My first comment didnt go through… maybe this one will…

    Thanks everyone for the comments.

    The first comment I attempted to post last night didnt seem to work.

    I think that the best way for us to go is to add a sight glass to the outside of each of the 3 vessels then add a sensor to the sight glass

    Anyone have a suggested sensor to use? I was thinking of maybe a floating ball and a sensor on the top of the tube that can detect distance from top of tube to the float. Or maybe some kind of capactive sensor that could detect the volume of liquid in the tube.

    Anyone have a specific sensor or method to try with a sight glass?

    Find our more info about our brewing system at our web site http://blackheartbrewery.com/ or look for some of our videos on YouTube under BlackHeartbrewery

  19. alandove says:

    I’d go with a float as the simplest, cheapest, most robust, and easiest to clean. The sight glass would be my second choice, but from direct experience with laboratory fermenters, I can forsee a lot of trouble sanitizing it unless it’s either disposable or very carefully engineered. Also, electronically sensing the liquid level in a sight glass could end up being harder than you think.

    For a float system, all you need is a float, a couple of metal rods attached by pivot points, and a potentiometer. Configure the rods so that the rising float causes an angular change in a rod’s position – think of the water valve in an old-style toilet flush mechanism – and then read the rod’s angle from the potentiometer. The whole thing could be built to clamp onto the side of any brewing vessel, with the electronics well clear of the boiling wort. The float is unaffected by bubbles, heat, or specific gravity. After each batch, take off the whole float assembly and dip it in diluted bleach or iodine to sanitize it.

  20. Brad I says:

    I work as an instrumentation technician in Canada and I do agree with Aaron above, however for an application like this the best way I think for someone to make something themselves to measure the level would be to use a capacitive level measurement.

    Although in the original post Matt says that a capacitive measure might be difficult in a metal tank, it is just the opposite.

    Firstly, because the product is water based, the dielectric constant is going to be high enough to be essentially unaffected by whatever you put in it.

    So what you would do is actually place a metal rod into the tank as one side of the capacitor, and use the metal tank the product is in as the other side of the capacitor.

    Since the water is conductive, the metal rod will have to be completely insulated/covered with something non conductive to prevent it from just shorting though the water.

    So now you have two plates of the capacitor that have a fixed surface area, and the distance between the plates will also be fixed. When the tank gets more full, the water (with a high DK) replaces the air (with a DK of 1.)

    You could totally design this yourself, but you will need to figure out for yourself how to read this into the arduino (probably some sort of RC circuit).

    Lastly, once you are reading the capacitance, you may need to fill the tank with your product in increments and read the values. if the values are linear from empty to full, you can simply take an empty value and a full value as the range in the arduino. If it is non-linear, you would need to make a table to linearize this. (not sure if you can do that in an arduino)

    it is more complicated, but you can do it yourself with a little work for far less than the price of a pressure sensor.

  21. Mike says:

    You might want to check out Madison Co.’s sensors. I have called their toll free number (800-466-5383) they offered em some great suggestions and customized solutions when I was looking into float sensors.

  22. Apis says:

    Great post

    I’ve been thinking of a way to measure the fuel level in the diesel tank in our boat. Not as difficult as this perhaps but I have also thought of measuring the resonance frequency change as the tank fills up or empties, since the boat will heel when at sea, and I was thinking that might be less sensitive the tank being level.

    There have been many good suggestions here. Like Don Hersey I would like to push for weight as well though. I don’t think it would be so difficult to calibrate depending on implementation/hardware. It would be extremely reliable and as precise as you need it to be. It would take up some space though. Not sure what your set-up looks like but if it’s small volumes, a bathroom weight might be enough, and then just hack in an arduino or pic to read the sensor…