I connected the MQ sensor to jumper wires, and soldered one half of its pins together for Vcc(yellow wire), and on the other side I soldered the opposite two together for the output(orange wire), while the last pin was its GND(purple wire).
Here's the code I uploaded to the ESP:
void setup() {
Serial.begin(115200);
}
void loop() {
delay(500);
Serial.println(analogRead(A0));
}
But it only returned 1024, which meant the sensor's output voltage was equal to its input voltage, which means something is wrong. When removing the pin from the breadboard, the analog reading fluctuated, but returned to 1024. After checking the ESP8266 Arduino Core website(https://arduino-esp8266.readthedocs.io/en/latest/reference.html#analog-input), I found that the ADC pin can only handle 1V. I think the ADC on the chip may be broken, because I connected it to 5V initially, before changing it to 3.3V. Luckily, I have a spare. I'll have to use a voltage divider.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.