Differents boards, differents reads of ADC !?!?!?!?

steve-cr
Posts: 2
Joined: Mon Apr 08, 2019 8:07 am

Differents boards, differents reads of ADC !?!?!?!?

Postby steve-cr » Mon Apr 08, 2019 8:25 am

I made a simple code to analog read on GPIO32 and GPIO33.
Well, all is ok... BUT, when I change my ESP32 DEVKIT V1 with another one, values are different.
I changed again with another DEVKIT and other values....
Three ESP32 DEVKIT V1 with three different reads on GPIO32 and GPIO33 !!!

I checked the voltage on pin 3v3: one has 3,29, the other one has 3,28 and the last has 3,31.
This is normal for AMS1117 (min. 3,20 and max 3,99 V).
I tryed with USB power supply and with VIN power supply (8, 9 and 11.5 Volt): nothing change.

Can you tell me WHY ?

Code: Select all

int x = 0;
int y = 0;

void setup() {
  Serial.begin(115200);
  adcAttachPin(32);
}

void loop() {
  for (int i = 0; i <= 255; i++) {
    x =  analogRead(32);
    y = y + x;
  }
  y = y / 255;
  Serial.println(y);
  delay (200);
}

username
Posts: 477
Joined: Thu May 03, 2018 1:18 pm

Re: Differents boards, differents reads of ADC !?!?!?!?

Postby username » Mon Apr 08, 2019 11:20 am

Describe what your measuring with your A/D pin and anything attached to that pin.

steve-cr
Posts: 2
Joined: Mon Apr 08, 2019 8:07 am

Re: Differents boards, differents reads of ADC !?!?!?!?

Postby steve-cr » Mon Apr 08, 2019 10:59 pm

I measuring NTC resistance.
But I can measure everything: NTC, carbon resistor, PT100...
The problem is that if with ESP32 No.1 I read, for example, 2570, with ESP32 No.2 I read 2640 and with ESP32 No.3 I read 2465.....

I read that ESP32 needs calibration, one by one, but for me is impossible to think this

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Differents boards, differents reads of ADC !?!?!?!?

Postby fly135 » Tue Apr 09, 2019 1:00 am

steve-cr wrote:
Mon Apr 08, 2019 10:59 pm
I measuring NTC resistance.
But I can measure everything: NTC, carbon resistor, PT100...
The problem is that if with ESP32 No.1 I read, for example, 2570, with ESP32 No.2 I read 2640 and with ESP32 No.3 I read 2465.....

I read that ESP32 needs calibration, one by one, but for me is impossible to think this
I haven't messed with it but the docs talk about a calibration API.

https://docs.espressif.com/projects/esp ... s/adc.html

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Differents boards, differents reads of ADC !?!?!?!?

Postby WiFive » Tue Apr 09, 2019 1:05 am

https://github.com/espressif/esp-idf/issues/164

There are lots of complaints about adc. Your results are within +-5% without calibration which is probably expected from average hardware layout.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Differents boards, differents reads of ADC !?!?!?!?

Postby ESP_Angus » Wed Apr 10, 2019 12:10 am

Using the linked calibrated ADC API will help quite a bit, as reference voltage is calibrated in factory and written to efuse.

Unfortunately I don't think this API is wrapped into the Arduino analogRead() functions yet, so you'll need to call ESP-IDF APIs (you can do this from an Arduino sketch, however).

Who is online

Users browsing this forum: No registered users and 67 guests