I am working on project with a very simple circuit and a MQ2 gas sensor. I am using the analogReadSerial example code, no changes has been made to the code at all. I done all of my coding and my circuit setup and I realized the gas sensor produce a very high sensor value, even before the sensor detects any gas at all. I am having 900++ sensor value and by default the gas sensor should be producing value between 100 - 300++. Since this is an analog device, the value can only be output between 0 - 1024. Please help me, how do I reduce the value?
The code:
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
The circuit:
Note: Due to I have insufficient fritzing component, in which I don't have MQ2, this diagram doesn't reflect on what my actual circuit looks like. I am using MQ2, 3v3 pin is connected to VCC, GND to GND, A0 to A0.
I am not sure. Fyi, I am a college student working on this project and I am new to this. We purchased a devkit with multiple components in it, and each of us have MQ2 gas sensor and NodeMCU. Our NodeMCU doesn't have 5V pin, so we connected to 3v3 pins. Some of us managed to do it correctly but I am not sure why, since we are all following the same steps. That's why I think it is ok to connect MQ2 to 3v3.
The NodeMCU is powered by 5 V. Usually by the USB jack.
Unlike Arduinox, the "Vin" pin on the NodeMCU is actually there to either supply 5 V, or (depending on version) provide a modest 5 V supply for some other components. It should not be connected to greater than 5 Volts.
Do you mean that Vin pin is 5V pin? I tried running the code with the wires attached to 5V pin but the default value becomes even higher. The value has increased even higher, to 1000++. Sometimes it fluctuates and drops to 900++.
I don't have the link because we bought it from our lecturer. The lecturer made a bulk order from the vendor, so basically this is between the lecturer and the vendor.
As of now, I don't think it's the issue of using 3.3V or 5V pins, since my friends and other people are able to make it work with 3.3V pin. Plus, I don't have 5V pin.
Hi Tom,
I tried connecting my wires to Vin pin, unfortunately the sensor Value is still high. At first it was 1000++, so I just left it there and wait for a few hours. The sensor value managed to reduce to 700++. Based on the suggestions of the replies, I will leave it on for a few hours and hopefully the value will continue to drop. I am not sure am I heading to the right direction, so please correct me if I am wrong