Gravity in the cloud

Roman Eremin
Nov 14, 2017 · 4 min read

How to connect you Tilt hydrometer to the cloud control panel using Raspberry Pi and Python.

When beer is fermenting, you should monitor its gravity and temperature daily. It is easy to forget to do so, and impossible if you are away.

After some googling, I found several solutions for automated gravity monitoring. One of them, with very clever concept, called Tilt. Tilt is floating in your beer and is measuring its own tilt angle. This angle depends on liquid’s density, and therefore can measure gravity of the fermenting beer.

Image for post
Image for post

Tilt comes with a mobile app, that connects to it and can post data to any web service. The problem is that you need to be not far from Tilt to be able to do so. There is also a Raspberry Pi program that works with Tilt.

I’m already using Raspberry Pi to monitor cellar temperature, and a cloud control panel service If Tilt can talk to Raspberry Pi, it should be possible connect cloud4rpi to it. Tilt is using a wireless protocol, so you’ll need Raspberry Pi with a wireless chip (Rasbperry Pi 3 or Zero W).

Luckily, there is a GitHub repo for Tilt software with some samples. Looking at you can see that Tilt looks to others as BLE iBeacon, with “Color” coded in UUID, and temperature and gravity are in major and minor bytes.

Their sample code is for Node.js, and I have a Python control program based on cloud4rpi template

So I need to get Tilt data in Python. After some googling, I found — Python iBeacon scanner. This is a program, not a library, so I modified it to return a dictionary instead of string. And I also wrote Tilt-specific module to get color, temperature and gravity of the first Tilt found (I have only one), and a simple test program to check if it can see my Tilt:

Running it on my rpi-brewery:

Image for post
Image for post

It works! Now I can plug it to my control program. I already have a python program connected to, but let me show how to do so from the scratch.

First, sign in to, then create a new device:

Image for post
Image for post

You will be given a device token and installation instructions. For Raspberry Pi follow instructions here — make sure your system is up-to-date:

sudo apt update && sudo apt upgrade

Install prerequisites:

sudo apt install git python python-pip

Install cloud4rpi python packages:

sudo pip install cloud4rpi

then get a sample python app for Raspberry Pi (into control folder):

git clone controlcd control

modify — specify your device token in the line


Remove unnecessary entries from device variable declarations, leave only CPUTemp to test device connection:

now do a test run:

sudo python

If everything is ok, your device page will be immediately updated:

Image for post
Image for post

Now we need to modify to read and report Tilt’s color, temperature and gravity. Result looks like this:

Now run it manually to see if it works:

sudo python

If everything is good, you will see your variables online:

Image for post
Image for post

To run at system startup, install it as a service. Cloud4rpi provides an install script to do so. I’ve included it into my repo. To install as a service, run

sudo bash

Now you can start|stop|restart this service by running command

sudo systemctl start cloud4rpi.service

Service keeps its previous state on power up, so if it was running, it will be running after reboot or power loss.

This is it, now I have my Tilt parameters being sent to the cloud, so I can set up a nice cloud control panel for it. Go to and create new control panel, add widget and select <your device>/Gravity and Beer Temp as data source. Now I can monitor what’s going on even if i’m away from home:

Image for post
Image for post

Yes, it is 40C, but I just put Tilt into a glass of hot water to test graphs, don’t worry.

The code I copied and wrote is available here It is far from perfect, it works only with a single Tilt, it doesn’t care about “Color” of the device, whatever it means, and I’m not a Python guy at all, so fixes, suggestions or forks are welcome!

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store