Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Gas Level Monitoring System with MQ6 Sensor and OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Gas Level Monitoring System with MQ6 Sensor and OLED Display

Circuit Documentation

Summary

This circuit is designed to monitor gas levels using an MQ6 sensor and display the readings on an OLED 1.3" display via an ESP32 microcontroller. The ESP32 also controls a Piezo Buzzer for audible alerts and a Servo motor for physical responses. A SIM800L GSM Module is included for communication capabilities. Power management is handled by a Buck converter connected to a 2.1mm DC Barrel Jack. The circuit includes resistors for current limiting and voltage division.

Component List

ESP32 - 38 pins

Piezo Buzzer

SIM800L GSM Module

Resistor (10 Ohms)

Resistor (20 Ohms)

Servo

MQ6 Gas Sensor

Buck Converter

OLED 1.3" Display

2.1mm DC Barrel Jack

Wiring Details

ESP32 - 38 pins

Piezo Buzzer

SIM800L GSM Module

Resistor (10 Ohms)

Resistor (20 Ohms)

Servo

MQ6 Gas Sensor

Buck Converter

OLED 1.3" Display

2.1mm DC Barrel Jack

Documented Code

/*
 * This Arduino Sketch monitors the gas level using the MQ6 sensor and
 * displays the gas level on an I2C OLED screen. The MQ6 sensor's analog
 * output is connected to pin SP of the ESP32, and the OLED is connected
 * via I2C to pins G21 (SDA) and G22 (SCL) of the ESP32.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the OLED with the I2C address 0x27 and 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define the pin for the MQ6 sensor
const int mq6Pin = 34; // SP pin on ESP32

void setup() {
  // Initialize the OLED
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Gas Level:");

  // Initialize the serial communication for debugging
  Serial.begin(115200);
}

void loop() {
  // Read the analog value from the MQ6 sensor
  int gasLevel = analogRead(mq6Pin);

  // Print the gas level to the serial monitor
  Serial.print("Gas Level: ");
  Serial.println(gasLevel);

  // Display the gas level on the OLED
  lcd.setCursor(0, 1);
  lcd.print("Level: ");
  lcd.print(gasLevel);

  // Wait for a short period before the next reading
  delay(1000);
}

Note: The code provided is for an Arduino sketch that uses the LiquidCrystal_I2C library to interface with an I2C OLED display. The MQ6 sensor's analog output is read by the ESP32 and displayed on the OLED. Serial communication is also initialized for debugging purposes.