ESPHOME ADC setup

I’m new to ESPHome and YAML. I’m trying to build a pool filter pressure monitor using an ESP32. I’m able to customize and write to my ESP32 using a mix of Konnected base yaml and some of my own. I can not get my ADC sensor to compile w/o errors. I get “preparation failed” and the following errors…

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf @ 3.40406.240122 (4.4.6)
  • tool-cmake @ 3.16.9
  • tool-ninja @ 1.10.2
  • toolchain-esp32ulp @ 2.35.0-20220830
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    Reading CMake configuration…
    Dependency Graph
    |-- noise-c @ 0.1.4
    |-- ArduinoJson @ 6.18.5
    |-- Improv @ 1.2.3
    Linking .pioenvs/alarm-panel-pro-2cde88/firmware.elf
    /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld: .pioenvs/alarm-panel-pro-2cde88/src/main.o:(.literal._Z5setupv+0x14c): undefined reference to `vtable for esphome::adc::ADCSensor’
sensor:
  - platform: adc
    name: "Filter Pressure"
    pin: GPIO35
    id: pressure
    update_interval: 30s
    unit_of_measurement: "PSI"
    accuracy_decimals: 1
    attenuation: 11db
    filters:
      - calibrate_linear:
        - 0.5 -> 0.0
        - 4.0 -> 20.0

@Steve_Campbell
Some questions…

  • What is the name of your pressure sensor
  • What is the output signal of your sensor
  • How is the sensor connected to the ESP32

Also - post ALL your yaml. It’s unlikely your simple sensor definition is causing compile errors.

it’s a simple 5v 3 wire transducer (e.g. not a chip type sensor) that will go thru a voltage divider. 0.5 V = 0psi, 4.5v = 30 PSI.

@zoogara Thanks…

substitutions:
  name: alarm-panel-pro-2cde88
  friendly_name: SoupPoolMonitor
packages:
#  konnected.alarm-panel-pro-esp32-wifi: github://konnected-io/konnected-esphome/alarm-panel-pro-esp32-wifi.yaml@master
  remote_package:
    url: http://github.com/konnected-io/konnected-esphome
    ref: master
    refresh: 5min
    files:
  
      # Required packages:
      - packages/alarm-panel-esp32-base.yaml
      - packages/status-led.yaml      

      # Keep either the wifi.yaml or ethernet.yaml package below (not both)
      - packages/wifi.yaml

      # Default input/output configuration
      - packages/alarm-panel/zone1.yaml
      - packages/alarm-panel/zone2.yaml
      - packages/alarm-panel/zone3.yaml
      - packages/alarm-panel/zone4.yaml
      - packages/alarm-panel/zone5.yaml
      - packages/alarm-panel/zone6.yaml
      # - packages/alarm-panel/zone9.yaml     

binary_sensor:
  - id: !extend zone1
    device_class: tamper
    name: Tamper Switch 
 
  - id: !extend zone2
    device_class: motion
    name: Motion Detector

  - id: !extend zone3
    device_class: light
    name: Light Switch 1

  - id: !extend zone4
    device_class: light
    name: Light Switch 2

  - id: !extend zone5
    device_class: light
    name: Light Switch 3

  - id: !extend zone6
    device_class: light
    name: Light Switch 4

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
  area: Pool

esp32:
    board: nodemcu-32s  

api:
  encryption:
    key: <redacted>

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

#additional components
web_server:
logger:
ota:

text_sensor:
  # Formatted updtime output
  - platform: template
    name: UptimeF
    update_interval: 1s
    lambda: |-
      auto s = millis() / 1000;
      return str_snprintf("%02d:%02d:%02d:%02d", 11, s / 86400, s / 3600 % 24, s / 60 % 60, s % 60);
    icon: mdi:clock-start

sensor:
  - platform: adc
    name: "Filter Pressure"
    pin: GPIO35
    id: pressure
    update_interval: 30s
    unit_of_measurement: "PSI"
    accuracy_decimals: 1
    attenuation: 11db
    filters:
      - calibrate_linear:
        - 0.5 -> 0.0
        - 4.0 -> 20.0type or paste code here

@RH_Dreambox and I guess I’m a little confused… If I’m applying an analog input signal to any of the ADC inputs, can’t I just declare or type a sensor as “adc”. New to ESP but based on a lot of examples of pressure sensors - it seems it should be straight forward.

@Steve_Campbell
Have you connected the sensor to a voltage divider to lower the input signal to the voltage that the ESP32 can handle, i.e. max 3.3V ?
Then the lowest input signal should be slightly lower than 0.5V.
The calibration should then be…

  • 0.X → 0.0
  • 3.3 → 20.0

And does the error message stop if you remove the sensor code?
If not, there is a problem with the rest of your code, the one above the heading “esphome:”.

1 Like

FYI: I removed the Konnected bit and wrote my own ESP from scratch and learned a lot. The error went away :). I have a working ESP32 with 4 relays and now just need to get the voltage divider completed and actual pressure sensor connected instead of potentiometer. Thanks.

1 Like