Create sensors from uart debug

Hi, i’m trying to read sensors data from a blade beer machine with esp32 and esphome.
I’m using this config:

esphome:
  name: blade

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

api:

logger:
  baud_rate: 115200

ota:

wifi:
  ssid: !secret ssid
  password: !secret wifipass

web_server:
  port: 80

uart:
  baud_rate: 115200
  tx_pin: 17
  rx_pin: 16
  id: UART3
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\r\n"
    sequence:
      - lambda: |-
          UARTDebug::log_string(direction, bytes);

I can see data in esphome console:

[14:21:24][D][uart_debug:158]: <<< "--KEG(TemperatureTemp):-3.1C --AMB(TemperatureTemp):23.6C --BOWL(TemperatureTemp):-4.2C --Keg Volume:5720ml --Air Pressure: 1.52bar\r\n"
[14:41:22][D][uart_debug:158]: <<< "--KEG(TemperatureTemp):-3.1C --AMB(TemperatureTemp):23.6C --BOWL(TemperatureTemp):-4.2C --Keg Volume:5720ml --Air Pressure: 1.52bar\r\n"
[14:53:12][D][uart_debug:158]: <<< "--KEG(TemperatureTemp):-3.1C --AMB(TemperatureTemp):23.6C --BOWL(TemperatureTemp):-4.2C --Keg Volume:5720ml --Air Pressure: 1.52bar\r\n"

From this data i want to create 5 sensors: Keg Temperature, Ambient Temperature, Bowl Temperature, Keg Volume and Air Pressure but i have no idea how to extract only those values from the log.
Thanks.

Take a look at this post for a go-by. The sscanf() format string would be something like below to read in 5 numeric float values from each string.

"--KEG(TemperatureTemp):%fC --AMB(TemperatureTemp):%fC --BOWL(TemperatureTemp):%fC --Keg Volume:%fml --Air Pressure: %f

1 Like

Thanks a lot.

1 Like