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

Arduino 101-Based Smart Environmental Monitoring System with Bluetooth Connectivity

View and Edit Project In Cirkit DesignerImage of Arduino 101-Based Smart Environmental Monitoring System with Bluetooth Connectivity

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions using an MQ2 gas sensor and a DHT11 humidity and temperature sensor. It also includes an HC-05 Bluetooth module for wireless communication, a buzzer for alerts, and three LEDs (yellow, red, and green) for visual indicators. The circuit is controlled by an Arduino 101 microcontroller.

Component List

MQ2 Gas Sensor

DHT11 Humidity and Temperature Sensor

HC-05 Bluetooth Module

Arduino 101

Buzzer

LED: Two Pin (Yellow)

LED: Two Pin (Red)

LED: Two Pin (Green)

Resistor (220 Ohms)

Wiring Details

MQ2 Gas Sensor

DHT11 Humidity and Temperature Sensor

HC-05 Bluetooth Module

Buzzer

LED: Two Pin (Yellow)

LED: Two Pin (Red)

LED: Two Pin (Green)

Code Documentation

#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11
#define BUZZER_PIN 8
#define ALERT_LED_PIN 7
#define CONTROL_LED_PIN 6
#define CONTROL_LED2_PIN 5
#define MQ2_PIN A0
#define THRESHOLD 600

DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(9600);
    dht.begin();
    pinMode(BUZZER_PIN, OUTPUT);
    pinMode(ALERT_LED_PIN, OUTPUT);
    pinMode(CONTROL_LED_PIN, OUTPUT);
    pinMode(CONTROL_LED2_PIN, OUTPUT);
    Serial.println("Type 'on' or 'off' to control the first LED, and 'on2' or 'off2' for the second LED.");
}

void loop() {
    int mq2Value = analogRead(MQ2_PIN);
    if (mq2Value > THRESHOLD) {
        digitalWrite(BUZZER_PIN, HIGH);
        digitalWrite(ALERT_LED_PIN, HIGH);
    } else {
        digitalWrite(BUZZER_PIN, LOW);
        digitalWrite(ALERT_LED_PIN, LOW);
    }

    if (Serial.available() > 0) {
        String command = Serial.readStringUntil('\n');
        command.trim();
        if (command == "on") {
            digitalWrite(CONTROL_LED_PIN, HIGH);
            Serial.println("Control LED 1 turned ON");
        } else if (command == "off") {
            digitalWrite(CONTROL_LED_PIN, LOW);
            Serial.println("Control LED 1 turned OFF");
        } else if (command == "on2") {
            digitalWrite(CONTROL_LED2_PIN, HIGH);
            Serial.println("Control LED 2 turned ON");
        } else if (command == "off2") {
            digitalWrite(CONTROL_LED2_PIN, LOW);
            Serial.println("Control LED 2 turned OFF");
        } else {
            Serial.println("Invalid command. Type 'on', 'off', 'on2', or 'off2'.");
        }
    }

    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature();
    if (isnan(humidity) || isnan(temperature)) {
        Serial.println("Failed to read from DHT sensor!");
    } else {
        Serial.print("Humidity: ");
        Serial.print(humidity);
        Serial.print("% Temperature: ");
        Serial.print(temperature);
        Serial.println("°C");
    }
}

This code initializes the DHT11 sensor, sets up the pins for the buzzer and LEDs, and continuously reads the gas sensor value. If the gas concentration exceeds a threshold, the buzzer and alert LED are activated. The code also listens for serial commands to control two additional LEDs and prints the humidity and temperature readings to the serial monitor.