Return mean of observations for a given sample time
I have this:

int readElSens() {
  long sum = 0;
  int n = 0;
  long start_time = millis();
  while(millis() - start_time &lt; 400) { 
    sum += analogRead(ELSENS_PIN);
    n++;
  }
  return sum / n;
}