For this project, I simply weigh the Keg to determine the remaining beer. For a more detailed writeup of why I weigh versus some other method, see: http://www.brettsbeta.com/blog/2015/01/kegmon/
MeasSpec recently released the FX1901 load cell, touted as a “1% load cell device with full scale ranges of 10, 25, 50 or 100 and 200lbf compression” with “breakthrough price/performance value”. I picked one up from Servoflo.com for about $30 and tested it out: at the initial setup, it detected smaller than half-ounce differences, far better than I had hoped, and far better than the spec sheet indicates!
Hardware
Parts List
- Spark Core the WiFi enabled Arduino-ish microcontroller
- Load cell FX1901 from MeasSpec, purchased from Servoflo.com
- Burr-Brown INA125P instrumentation amplifier, available from Mouser (necessary because load cells only produce a very small change in voltage) Amplifier amplification is set via a simple resistor across pins 8 and 9. I started with 1kΩ, it gave me good results so I didn’t try to optimize any further.
- Electronics enclosure, 3d printed
- Some stainless steel framing angles from McMaster-Carr to build the stand
- Audio jack. Not required, I like to wire into a three connection audio jack for easy assembly and disassembly.
Electronics assembly is easy. Follow the data sheets on the load cell and instrumentation amplifier, or mimic this Fritzing diagram:
The stand is very simple; a better stand will be a future exercise, for now this one is functional. An average keg weighs 160lbs when full and around 30lbs when empty. To use a 100lbf sensor we need to relieve some of that load, but still apply a proportional amount. A quick triangular frame built with framing angles left over from a previous project will balance the load nicely across three feet – one of which is the load sensor. In the event there is more force (such as during installation) the load cell can handle a 250% overload, so just try not to drop it more than a couple inches onto the stand.
The load must be directly applied to the nub in the middle of the load sensor. While not glamorous, the same 5/16″ bolt used for assembly fit nicely onto the center tip without touching any edges. There isn’t a lot of lateral movement of a keg after installation so there isn’t a big need to secure the sensor at this time.
Software
Once the hardware is hooked up, a very simple program reads the load cell’s amplified analog signal from the Core’s pin 0. The response from the load cell is linear, linear interpolation can be used to get a value using two known loads (I used empty and full):
float newReading = analogRead(A0); // Read the voltage from the amplified load cell on pin A0
float load = ((bLoad - aLoad)/(bReading - aReading))*(newReading - aReading) + aLoad; // Using our predefined calibration values (empty and full) interpolate the load reading to get a value.
aLoad and bLoad are known loads, 30lbs and 160lbs respectively, while aReading and bReading are pre-recorded sensor readings at those loadings.
Unfortunately, the load sensor’s output is noisy. For now, I query the analog pin almost continuously then average those readings to get a representative value. Eventually I want to use a Kalman filter for better accuracy. After removing noise, the final value is posted to a web service every ‘interval’ seconds using Spark’s TCPClient function:
if (millis() > mytime + interval) {
weight = weight/count; // Average the readings taken over the last interval
sprintf(url, "/postdata.php?user=0001&weight=%2.2f", weight);
getrequest(); //send to server
delay(10000);
mytime = millis(); //reset all the values for the next post interval
count = 0;
weight = 0;
}
The php script records all the data posted to a database or flat file. From here, the data can be manipulated in some fun ways – an exercise I’ll leave to the reader. My guests always enjoy knowing their average ounces per hour consumed, how much the flow rate spikes at halftime versus in the middle of a big play, or beers per month consumed. ‘Estimated time until empty’ is one of my favorite metrics for parties and judging how popular a particular home-brew recipe is.
A sample graph of a few pourings is below, in which you can see the accuracy of the load cell:
More photos are available here: http://www.brettsbeta.com/blog/2015/01/kegmon/
Email or tweet me if you have questions.
See it running live on our kegerator: www.4drillsbrewery.com/kegmon/
Comments