I've got issues with ESP32 ADC conversion. There is too much noise and interference. For example its measures are flying around for +-50 in normal conditions when the measurement should be constant. In other MCUs such as PIC16F, measures were constant (+-5) for same conditions. Can I guess it is about MCU or I've missed some settings. Here is the code too. Also, when I fully cover sensor lenses, it should give maximum value (4095) but it gives around 3700. Thanks.
void setup(){
Serial.begin(115200);
SerialBT.begin(115200);
pinMode(pin, INPUT);
analogSetAttenuation(ADC_11db); //reference 0-3.3V
analogSetWidth(12);
delay(1000);
}
void loop{
val = analogRead(pin);
... other code
}