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

Arduino UNO-Based Environmental Monitoring System with Temperature and Gas Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Environmental Monitoring System with Temperature and Gas Sensors

Circuit Documentation

Summary

This circuit is designed to monitor temperature and gas levels using an Arduino UNO microcontroller. It includes a temperature sensor (LM35), a gas sensor (MQ-4), an RGB LED, a membrane matrix keypad, a piezo buzzer, and a DC motor. The Arduino UNO reads data from the sensors and controls the RGB LED, buzzer, and motor based on the sensor readings.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Temperature Sensor (LM35)

    • Description: Analog temperature sensor.
    • Pins: +Vs, Vout, GND
  3. MQ-4

    • Description: Gas sensor for detecting methane (CH4).
    • Pins: A0, D0, GND, VCC
  4. RGB LED (Wokwi compatible)

    • Description: RGB LED with common cathode.
    • Pins: R, COM, G, B
  5. Membrane Matrix Keypad

    • Description: 4x3 matrix keypad.
    • Pins: Row 1, Row 2, Row 3, Row 4, Column 1, Column 2, Column 3
  6. Piezo Buzzer

    • Description: Simple piezoelectric buzzer.
    • Pins: pin 1, pin 2
  7. DC Motor

    • Description: Standard DC motor.
    • Pins: pin 1, pin 2

Wiring Details

Arduino UNO

Temperature Sensor (LM35)

MQ-4

RGB LED (Wokwi compatible)

Membrane Matrix Keypad

Piezo Buzzer

DC Motor

Documented Code

#include <Keypad.h>

const int tempPin = A0;
const int gasPin = A1;
const int buzzerPin = 13;
const int fanPin = 12;

void setup() {
    pinMode(buzzerPin, OUTPUT);
    pinMode(fanPin, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    int temp = analogRead(tempPin) * (5.0 / 1023.0) * 100;
    int gas = analogRead(gasPin);

    Serial.print("Temperature: ");
    Serial.println(temp);
    Serial.print("Gas Level: ");
    Serial.println(gas);

    if (temp > 30) {
        digitalWrite(fanPin, HIGH);
    } else {
        digitalWrite(fanPin, LOW);
    }

    if (gas > 400) {
        digitalWrite(buzzerPin, HIGH);
    } else {
        digitalWrite(buzzerPin, LOW);
    }

    delay(1000);
}

This code reads the temperature and gas levels from the sensors and controls the fan and buzzer based on the readings. The temperature is read from the LM35 sensor connected to pin A0, and the gas level is read from the MQ-4 sensor connected to pin A1. If the temperature exceeds 30°C, the fan is turned on. If the gas level exceeds a threshold of 400, the buzzer is activated. The readings are also printed to the serial monitor.