Measuring VCC and A0 (for NTC)

Hi all,

Update:
I just read the information on the ADC documentation page:

To measure the VCC voltage, set pin: to VCC and make sure nothing is connected to the A0 pin.

Looks like I’m not able to sense VCC and use A0. Something that is slightly problematic for my use case it would be beneficial to know the VCC.

New to the forum so hopefully I’m able to follow the correct format.

Little background of my project:

  • Using a NodeMcu V3 LoLin board (ESP8266) powered at the 5v USB pin (or USB connector).
  • 50k @ 25c NTC thermistor with 100k resistor.

Sensors:

sensor:
  - platform: adc
    pin: VCC
    name: "VCC Voltage"
    update_interval: 5s
  - platform: ntc
    sensor: resistance_sensor
    calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 50kOhm
    name: NTC Temperature
  - platform: resistance
    id: resistance_sensor
    sensor: source_sensor
    reference_voltage: 1.0
    configuration: DOWNSTREAM
    resistor: 100kOhm
    name: Resistance Sensor
  - platform: adc
    id: source_sensor
    pin: A0
    update_interval: 5s

The problem is when I enable the VCC Voltage sensor my NTC sensor stops working.

With VCC voltage sensor disabled it seem I get the correct measurement:

[15:26:57][D][adc:056]: 'source_sensor': Got voltage=0.30V
[15:26:57][D][resistance:037]: 'Resistance Sensor' - Resistance 37802.8Ω
[15:26:57][D][ntc:026]: 'NTC Temperature' - Temperature: 31.4°C

When I enable the VCC sensor this stops working:

[15:35:01][D][adc:056]: 'VCC Voltage': Got voltage=2.99V
[15:35:01][D][adc:056]: 'source_sensor': Got voltage=2.99V
[15:35:01][D][resistance:037]: 'Resistance Sensor' - Resistance -158193.8Ω
[15:35:01][D][ntc:026]: 'NTC Temperature' - Temperature: nan°C

I do not fully understand why this is happening.

Additionally I have to use reference_voltage: 1.0 to get a useful temperature reading, if I leave it empty (or set it to 3.3v) it’s completely wrong.

Thank you for reading!

TheDJVG

Hello, I have same problem. Unable to use vcc and A0 as two sensors. In C++ code (without ESPHome), it can be done. Jan

Actually, the assumption of ESPhome authors that you cannot measure Vcc and voltage on A0 together is not correct and two pins should be allowed. Lets say you have two digital pins GPIO12 and GPIO13 and analog pin A0. You connect photoresistor between A0 and GPIO12 and you connect GPIO13 to A0.
Then you set both GPIO12 and GPIO13 as INPUT. Therefore nothing is connected to A0 and you can measure battery Vcc. Then you set GPIO13 INPUT_PULLUP and GPIO12 OUTPUT LOW. This way you create voltage divider from + voltage internal resistor to GPIO13 to A0 to photoresistor to ground on GPIO12 and you can measure variable voltage on A0 that depends on light intensity.
This way you can measure both Vcc on disconnected A0 and voltage on A0. Therefore I would request to enable both VCC and A0 pins in one yaml configuration for sensor.