#Get data from serial port

2 messages · Page 1 of 1 (latest)

vernal parrot
#
substitutions:
  name: esphome-web-******
  friendly_name: ESPHome Tank

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: dev

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  level: VERBOSE #makes uart stream available in esphome logstream
  baud_rate: 0 #disable logging over uart

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

wifi:
  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
  authorizer: none

# To have a "next url" for improv serial
web_server:

uart:
  baud_rate: 9600
  tx_pin: 1
  rx_pin: 3
  id: UART3
  debug:
    direction: RX
    dummy_receiver: true
    sequence:
      - lambda: |-
          auto str = std::string(bytes.begin(), bytes.end());
          float sensorL = 0;
          float sensorM1 = 0;
          
          // Parsing the sensor data "L<level>M<moisture>"
          if (sscanf(str.c_str(), "L%fM%f", &sensorL, &sensorM1) == 2){
            id(level).publish_state(sensorL);
            id(moisture).publish_state(sensorM1);
          }

sensor:
  - platform: template
    name: "Level"
    id: "level"
  - platform: template
    name: "Moisture"
    id: "moisture"