ADC reporting lower voltage then expected

I have a NodeMCU board with a TMP36 connected to pin A0

configuration:

sensor:
  - platform: adc
    pin: A0
    name: "Family Room Temperature"
    update_interval: 60s

Hooking up a Voltmeter to the TMP36 I am getting 0.73v, but ESPHome is reporting a lower voltage

[09:38:37][D][adc:056]: 'Family Room Temperature': Got voltage=0.23V
[09:38:37][D][sensor:092]: 'Family Room Temperature': Sending state 0.22852 V with 2 decimals of accuracy

It seems the board will accept an input voltage of 3.3 but the documentation on page 23 says when using an external circuit that A0 will only accept 0.0v-1.0v

Currently, though using my setup, it seems if I multiply the result from ESPHome by 1/3.3 I get a value that is around what I’m expecting.

It depends on the board implementation. The ESP8266 chip has a specified ADC input of 1v max. Nearly all ESP8266 development boards have a voltage divider to take 3.3v in and present 1v to the ADC input of the chip. Thus scaling up by 3.3x is required to get the actual voltage at the board input. Most of these dividers don’t use precision resistors either so it may be slightly more or less than 3.3. When calibrating my last battery voltage sensor I found I had to multiply by 3.25. Looks like yours is closer to 3.195x.

As Tom says the output is scaled down.

If you read the ESPHome about ADC then you see this:

Note
This component prints the voltage as seen by the chip pin. On the ESP8266, this is always 0.0V to 1.0V Some development boards like the Wemos D1 mini include external voltage divider circuitry to scale down a 3.3V input signal to the chip-internal 1.0V. If your board has this circuitry, add a multiply filter to get correct values:

sensor:
  - platform: adc
    # ...
    filters:
      - multiply: 3.3

@tom_l @Hellis81 Thank you both for your quick responses!

I see where I made the mistake, the pdf was for the ESP8266 and not the NodeMCU board I’m using.

Thanks for this. How did you do that? Multimeter on the battery and then compare to board readings?

Yes exactly that.

You can also use the calibrate linear filter for increased accuracy (the ESP ADC is non linear at the extremes of its range). Make a number of measurements across the input range noting the values measured by an accurate meter and the ADC.

1 Like