Make average of Analog pin value of esp32 module

  adc, c++

I’m trying to make as precise analog read as possible from my TDS Gravity sensor on esp32 board.
I’ve read that the module’s ADC pin is not very precise.
So I was thinking about making a average of multiple analogRead().

I made it this way

uint32_t Sum = 0;
int i = 0;
for(i=0; i<10; i++) {
  Sum+= analogRead(this->pin);
  delay(1000);
  }
this->analogValue = Sum/10;

My question here is:
Is this going to work or have I missed something important to take a care of? Maybe Float precision or something?

Source: Windows Questions C++

LEAVE A COMMENT