2

my battery is lifepo4 3.32v currently. then i set

adc1_config_width(ADC_WIDTH_11Bit);

adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11); //set reference voltage So if i applied 3.9v then i will se 2047 in monitor. Code for measyre adc value

for (int i = 0; i < 500; i++)
    {
        sum += adc1_get_voltage(ADC1_CHANNEL_0);
        delayMicroseconds(1000);
    }
    // calculate the voltage
    voltage = sum / (float)500;

But when i apply lifepo4 (3.2v) to GPIO36, i always see 2047? where is the problem?

Quang Minh Lê
  • 169
  • 1
  • 2
  • 13
  • 1
    Is the ESP powered directly from that battery? – JimmyB Jul 03 '19 at 14:22
  • i powered by usb cable and use GPIO36 to measure battery. but later it's will power up directly by battery. for example the lifepo4 max voltage is 3.6 so the max scale at 11db is 3.6? i also ask at other forum, they recommeded me to always use voltage divider. [link](https://github.com/espressif/arduino-esp32/issues/2957#issuecomment-508133696) – Quang Minh Lê Jul 04 '19 at 01:55

1 Answers1

1

From https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/adc.html

At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.

Check VDD_A.

Piglet
  • 27,501
  • 3
  • 20
  • 43
  • is VDD_A a voltage applied to esp32 board, since i power up by usb cable or Vin, it's always 3.3v ? – Quang Minh Lê Jul 04 '19 at 01:48
  • @QuangMinhLê No VDD_A is one of the chips pins. But if your board is powered by a 3.3V voltage regulator this pin is most likely connected to those 3.3V. Hence you cannot measure more than 3.3Vs – Piglet Jul 08 '19 at 14:43