Sugarboat, an Open Source Digital Hydrometer

An open source digital hydrometer. The main use case is measuring the amount of sugar in liquids during the process of beer and wine making.

Vincent Kok
3 years ago

Have you ever wanted to estimate the amount of sugar in the water during the process of brewing beer? Raphael Baron shared about his journey in making a digital hydrometer that can achieve that!

Background

A hydrometer is a device used to determine the relative density of a liquid solution. It floats on top of it and we can tell something about the liquid’s density by investigating exactly how it floats.

Most analog hydrometers float vertically like this.

At rest, they displace their own weight of the liquid it’s in — that’s the Archimedes’ principle from high school. The catch is this: while this weight is constant, the _volume_ of displaced liquid depends on its density. Intuitively, a larger volume of a less dense liquid must be displaced to cancel out the weight of the hydrometer. This makes the hydrometer sink further into the liquid. We can correlate how much it sinks with the density of the liquid.

Now, imagine we keep raising the center of mass of that analog hydrometer. What should happen? As it turns out, we can get it to float at an angle — and the angle depends both on the location of the center of mass and the density of the liquid.

If we then construct a device that purposefully floats in this fashion, we can correlate this tilt angle with the liquid’s density. I bet you know where this is going. If we slap an accelerometer and gyroscope on this baby, we’re in a pretty good position: we can measure this tilt angle and then estimate the liquid’s density. This is exactly what the digital hydrometer does.

How does it work?

When measuring liquid, sugarboat will float on top of the liquid. This will cause it to shift its center of mass and float at an angle. This tilt angle (see image below) is larger for denser liquids and smaller for less dense liquids. We can then estimate the density of a solution from this angle.

As is usual in the beer and wine making processes, we can additionally correlate the estimated density of a solution with the amount of sugar present in it.

Tech Specs

  • nRF52840 SoC: Reads sensors, estimate the sugar content and exposes their values via Bluetooth Low Energy (BLE) service
  • SHT30 temperature and humidity sensor
  • MPU6050 accelerometer + gyroscope estimates the tilt angle
  • Li-ion 18650 battery
  • Battery life of over a year on a single charge
  • Built-in TP4056-based charging circuit
  • USB-C for battery charging and programming
  • UF2 support using a forked Adafruit_nRF52_Bootloader allows for direct programming via the USB-C port. This bootloader needs to be flashed to the blank nRF52 chip once using a J-Link or compatible SWD programmer.

Calibration

In the world of beer making, the quantity of interest often is the amount of sugar that will get processed into alcohol during the fermentation. The density of the pre-fermentation is usually taken to be caused mainly by sugar. So, the sensor needs to be calibrated by measuring the angle against a series of solutions with different, known sugar concentrations. This will give a list of (angle, sugar%) pairs. We then fit a polynomial model over it to interpolate in-between values:

The process is manual — add some sugar, write down the measured angle. Repeat. We can measure the relative density at each step with a store-bought analog hydrometer, but most people will prefer a refractometer for this. Refractometers measure the refraction angle of a solution and correlate it with, in this case, the concentration of sugar in it. These ones in the picture above output the value in two scales: Brix (1 degree = 1 g sugar/100 g solution) and SG (rel. density, or specific gravity). By the end of this process, you will have the coefficients of a second-degree polynomial that best fits the pairs of measured (angle, degree Brix) and just upload them to sugarboat using the web client and it's good to go.

Web client

This client is a web page that connects to sugarboat using the Web Bluetooth API. It lets you calibrate, configure and read the sensor values right from your web browser, wirelessly.

Interactive 3D model

Baron then exported the 3D model of the PCB board from Kicad design software. Having an accelerometer and gyro means a 3D model can be made extra interactive. The orientation can be obtained from sugarboat’s BLE service and pipe it, together with the 3D model, into Threejs. No wires, right in the browser. The result turns out to be great!

Sugarboat interactive 3D Model

Home Assistant integration

Baron also put together an ESPhome client, which is an awesome way to get sugarboat’s data into Home Assistant. Here’s a screenshot of the home assistant instance:

For more information about this project, all the design files and code are open source and available on GitHub.

Vincent Kok
Community Evangelist, Maker, a STEM AI Robotics advocate in the EdTech industry.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles