Tilt Hydrometer for fermentation control

Here my ESPHome configuration for the Tilt Hydrometer:

esphome:
  name: 182-tilt
  libraries:
    - "ESP32 BLE Arduino"


esp32:
  board: nodemcu-32s
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

web_server:


ota:
  password: "***"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
 
captive_portal:
    
esp32_ble_tracker:
  on_ble_advertise:
      then:
        - lambda: |-
           if(x.get_ibeacon().has_value()) {
              auto ibeacon = x.get_ibeacon().value();
              if(strcmp(ibeacon.get_uuid().to_string().c_str(), "DE742DF0-7013-12B5-444B-B1C540BB95A4") == 0) {
                id(purple_temperature_fahrenheit).publish_state(ibeacon.get_major());
                id(purple_gravity).publish_state(ibeacon.get_minor());
              }else
              if(strcmp(ibeacon.get_uuid().to_string().c_str(), "DE742DF0-7013-12B5-444B-B1C530BB95A4") == 0) {
                id(black_temperature_fahrenheit).publish_state(ibeacon.get_major());
                id(black_gravity).publish_state(ibeacon.get_minor());
              }else{
                ESP_LOGD("ble_adv", "iBeacon uuid: %s",ibeacon.get_uuid().to_string().c_str());
              }
            }
sensor:
  # purple
  - platform: template
    id: purple_temperature_fahrenheit
    name: "Purple temperature fahrenheit"
    update_interval: never
    unit_of_measurement: "°F"
  - platform: template
    id: purple_gravity
    name: "Purple gravity"
    update_interval: never
    unit_of_measurement: ""
  - platform: template
    name: Purple Temperature_C
    id: purple_temperature_celsius
    lambda: return (id(purple_temperature_fahrenheit).state-32) * .5556;
    update_interval: 5s
  # black
  - platform: template
    id: black_temperature_fahrenheit
    name: "Black temperature fahrenheit"
    update_interval: never
    unit_of_measurement: "°F"
  - platform: template
    id: black_gravity
    name: "Black gravity"
    update_interval: never
    unit_of_measurement: ""
  - platform: template
    name: Black Temperature_C
    id: black_temperature_celsius
    lambda: return (id(black_temperature_fahrenheit).state-32) * .5556;
    update_interval: 5s

# https://hobbybrauer.de/forum/wiki/doku.php/konvertierung_sg_plato

I did not jet manage to get the gravity in °Plato, the formula is known, but still fighting with the pow() function which does not compile.

If an unknown Tilt Sensor (other than black or purple) is nearby, the uuid will be printed to the log.

I use the temperature value as input to a smart thermostat, which then toggles a Shelly to power a heating matt. Using Kveik gives me a perfect temperature control without cooling.

Cheers!

References used:

Wish i was still brewing so I could play with this :slight_smile:

I hadn’t heard of degrees plato before, but looking at this Plato gravity scale | Craft Beer & Brewing the formula is simple to do. In HA use a template

{{ ((states('sensor.black_gravity') - 1) * 250) round (1) }}

That is their formula simplified.

No doubt easy in a lambda as well, but my c++ is not strong. It does not need pow() though.

Thank you very much for your input. For me, the returned value does not match the desired conversion, but:

you motivated me to think over it again!!

I again took the formula from Konvertierung SG/°Plato - Hobbybrauer Wiki

using pow() instead of ^ gave me build errors last night. (02:00 is perhaps not the greatest time for math :wink: )

the only problem i had was not a math problem, but a unicode problem. so i rewrote all special characters and… :tada: it works!

 - platform: template
    name: Black Plato
    id: black_plato
    lambda: |-
      auto sg=id(black_gravity).state /1000;
      return (-1 * 616.868) + (1111.14 * sg) - (630.272 * pow(sg,2)) + (135.997 * pow(sg,3));
    update_interval: 5s
    unit_of_measurement: "°P"

Again, without your input, i would not have revisited the problem i such a short time. Thanks!

Start brewing, its Fun! all you need is a Kettle, a bag, some grains, some hops and a yeast.

Cheers!

1 Like

Yes that formula is much more complex than the one I found. And I assume more accurate :slight_smile:

The one I found is accurate -ish for smaller values, eg for sg=1.048 mine gives 12 plato, yours gives 11.9.

For sg=1.148 mine gives plato = 37, yours 33.7.

Wow…
You really did this?

I don’t own a tilt so I don’t know how it works - does it do BLE broadcasts? No need to pair it?

Also in your sketch - are the BLE addresses particular to the specific tilts and need to be detected/changed for each tilt?

Try reading the references he gave.