Introduction: NodeMCU Based Gas Monitoring System

In this project, I will use an MQ2 gas sensor and a NodeMCU to monitor the level of gas in the environment. The MQ2 gas sensor is a device that can detect various gases such as LPG, smoke, alcohol, propane, hydrogen, methane, and carbon monoxide. The NodeMCU is a microcontroller that can connect to the internet and send data to cloud platforms. I will use Adafruit IO, a service that allows users to create and manage data feeds, dashboards, and triggers. I will send the gas level data (in parts per million or ppm) from the NodeMCU to a feed named adafruitprojectfeed1 in Adafruit IO. If the feed value goes above 3600 PPM, which indicates a dangerous gas concentration, I will use IFTTT, a web-based service that can create applets to automate tasks, to initiate a voice over IP (VoIP) call to alert me or someone else about the situation.

Supplies

Hardware:

  1. ESP8266 NodeMCU
  2. A JTAG/USB Cable
  3. MQ-2 Gas Sensor
  4. A few connecting wires/soldering iron + PCB/Breadboard+2 wires

Software:

  1. Accounts in Adafruit IO and IFTTT
  2. Arduino IDE
  3. CH210x NodeMCU Driver

Step 1: Configuring the NodeMCU

Installing Arduino IDE 2.0:

  • First, ensure that you have the Arduino IDE 2.0 or later installed on your computer. If not, download it from the Arduino website and follow the installation instructions specific to your operating system (Windows, Mac OS X, or Linux).

Adding ESP8266 NodeMCU Support:

Step 2: Creating an Account in Adafruit IO and IFTTT

Adafruit IO:

  • Begin by visiting Adafruit Accounts.
  • Click the Sign Up button under the “Need An Adafruit Account?” section.
  • Fill in the requested information and click the Create Account button.
  • You will be redirected to your Adafruit Account home page.

IFTTT:

  • Visit IFTTT and sign up for an account if you haven’t already.
  • Once signed in, visit IFTTT Adafruit and click the Connect button to link your IFTTT account to Adafruit IO.
  • You’ll be redirected to your Adafruit account page and asked to authorize IFTTT. Click the AUTHORIZE button to grant access.
  • After authorization, you’ll be redirected back to IFTTT, and you should see a Channel connected! message at the top of the page.

Step 3: Creating an Applet in IFTTT

  1. Open the IFTTT app on your device.
  2. Tap “Create” to start building your applet.
  3. Under “If This,” select the trigger service. Select and connect to Adafruit IO.
  4. Provide your IO username and feed name and set relationship as "greater or equal to" and value as 3600.
  5. Next, under “Then That,” choose the action service. Choose VoIP Calls and enter "The MQ2 smoke sensor has detected {{Adafruit.monitorYourData.FeedValue}}PPM gas or smoke in your house. Please be cautious. Thank you" in the Voice Message text box.
  6. Customize your applet by editing the title and adding a description. Be specific and concise.
  7. Once you’re satisfied, tap “Finish” to save your new applet.


Step 4: Circuit Diagram

Step 5: Editing and Uploading the Code

Editing the Code:

Uploading the Code:

  • Connect your NodeMCU board to your computer via USB.
  • Select the NodeMCU board from the Tools > Board menu.
  • Choose the appropriate COM port for your NodeMCU.
  • Click the Upload button (right arrow icon) to upload the code to your NodeMCU.
  • Now your ESP8266 NodeMCU is supposed to start working

Step 6: Viewing the Output

  1. Login to your Adafruit IO.
  2. Go to 'Feeds' tab and click 'New Feed'
  3. Enter 'adafruitprojectfeed1' in 'Name' text box.
  4. Click 'Create'.
  5. Then, go to 'Dashboards' tab and click 'New Dashboard'.
  6. Enter 'AdafruitIFTTTproject' in 'Name' text box
  7. Open the dashboard.
  8. Click on Settings Icon and click 'Create new block'
  9. Add whatever blocks you want for your display. But do not forget to link the block to 'adafruitprojectfeed1' and set the maximum value, step value and minimum value 10000, 1 and 0 respectively
  10. Now your dashboard is ready for display and the output of the NodeMCU will be updated in the feed at regular intervals(i.e. 10 seconds).
  11. If your feed value goes above 3600 PPM, IFTTT will trigger a VoIP call to the device in which the IFTTT with the person's account is installed.