The idea of this project is to image the refractometer output, then convert the position of the blue line, to a digital reading, using image processing.
The idea is to measure the brix of wort during mash and sparging, so that sparging can be stopped around 1.010 SG, to avoid tannins.
It was necessary to alter /boot/config.txt, so that the temperature probe was recognised. Also without gpiopin=4, the probe didn’t seem to be detected on my Pi Zero W.
The following image depicts a Pi zero with a camera along with a thermowell with a DS18B20 temperature probe, also connected to the Pi.
Image from the refractometer taken via the Pi camera, without any liquid in the vessel.
The following video depicts water being recirculated through the refractometer being heated from around 17C to just below 70C, before the raspberry pi crashed, I believe being in too close proximity to the hot refractometer (Note: The camera is now separate from the refractometer body, so this shouldn’t happen).
The idea of heating just plain water, is so that I can generate a calibration curve for brix as temperature increases.
As you can see from the video I need to alter the shutter speed of the pi camera, as the images become too dark at high temperatures.
Image of the first test, using a piece of paper as a diffuser and clumsily balanced on a tub to get the right angle for the liquid to fill most of the vessel. Note the photo below was taken just after the experiment, and the water in the vessel has dropped what looks like below the thermowell.
I had problems with the triclamp version I was working on, I believe possibly because not enough light was getting in from all angles.
Version 3 (2020)
The following image depicts a new version, making use of a lab clamp to hold the jar. The camera is now positioned on a mini tripod.
I recorded images every second from the refractometer whilst heating the water being pumped through it. I took two photos to create a simple line graph, with the following values:
|Pixels from top of scale to line
Using this information I obtained an equation for the line, which allowed me to perform temperature correction for different temperatures.
I created a very simple python snippet that I then used to obtain a ‘real’ brix value when I added powdered sugar to the water.
current_temp = 70.31
current_diff_from_top_scale = 1284
scale_height = 1170
return 3.383*temp + 1094.515
print((1 - ((current_diff_from_top_scale - (temp_correction(current_temp) - scale_height)) / scale_height)) * 32)
This gave me a value of 1.32 brix whilst my digital refractometer read 1.4 brix.
https://github.com/anfractuosity/refractometer – the software to capture images and log temperature data to a CSV file, is located here.
You can see my article in the BYO Magazine – https://byo.com/ (Jan/Feb 2021) for further information on this version.
My first attempt at tracking the refractometer brix line automatically (you can see it doesn’t always find the line exactly, so this needs to be improved):
- Investigate different plastics which may be more suitable for high temperatures (less potential for warping)
- Finish working on software to automatically determine the brix from the photo
- Then use many photos for the generation of a graph of the temperature and ‘apparent’ brix, so that a more accurate calibration curve can be created.