Esphome UART reading Data

Hello,
I have a little problem with the decimals in uart. I need at least 1 or 2 decimal places. What is wrong here? I can’t get any decimal places. I’m a beginner and can’t find the error.

uart:
  id: uart_bus
  tx_pin: GPIO2
  rx_pin: GPIO14
  baud_rate: 9600
  stop_bits: 1
  data_bits: 8
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\r\n"
    sequence:
    - lambda: |-
       UARTDebug::log_string(direction, bytes);
         int val1=1;
         std::string str(bytes.begin(), bytes.end());

       if (sscanf(str.c_str(), "%d", &val1) == 1 ) {
       id(voltage).publish_state(val1);
          }

It ist connected to the XY-DJ DC 6-40V Monitor/Switch.

I think you are scanning for and returning an integer with %d.

You may need to use %f. Not sure if you need other adjustments. I’m pretty rooky with cpp too.