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

Arduino Mega 2560 Based Automatic Smoke Detection and Alert System with Solar Charging

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Based Automatic Smoke Detection and Alert System with Solar Charging

Circuit Documentation

Summary

This circuit is designed for an automatic system that interacts with various sensors and modules to perform specific actions based on environmental conditions and inputs. The system is capable of detecting smoke or gas using an MQ2 sensor, controlling power to an exhaust fan and a solenoid lock, and providing audio feedback through a buzzer and a DFPlayer Mini module. It also includes a voice recognition module for receiving voice commands and an ESP32 microcontroller for additional functionalities. The circuit is powered by a 12V battery, which is charged by a solar panel through a charge controller. An ATS (Automatic Transfer Switch) is used to switch between the battery and solar power. The main control unit is an Arduino Mega 2560, which manages the inputs and outputs and communicates with the ESP32 and other modules.

Component List

Power Sources

Sensors and Modules

Actuators

Control and Conversion

Input Devices

Indicators

Wiring Details

Power Distribution

Sensors and Modules

Actuators

Control and Conversion

Input Devices

Indicators

Documented Code

/*
 * This Arduino sketch is designed for an automatic system that opens a solenoid
 * lock and activates a buzzer when the MQ2 sensor detects smoke or gas. The
 * system also includes a DFPlayer Mini for audio output, a voice recognition
 * module, and an ESP32 for additional functionalities. The circuit is powered
 * by a 12V battery and a solar panel with a charge controller.
 */

#include <SoftwareSerial.h>

// Pin definitions
const int mq2DigitalPin = 2;
const int mq2AnalogPin = A0;
const int solenoidPin = 10;
const int buzzerPin = 3;
const int relay1Pin = 11;
const int relay2Pin = 12;
const int relay3Pin = 13;

// DFPlayer Mini
SoftwareSerial myDFPlayer(16, 17); // RX, TX

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

  // Initialize pins
  pinMode(mq2DigitalPin, INPUT);
  pinMode(mq2AnalogPin, INPUT);
  pinMode(solenoidPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(relay1Pin, OUTPUT);
  pinMode(relay2Pin, OUTPUT);
  pinMode(relay3Pin, OUTPUT);

  // Initial states
  digitalWrite(solenoidPin, LOW);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(relay1Pin, LOW);
  digitalWrite(relay2Pin, LOW);
  digitalWrite(relay3Pin, LOW);
}

void loop() {
  // Read MQ2 sensor
  int mq2DigitalValue = digitalRead(mq2DigitalPin);
  int mq2AnalogValue = analogRead(mq2AnalogPin);

  // Check for smoke or gas
  if (mq2DigitalValue == HIGH || mq2AnalogValue > 300) {
    // Activate solenoid lock and buzzer
    digitalWrite(solenoidPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(5000); // Keep activated for 5 seconds
    digitalWrite(solenoidPin, LOW);
    digitalWrite(buzzerPin, LOW);
  }

  // Add any additional functionalities here
}

Filename: sketch.ino