Esp32 devkit V1 Issue

I have connected up an esp32 devkit V1 to home assistant via ESPhome. I want to read an analogue voltage from GPIO32. I’m currently using the following yaml file:

  name: main-power
  platform: ESP32
  board: esp32doit-devkit-v1

 # board: nodemcu-32s

# Enable logging

# Enable Home Assistant API

  password: "224c14826fd2a8216b926efc1f0385b5"

  ssid: "The Manor"
  password: "chubster"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Main-Power Fallback Hotspot"
    password: "5py8EBGKWeWk"


  - platform: adc
    pin: GPIO32
    name: "Living Room Brightness"
    update_interval: 0.5s

When I view the output in the node terminal, I can only get voltages from 0.075V - 1.057V. Even when I short the pin to ground, I still cant get a value of 0V in the readout. I should be getting a range from 0-3.3V. Just to make sure I didn’t have damaged hardware, I used the arduino IDE to load a test sketch and I was able get the full range from the ADC.

Am I doing something stupid?

What is connected to GPIO32? A wiring diagram may help :slight_smile:

Nothing at the moment, I’m just using the 3v3 and GND to short the pin out for a quick test.

You need to set the attenuation value to get the full range:

  - platform: adc
    pin: GPIO32
    attenuation: 11db
    name: "Living Room Brightness"
    update_interval: 0.5s

Try setting the attenuation to auto.

  - platform: adc
    pin: GPIO32
    name: "Living Room Brightness"
    update_interval: 0.5s
    attenuation: auto

On the ESP32 the voltage measured with the ADC caps out at ~1.1V by default as the sensing range (attenuation of the ADC) is set to 0db by default.

Oooh. When was the auto option introduced?

Or did I just miss that from the start as it is not listed as a valid option in the docs:

Screenshot 2022-02-14 at 10-26-41 Analog To Digital Sensor

Though it is mentioned further down the page:

Screenshot 2022-02-14 at 10-27-43 Analog To Digital Sensor

You didn’t, it showed up a couple of cycles ago.

1 Like

Neat. I’ll put in a PR to have it included in the valid options.

EDIT: I’m blind. Someone has already added it:

Screenshot 2022-02-14 at 10-37-05 Analog To Digital Sensor

1 Like