Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Controlled Environment Monitoring System with Motorized Alert Mechanism

Image of Arduino UNO Controlled Environment Monitoring System with Motorized Alert Mechanism

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with various sensors, actuators, and an OLED display. The primary components include an Arduino UNO microcontroller, an L298N DC motor driver, two DC motors, a buzzer, two white LEDs, a flame sensor, a DHT11 temperature and humidity sensor, an OLED display, two IR sensors, and a 12V battery. The circuit is capable of reading sensor data, displaying information on the OLED, controlling the buzzer and LEDs based on sensor inputs, and driving the motors.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

L298N DC Motor Driver

  • A motor driver module capable of driving two DC motors or one stepper motor.
  • It has 2 H-bridges and can handle a current up to 2A per channel.

DC Motor (x2)

  • Electric motors that convert DC electrical energy into mechanical energy.

Buzzer

  • An electronic buzzer that produces sound when provided with an electrical signal.

LED: Two Pin (white) (x2)

  • Standard white LEDs with an anode and cathode for emitting light when a current passes through them.

Flame Sensor

  • A sensor that can detect the presence of a flame or fire.

DHT11

  • A basic, ultra-low-cost digital temperature and humidity sensor.

OLED 1.3"

  • A small OLED display for showing text, graphics, and images.

Battery 12V

  • A 12V battery that provides power to the circuit.

IR Sensor (x2)

  • Infrared sensors used for object detection or distance measurement.

Wiring Details

Arduino UNO

  • A4 connected to OLED SCL
  • A5 connected to OLED SDA
  • D12 connected to IR Sensor 2 OUT
  • D11 connected to IR Sensor 1 OUT
  • D10 connected to DHT11 DATA
  • D9 connected to Flame Sensor D0
  • D8 connected to Buzzer PIN
  • D7 connected to LED 1 Anode
  • D6 connected to LED 2 Anode
  • D5 connected to L298N IN4
  • D4 connected to L298N IN3
  • D3 connected to L298N IN2
  • D2 connected to L298N IN1

L298N DC Motor Driver

  • IN1 to IN4 connected to corresponding Arduino UNO pins
  • OUT1 and OUT2 connected to DC Motor 1
  • OUT3 and OUT4 connected to DC Motor 2
  • 12V connected to Battery 12V +
  • GND connected to common ground
  • 5V connected to common 5V

DC Motor 1

  • pin 1 connected to L298N OUT1
  • pin 2 connected to L298N OUT2

DC Motor 2

  • pin 1 connected to L298N OUT4
  • pin 2 connected to L298N OUT3

Buzzer

  • PIN connected to Arduino UNO D8
  • GND connected to common ground

LED 1

  • anode connected to Arduino UNO D7
  • cathode connected to common ground

LED 2

  • anode connected to Arduino UNO D6
  • cathode connected to common ground

Flame Sensor

  • VCC connected to common 5V
  • GND connected to common ground
  • D0 connected to Arduino UNO D9

DHT11

  • DATA connected to Arduino UNO D10
  • GND connected to common ground
  • VCC connected to common 5V

OLED 1.3"

  • GND connected to common ground
  • VCC connected to common 5V
  • SCL connected to Arduino UNO A4
  • SDA connected to Arduino UNO A5

Battery 12V

  • + connected to L298N 12V
  • - connected to common ground

IR Sensor 1

  • out connected to Arduino UNO D11
  • gnd connected to common ground
  • vcc connected to common 5V

IR Sensor 2

  • out connected to Arduino UNO D12
  • gnd connected to common ground
  • vcc connected to common 5V

Documented Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// DHT11 settings
#define DHTPIN 10
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// Flame sensor pin
#define FLAME_SENSOR_PIN 9

// Buzzer pin
#define BUZZER_PIN 8

// LED pins
#define LED1_PIN 7
#define LED2_PIN 6

// L298N motor driver pins
#define IN1_PIN 2
#define IN2_PIN 3
#define IN3_PIN 4
#define IN4_PIN 5

// IR sensor pins
#define IR_SENSOR1_PIN 11
#define IR_SENSOR2_PIN 12

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize OLED display
  if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  // Initialize DHT11 sensor
  dht.begin();

  // Initialize flame sensor pin
  pinMode(FLAME_SENSOR_PIN, INPUT);

  // Initialize buzzer pin
  pinMode(BUZZER_PIN, OUTPUT);

  // Initialize LED pins
  pinMode(LED1_PIN, OUTPUT);
  pinMode(LED2_PIN, OUTPUT);

  // Initialize motor driver pins
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  pinMode(IN3_PIN, OUTPUT);
  pinMode(IN4_PIN, OUTPUT);

  // Initialize IR sensor pins
  pinMode(IR_SENSOR1_PIN, INPUT);
  pinMode(IR_SENSOR2_PIN, INPUT);
}

void loop() {
  // Read DHT11 sensor data
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Read flame sensor data
  int flameSensorValue = digitalRead(FLAME_SENSOR_PIN);

  // Read IR sensor data
  int irSensor1Value = digitalRead(IR_SENSOR1_PIN);
  int irSensor2Value = digitalRead(IR_SENSOR2_PIN);

  // Display data on OLED
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Temp: ");
  display.print(temperature);
  display.print(" C");
  display.setCursor(0, 10);
  display.print("Humidity: ");
  display.print(humidity);
  display.print(" %");
  display.setCursor(0, 20);
  display.print("Flame: ");
  display.print(flameSensorValue ? "No" : "Yes");
  display.setCursor(0, 30);
  display.print("IR1: ");
  display.print(irSensor1Value ? "No" : "Yes");
  display.setCursor(0, 40);
  display.print("IR2: ");
  display.print(irSensor2Value ? "No" : "Yes");
  display.display();

  // Control buzzer based on flame sensor
  if (flameSensorValue == LOW) {
    digitalWrite(BUZZER_PIN, HIGH);
  } else {
    digitalWrite(BUZZER_PIN, LOW);
  }

  // Control LEDs based on IR sensors
  digitalWrite(LED1_PIN, irSensor1Value == LOW ? HIGH : LOW);
  digitalWrite(LED2_PIN, irSensor2Value == LOW ? HIGH : LOW);

  // Control motors (example: forward motion)
  digitalWrite(IN1_PIN, HIGH);
  digitalWrite(IN2_PIN, LOW);
  digitalWrite(IN3_PIN, HIGH);
  digitalWrite(IN4_PIN, LOW);

  delay(1000);
}

This code initializes the components and reads data from the sensors. It displays the sensor data on the OLED screen, controls the buzzer based on the flame sensor, and controls the LEDs based on the IR sensors. The motors are set to move forward as an example. You can modify the motor control logic as needed for your application.

How to Upload Code

To upload the code to your Arduino UNO, follow these steps:

  1. Install the Arduino IDE:

    • If you haven't already, download and install the Arduino IDE from the official Arduino website.
  2. Connect the Arduino UNO: