Measure ADC VREF

User avatar
dg9ngf
Posts: 65
Joined: Mon Sep 16, 2019 6:49 pm
Location: Germany
Contact:

Measure ADC VREF

Postby dg9ngf » Mon Dec 01, 2025 9:18 pm

Hello,

I'm trying to use the ESP32 ADC again and the result was a bit off. I measured 0.73 V and the code result after calibration is 0.77 V. For the temperature sensor I'm using (MCP9700B) that makes around 4 °C more than actual. While the sensor's purpose is to detect overheating of the device, I'd still like to improve the readings.

There are numerous complex guides out there that imply all sorts of special hardware which I haven't got in my existing design. So I need to do with the ADC pin alone. The temperature sensor is meant to be connected to the ADC directly, no additional circuitry needed, and so I have none.

At one point, I'm passing a VREF of 1100 into the code.

Code: Select all

#if ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
	if (!calibrated)
	{
		ESP_LOGI(TAG, "calibration scheme version is %s", "Line Fitting");
		adc_cali_line_fitting_config_t cali_config =
		{
			.unit_id = TEMP_ADC_UNIT,
			.atten = ADC_ATTEN_DB_12,
			.bitwidth = ADC_BITWIDTH_DEFAULT,
			.default_vref = 1100,   // Just a guess to make it work
		};
		ret = adc_cali_create_scheme_line_fitting(&cali_config, &handle);
		if (ret == ESP_OK)
		{
			calibrated = true;
		}
	}
#endif
This is from some random example I found in the official documentation I guess, not sure. It's way too complicated to remember that. If calibration is there (and in the end, the calibrated variable is true, so I guess it's active), I expect it to just work and not to still be wrong. Or are they not working carefully in the fab?

Anyway, the docs say that this VREF can be anywhere between 1000 and 1200 mV. How can I find out what it is? Where do I have to point my multimeter to measure it and put the correct value in the code?

Interestingly, it doesn't even matter what value I put there. From 1000 to 1200 the measurement result is always the same. Would I be better off just subtracting 0.04 V from the calibrated reading and leave it there?

I'm using ESP-IDF with PlatformIO on an ESP32-WROOM-32UE module on a custom PCB.

Who is online

Users browsing this forum: Qwantbot and 2 guests