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:
1 Like
nickrout
(Nick Rout)
September 13, 2022, 10:35pm
2
Wish i was still brewing so I could play with this
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.
1 Like
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 )
the only problem i had was not a math problem, but a unicode problem. so i rewrote all special characters and… 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!
2 Likes
nickrout
(Nick Rout)
September 14, 2022, 9:09pm
4
Yes that formula is much more complex than the one I found. And I assume more accurate
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.
1 Like
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?
1 Like
nickrout
(Nick Rout)
September 24, 2022, 11:45am
6
Try reading the references he gave.
uSlackr
(Greg Martin)
June 23, 2024, 12:33am
8
The tilt comes in colors. Each one of a similar color shares a BLE address
uSlackr
(Greg Martin)
June 23, 2024, 6:57pm
9
Question - the docs provide the UUIDs in this format:
Purple: A495BB40C5B14B44B5121370F02D74DE
How do I convert it to:
DE742DF0-7013-12B5-444B-B1C540BB95A4
like is used in the code?
I’ve figured it out. The former UUID is the reverse (by pairs) of the latter. There is on a single character difference in each. Here’s the full list:
Red: A495BB10C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C510BB95A4
Green: A495BB20C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C520BB95A4
Black: A495BB30C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C530BB95A4
Purple: A495BB40C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C540BB95A4
Orange: A495BB50C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C550BB95A4
Blue: A495BB60C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C560BB95A4
Yellow: A495BB70C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C570BB95A4
Pink: A495BB80C5B14B44B5121370F02D74DE DE742DF0-7013-12B5-4448-B1C580BB95A4