Hi friends. here my projects for measurement MQ2 Gas values like CO, LPG and Smoke in PPM
Materials:
*Arduino UNO with ethernet shield ( you can use esp wifi but need to edit the sketch ).
*MQ2 gas module
Wiring:
Arduino UNO – MQ2
5V >>> VCC
GND >>> GND
A0 >>> AO
MQ2 Library:
https://github.com/labay11/MQ-2-sensor-library
the widgets:
V1 = LPG
V2 = CO
V3 = Smoke
Sketch:
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <MQ2.h>
//change this with the pin that you use
int pin = A0;
int lpg, co, smoke;
MQ2 mq2(pin);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "f375eacff6884389b7d553c7b8e62513";
char server[] = "10.5.51.5";
SimpleTimer timer;
void setup() {
Blynk.begin(auth, server, 8080);
mq2.begin();
timer.setInterval(2000L, gas);
}
void gas() {
/*read the values from the sensor, it returns
an array which contains 3 values.
1 = LPG in ppm
2 = CO in ppm
3 = SMOKE in ppm
*/
float* values = mq2.read(true); //set it false if you don't want to print the values in the Serial
//lpg = values[0];
lpg = mq2.readLPG();
Blynk.virtualWrite(1, lpg);
//co = values[1];
co = mq2.readCO();
Blynk.virtualWrite(2, co);
//smoke = values[2];
smoke = mq2.readSmoke();
Blynk.virtualWrite(3, smoke);
}
void loop()
{
Blynk.run();
timer.run();
}
ScreenShot;