MQ2 Gas measurement

Hi friends. here my projects for measurement MQ2 Gas values like CO, LPG and Smoke in PPM

*Arduino UNO with ethernet shield ( you can use esp wifi but need to edit the sketch ).
*MQ2 gas module

Arduino UNO – MQ2
5V >>> VCC
A0 >>> AO

MQ2 Library:

the widgets:
V1 = LPG
V2 = CO
V3 = Smoke


#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[] = "";

SimpleTimer timer;

void setup() {
  Blynk.begin(auth, server, 8080);
  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 =; //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()



5 posts were split to a new topic: Questions regarding mq2 gas measurement project