I'm wanting to analogRead the value off a MQ-135 gas sensor. I have tired this with both an Arduino Uno and an TTGO ESP32 SX1276.
When reading the value of the sensor off the Uno, I get values approximately equal to 400 which is expected, as shown in this video. When doing the same on the TTGO, I get values close to 2000. For some reason, this person gets a similar value range as shown in this video.
What I don't understand is how these values are different when only the board is being changed. Do different boards analogRead differently?
More or less, how do I get the TTGO to read the same values as the Uno?
Below is my code for both boards. Nothing is changed between the boards:
#define sensor 2 //sensor pin
int gasLevel = 0; //int variable for gas level
void setup() {
Serial.begin(9600); //start serial comms
pinMode(sensor,INPUT); //set sensor for input
}
void loop() {
gasLevel = analogRead(sensor);
Serial.println(gasLevel);
delay(1000);
}
The following things I have tested:
- Multiple boards of both the Arduino Uno and TTGO
- Different pins, both analog and digital
I also am powering the sensor using 3.3V pin, so there is no variation in the voltage the sensor is receiving.