Author Topic: sometimes 6 percent difference in pure water  (Read 12368 times)

elbarto

  • Newbie
  • *
  • Posts: 2
sometimes 6 percent difference in pure water
« on: October 24, 2019, 12:42:44 PM »
Hello,
is it normal, that i have sometimes a difference of 6 percent in pure water?
Using esp32 with 1.1v sensor. (Meassured also 1.1v pin of the esp)
Burried inside earth the difference is up to 10 percent and more. :(
I attached a list of my values.

« Last Edit: October 25, 2019, 08:26:19 PM by elbarto »

pinolec

  • Administrator
  • Jr. Member
  • *****
  • Posts: 99
Re: sometimes 6 percent difference in pure water
« Reply #1 on: October 28, 2019, 02:24:36 PM »
Hi,

I have just answered your email but for future generations  ;)
Espressif explains how to deal with the noisy ADC here: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/adc.html

Here is the quote from Espressif:
Quote
The ESP32 ADC can be sensitive to noise leading to large discrepancies in ADC readings. To minimize noise, users may connect a 0.1uF capacitor to the ADC input pad in use. Multisampling may also be used to further mitigate the effects of noise.

regards,
Piotr

elbarto

  • Newbie
  • *
  • Posts: 2
Re: sometimes 6 percent difference in pure water
« Reply #2 on: October 30, 2019, 06:29:11 PM »
Still the same problem with capacitor between analog input and sensor cable. Trying esp8266 board now.
...
With the esp8266 the values are stable now. But i see that the A0 pin has only 3.3V and the sensor 1.1v...i hope that this does not damage the sensor.
 
« Last Edit: October 30, 2019, 11:02:12 PM by elbarto »

pinolec

  • Administrator
  • Jr. Member
  • *****
  • Posts: 99
Re: sometimes 6 percent difference in pure water
« Reply #3 on: February 24, 2020, 03:01:07 PM »
To get decent repeatability out of ESP32 ADC use code below as the starting point. The capacitor is also a must.

Code: [Select]
/*  Analog read for ESP32
    To minimize the noise connect 100nF capacitor between ADC pin and GND as per https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/adc.html#minimizing-noise
    Code below multisample ADC on sensPin and average the results.
    The result is printed on Serial port
*/

const int sensPin = 34;
int sensValue = 0;


void setup() {
  Serial.begin(115200);
  delay(1000);
  analogReadResolution(10); //set ADC resolution to 10bits
}

void loop() {
  // Reading sensor value
  sensValue = AvgAnalogRead(sensPin, 1024); //Average 1024 reads to make good readings
  Serial.print((sensValue*3.3)/1024);//convert to Volts
  Serial.print("V ADC:");
  Serial.println(sensValue);
  delay(500);
}

int AvgAnalogRead(int adcToRead, int samples){

  long x=0;
  int i = samples;

  while(i){
    x+= analogRead(adcToRead);
    i--;
  }
  return (x/samples);
}