Introduction: ITilt Beer Hydrometer
The iTilt is a digital hydrometer with the purpose of monitoring the beer fermentation process. Hydrometers in general measure the density (gravity) of liquids. The iTilt consist of an ESP32 microcontroller with battery unit, temperature sensor (optional) and accelerometer-gyroscope ( accelero-gyro) on a pcb. All is enclosed in a PET preform. The complete device is inserted in your unfermented beer. Initially the angle between the device and the vertical line will be large. As your brew start to ferment, the density (gravity) will reduce and the tilt angle will also reduce. The accelero-gyro will periodically measure the tilt angle, transform it into gravity (with a statistical model) and publish the results to cloud services.
A few commercial and open source devices (including the iSpindel) working on the same principal is available, but it is always nice to design and build your own thing.
I am a hobbyist in electronics and beer making. I am no expert.
Project is on https://github.com/JJSlabbert/iTilt-digital-hydrometer
The firmware in this project is cleverly written with appropriate pre compiler instructions to work on both an ESP32 and an ESP8266. This will enable iSpindel users to load this firmware on an iSpindel.
- ESP32. I use the ESP32-E Firebeetle 2 from https://www.dfrobot.com/product-2195.html
- MPU6050 accelero-gyro.
- DS18B20 Temperature sensor (Optional)
- XL PET Preform. This is the pre-forms they use to make 5L water bottles from https://www.ebay.com/itm/133422810230?hash=item1f109e8476:g:xscAAOSwPYZU36py
- A suitable PCB. You can etch or cnc it or use a proto-board.
- 18650 Battery.
- 18650 Battery holder. (https://www.ebay.com/itm/334135279577?hash=item4dcc03bfd9:g:YRIAAOSw~cthMa89)
- Push Button
- Proto Board,
- ESP32 programing in the Arduino IDE.
- Beer fermentation.
- PCB Etching/milling.
- Knowledge of the cloud service you want to use.
CLOUD SERVICE ACCOUNT:
Step 1: DETAIL: HOW EVERYTHING SHOULD WORK
As already mentioned: The itilt measures the angle between itself and a vertical line to estimate gravity of the beer. It can also measure temperature with the DS18B20 temperature sensor and/or the MPU6050 internal temperature sensor. The MPU6050 temperature has a resolution of 1 degree Celsius.
Beer fermentation can take anything between 7 and 20 days. The device will be inserted in your beer for this period. You will not be able to remove it easily without contaminating your beer. This limitation forces the device to use battery power very efficiently. An ESP32 continuously connected to WiFi may last 24 hours only on a 18650 battery.
The firmware contains a WiFi Manager Configuration Portal. If the device is powered up and in vertical or horizontal position (titl=+-90, +-0 or +-180 degrees), it will access the WiFi manager. The device will broadcast itself as an WiFi access point. You can enter the access point (ESP32 MAC ADDRESS as password or security key), insert the details of your WiFi router, cloud dashboard (Cayenne, Ubidots or Adafruit IO) and a few other details. This will provide your iTilt with instructions to connect to the internet and publish data to the cloud.
When the WiFi manager (Configuration Portal setup) details is completed and your device is in beer (tilt between 10 and 80 degrees) it will periodically wake out of hibernation mode and do the following:
- measure tilt,
- calculate gravity,
- measure temperature
- calculate alcohol by volume.
- Measure remaining battery live and voltage
- Measure WiFi Signal strength.
Only then it will connect to your WiFi router (a power intensive action) and publish the data to the cloud. After publishing it will hibernate again for the period specified in the WiFi manager Configuration Portal. Sensor measurement will take 2 seconds. Connecting to WiFi and publish data should take +- 4 seconds if WiFi signal is strong.
The sensors (MPU6050, DS18B20) are also powered by GPIO. This will ensure that they do not use any power during hibernation.
The device uses the MPU 6050 frequently to determine what to do. If the tilt is vertical (80-100 degrees) or horizontal (0-10 degrees or 170 to 190 degrees), the WiFi Manager configuration portal will run when the device awake from hibernation. If the roll is vertical (Battery is facing side way), the device will enter an infinite hibernation for storing or charging purpose. To exit this mode, press the reset button.
The device is charged and programed via the USB C port.
Gravity is estimated by a third degree polynomial (model) with tilt as independent variable. Do not let the math put you off. The WiFi manager contains an easy to use calibration wizard.
If you do not have an ESP32 firebeetle 2, other ESP32's should work. You may have to change the pin configuration in the WiFi Manager configuration.
Step 2: BUILD YOUR DEVICE ON a BREADBOARD
This is to make sure that all electronic components are functioning.
3.3v - GPIO 22 (Yes, we power the sensors via GPIO to switch them of when the device is in hibernation)
SDA - GPIO15
SCL - GPIO21
GND - GND
3.3v - GPIO17
GND - GND
To the battery connector on the ESP32
+ to A0 (GPIO36). Use a suitable voltage divider (4.7KOhms and 10KOhms resistor) to bring 4.3volt down to less than 3.3 volt. This is to measure your battery voltage and remaining capacity.
Step 3: Load the Firmware (v1.09) on ESP32
You will need to install the fallowing libraries:
-WiFimanager (Install the latest from Github https://github.com/tzapu/WiFiManager). The arduino library 2.0.3-alpha is out dated and does not support firmware updates.
-ArduinoJson version 6 (Install from Arduino IDE)
-PubSubClient (Install from Arduino IDE)
-OneWire (Install from Arduino IDE)
-DallasTemperature (Install from Arduino IDE)
-MPU6050 (Install from Arduino IDE)
-curveFitting (Install from Arduino IDE)
The firmware is available at https://github.com/JJSlabbert/iTilt-digital-hydrometer/tree/main/SOURCE%20CODE
Load it and also start the serial monitor.
This instructable is based on version 1.09
Step 4: Configure the Firmware
Reset the ESP32 while in vertical position. The BUILD IN LED (Normally Green) should flash fast for 10 times. The WiFi manager configuration portal should now run. A new WiFi access point called iTilt_0 should be available. Access it with your PC or phone. The password/security key is the MAC ADDRESS (printed to the serial port). You can change the password by changing it in setup(), search for wm.startConfigPortal(APName.c_str(),WiFi.macAddress().c_str())
The landing page should open. If not, open it with 192.168.4.1 in your browser address bar.
Navigate to the Readings page. Make sure all readings, like tilt, roll, temperature is logic. Tilt should be +-90 and roll +-0. Tilt and roll your breadboard to see how the readings change.
If you do not get proper sensor readings, study the serial monitor and check your wiring.
Navigate to Configure Wifi, Cloud and Calibration. Insert your WiFi details, cloud server details.
Use MQTT Username, Password and Client ID
MQTT Username: Adafruit IO username
MQTT Password: Adafruit IO Key
MQTT Client ID: (Short description of your iTilt with no special characters or spaces). Use iTilt
MQTT Username: API TOKEN
MQTT Password: Leave empty
MQTT Client ID: (Short description with no special characters or spaces). Use iTilt
Make the publication interval 2 minutes for now. Click Save. Make sure you always retype your WiFi SSID/Password, otherwise nothing will be saved. Tilt the device +-45 degrees and see what is published to your cloud service.
Step 5: Build Your Device
You should now create a PCB. Attach is my board design in dxf and Autodesk Eagle format. You will see there are large solder pads for the battery holder. The battery acts as a weight to get the tilt right. The positioning may require some experimentation to get the largest dynamic range of tilt readings. I suggest you put it more or less in the same position as in the image.
My PCB was machined on a desktop CNC. You can etch it or build it on a proto-board. If you do it on proto-board, keep the antenna on top to ensure a strong WiFi Signal when the device is in beer. Also leave enough space to move the battery up and down to get a proper dynamic range for tilt.
Solder all your components on your PCB. Make sure your PCB can slide in to the PET preform. You must be able to move it up and down in the PET preform with a little bit resistance.
If you insert the iTilt in pure water (room temperature), the tilt should be about 20 (17-25) degrees.
Step 6: Calibrate Your Device
I mentioned previously that the device will use the angle between itself and a imaginary vertical line to estimate the gravity of your bear. To transform this tilt (angle) into gravity, we need a statistical model (3rd degree polynomial). A statistical method, called the Method of Least Squares is used to determine this model.
You will need a 3Liter measuring jar and 550 gram sugar.
The sugar wash calculator at https://www.hillbillystills.com/distilling-calculator is used to calculate a theoretical SG (Gravity) based on a certain amount of sugar in a certain amount of water.
You can use excel or suitable statistical software (and the method of least squares) to build a model (3rd degree polynomial) with SG as dependent and tilt as independent variable or you can use the build in calibration wizard. To use the calibration wizard, reset the device while in horizontal or vertical position. Access the WiFi configuration Portal and navigate to the calibration wizard (http://192.168.4.1/polynomialcalibrationstart?). Follow the steps in the wizard. We suggest you use the sample size 7.
Open the 192.168.4.1/readings? in a second tab to see the tilt.
The wizard will require you to record tilts and gravities for different amounts of sugar in your test sample. It will calculate the coefficients that you need to paste into The Configure WiFi, Cloud and Calibration page (http://192.168.4.1/wifi?)
Step 7: Build Your Dashboard
Examples of dashboards. Study the guides for each of the clouds to build your dashboards. If you publish data only every 15 minutes, you should stay in the data limitation rates of the clouds.
Cayenne charts do not work properly anymore. Some other users may have better experience with Cayenne charts.
Only 11 streams is aloud for all your devices. If you have 3 iTilts, you can publish gravity, temp, battery level to fill 3x3 streams.
I started a fermentation on 28 April, 04:00. Follow it here
Participated in the