0% found this document useful (0 votes)
19 views5 pages

Experiment No: 13: Aim: Adafruit MQTT Using The Publisher Method Via MQ - 2 Sensor, Relay, Nodemcu and

The document describes an experiment using an MQ-2 gas sensor, relay, NodeMCU, and Adafruit IO to publish sensor readings to the cloud. The experiment connects the MQ-2 and relay to a NodeMCU, codes the NodeMCU to read the sensor and control the relay using Blynk and publishes the data to Adafruit IO. Connecting all the hardware and coding the NodeMCU allows real-time sensor monitoring and remote relay control through mobile apps.

Uploaded by

shalini pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Experiment No: 13: Aim: Adafruit MQTT Using The Publisher Method Via MQ - 2 Sensor, Relay, Nodemcu and

The document describes an experiment using an MQ-2 gas sensor, relay, NodeMCU, and Adafruit IO to publish sensor readings to the cloud. The experiment connects the MQ-2 and relay to a NodeMCU, codes the NodeMCU to read the sensor and control the relay using Blynk and publishes the data to Adafruit IO. Connecting all the hardware and coding the NodeMCU allows real-time sensor monitoring and remote relay control through mobile apps.

Uploaded by

shalini pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERIMENT NO : 13

Aim: Adafruit MQTT using the publisher method via MQ_2 sensor, Relay, NodeMcu and
Adafruit IO.

Apparatus:

I. 1x NodeMcu
II. 1x DHT11 Sensor
III. 1x BreadBoard
IV. 3x Male-Male Jumper Wires
V. Computer/Laptop with Internet Connectivity
VI. WiFi Connectivity/HotSpot.
VII. Relay Module

Theory:

MQ_2 has the following pin out as shown in the below Figure 1.

Fig 1.
MQ2 Gas sensor works on 5V DC and draws around 800mW. It can
detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentration
s anywhere from 200 to 10000ppm.

Specifications:

Schematic:

Fig 2.
Code:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

BlynkTimer timer;

char auth[] = "ffSecIoBQ0qfef4NEvkD5HTnYaowwRMG";

char ssid[] = "TeamIOT";

char pass[] = "12345";

int n;

void setup()

Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

pinMode(16,OUTPUT);

pinMode(5,OUTPUT);

timer.setInterval(1000L, sendUptime);

void sendUptime()

Blynk.virtualWrite(V1, n);

void loop()

Blynk.run();

timer.run();
n=analogRead(A0);

Serial.println(n);

if(n>550)

digitalWrite(16,HIGH);

digitalWrite(5,LOW);

delay(2000);

if(n<550)

digitalWrite(16,LOW);

digitalWrite(5,HIGH);

delay(2000);

}}

Hardware:

Fig 3.

Output:
The output is obtained on the Adafruit IO interface and Blynk App.

Fig 4.

Conclusion: From the above experiment we learnt to interface MQ_2 Gas sensor and Relay
with NodeMcu and create and application of it.

You might also like