I have an esp32 WROOM-32 connected to a MQ9 gas sensor to GPIO35. Both are powered separately. measuring the output from the sensor directly using a multi-meter shows a constant reading of 0.145 V but the readings on esp32 shows 3.3V and if fluctuates too much.
The circuit: MQ-9 AO -> voltage divider (using 1k and 2.2k ohm) -> ESP32 (GPIO35)
Sample Code:
void setup() {
Serial.begin(9600);
analogReadResolution(11);
analogSetWidth(11); // 11Bit resolution
analogSetAttenuation(ADC_0db);
}
void loop() {
int ADC = analogRead(35);
float volt = (ADC * 3.3) / 2045;
Serial.print("Volt : ");
Serial.println(volt);
Serial.print("Analog : ");
Serial.println(ADC);
Serial.println("");
delay(1000);
}
