Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By schufti
#49824 what is not clear for me is:

what is the reference voltage
a) when measuring the Vcc
b) when measuring on A0

especially for b) there is some cryptical hint that a setting for reference Vcc (byte x in the firmware) influences the measurement.

And the there is some unclear situation on the resolution:
if I read (cas a) 3100 is it 3.1V or 3100 * 1/1024 Volts?
the same question for b...

and: I read that the maximum returned for ext, measurement is 1024, but this is 1 more than 10bit

rgds,
schufti
User avatar
By martinayotte
#49828 I must admit that for VCC, I've never played with it.
But for A0 input, 1V should give 1023.

(BTW, the 1024 number in Espressif datasheet is probably a typo that they've never fixed since 10bits is 0-1023, or if value 1024 really exist, then it would means "overflow")
User avatar
By schufti
#49829 and did you check what is programmed for the "vcc" in the firmware?
What is the influence of this value wit stable supply?
What if actual vcc differs from this programmed value?

This whole adc chapter is even more dilledantic as the general espressif documentation.

rgds,
schufti
User avatar
By martinayotte
#49832 I don't know the details, but here is what we can find in ArduinoESP platform in the file esp8266/2.3.0/cores/esp8266/core_esp8266_phy.c :

Code: Select all    // vdd33_const
    // the voltage of PA_VDD
    // x=0xff: it can measure VDD33,
    // 18<=x<=36: use input voltage,
    // the value is voltage*10, 33 is 3.3V, 30 is 3.0V,
    // x<18 or x>36: default voltage is 3.3V
    //
    // the value of this byte depend from the TOUT pin usage (1 or 2):
    // 1)
    // analogRead function (system_adc_read()):
    // is only available when wire TOUT pin17 to external circuitry, Input Voltage Range restricted to 0 ~ 1.0V.
    // For this function the vdd33_const must be set as real power voltage of VDD3P3 pin 3 and 4
    // The range of operating voltage of ESP8266 is 1.8V~3.6V,the unit of vdd33_const is 0.1V,so effective value range of vdd33_const is [18,36]
    // 2)
    // getVcc function (system_get_vdd33):
    // is only available when TOUT pin17 is suspended (floating), this function measure the power voltage of VDD3P3 pin 3 and 4
    // For this function the vdd33_const must be set to 255 (0xFF).
    [107] = 33,


and this famous Byte 107 can be switched from a sketch, but only as global call with the following macro, not inside setup() or loop() using Esp.h :

Code: Select allenum ADCMode {
    ADC_TOUT = 33,
    ADC_TOUT_3V3 = 33,
    ADC_VCC = 255,
    ADC_VDD = 255
};

#define ADC_MODE(mode) int __get_adc_mode(void) { return (int) (mode); }


So, to my understanding, this Bytes 107 only switch the mode, it is not used as a reference level.