I recently bought new electric toothbrushes. The old ones had a dedicated timer display (separate box with 7-segment lcd) that displayed the brushed time. This feature was missing with the new toothbrush, so i tried to replicate it.
The new ones have Bluetooth and you find a handful of projects on the web where people are trying to get information from the brush.
To sort this out, i needed to understand a lot about bluetooth low energy:
BLE has 2 means to transmit data:
unsolicited and requested.
The toothbrush is using both, but not all data is transmitted in both means.
The unsolicited data is sent ~ every second. It contains several bytes of information, e.g. the time, the quadrant of your teeth, the brushing-mode, etc.
The requested data is sorted by UUIDs. Every UUID is usually one datapoint, e.g. time or batery SoC.
If i have understood the ble stuff correctly, the client (–> ESPhome) can not ony ask for the information on requested data, but as well subscribe to updates on this. If the value changes, the server (–> toothbrush) can tell the client that the data has changed.
Anyway: Requested data sensors (with “ble_client” on ESPhome) did not work. Unsolicited data (“esp32_ble_tracker”) did work.
TL;DR
The code above spawns several sensors in home assistant that show the brushing time, brush mode, quadrant and brush state for each brush.
I put these on a separate dashboard in home assistand and used an old smartphone with the HA-app to show just this dashboard to replicate the functionality of the hw-timer.
Hey @AndreasJH ,
since i used ESPHome, what you see above is (nearly) all my sourcecode. Only my Wifi-credentials are missing
@brammolenaar ,
if i found this correctly, you can use data.data[4] for pressure information. Since i did not need this, i am not sure if you get some analogue value or just digital “pressure too high” info.
@fkzle Could you be even more spesific, did you just insert the code and compiled it in ESPHome and uploaded to a Nodemcu?
How did you get the Bluetooth mac?
@Hellis81
I don’t know what the original source for the packet format is, but you find dozens of implementations online if you search for “oralb toothbrush github” or something like that. One example is:
AFAIK, the packet looks the same on all brush types.
You get:
information if brush is running
mode
time
pressure
quadrant you should be brushing.
@gulllfrode
You need to use a board with an ESP32, because the 8266 lacks bluetooth functionality.
The mac addresses were shown in the log of esphome.
IIRC you need to define a “ble_client” and set the log level to debug?
Details can be found here: BLE Client — ESPHome
(bottom of the page).
Thank you very much for these! But I need your help now, because I can not figure it out. How can we create a sensor that will show daily brush time? History stats show to much time if I select on-off time.