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

Arduino and ESP8266 Controlled Environmental Monitoring and Waste Management System

View and Edit Project In Cirkit DesignerImage of Arduino and ESP8266 Controlled Environmental Monitoring and Waste Management System

Circuit Documentation

Summary

The circuit is designed to monitor environmental conditions and control devices within a chicken coop and waste disposal system. It features temperature and gas detection sensors, motor drivers for actuator control, and relays for managing AC-powered devices such as a fan and light bulb. The core of the system is an Arduino UNO microcontroller, which processes sensor data and controls the connected devices based on predefined conditions.

Component List

DHT22 (Temperature and Humidity Sensor)

Arduino UNO (Microcontroller Board)

ESP8266 NodeMCU (Wi-Fi Microcontroller)

L298N Motor Driver (Motor Controller Module)

DC Mini Metal Gear Motor

MQ-136 (Gas Sensor)

AC Bulb

Fan

Two Channel Relay 5V

AC Source

Wiring Details

DHT22 Sensors

Arduino UNO

ESP8266 NodeMCU

L298N Motor Drivers

DC Mini Metal Gear Motors

MQ-136 Gas Sensors

AC Bulbs

Fans

Two Channel Relay 5V

AC Sources

Documented Code

/*
 * Arduino Sketch for monitoring temperature and controlling devices
 * in a chicken coop and waste disposal system.
 *
 * Components:
 * - DHT22 sensors for temperature monitoring
 * - MQ-136 sensors for gas detection
 * - L298N Motor Driver for motor control
 * - Two Channel Relay for controlling AC devices
 * - Fan and AC Bulb for environmental control
 *
 * Connections:
 * - DHT22 sensors connected to D4 and D5
 * - MQ-136 sensors connected to A2, D6, A3, and D7
 * - L298N Motor Driver connected to D8, D9, D10, and D11
 * - Relay connected to A0 and A1
 * - Fan and AC Bulb connected to Relay
 */

#include <DHT.h>

#define DHTPIN1 4
#define DHTPIN2 5
#define DHTTYPE DHT22

DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);

#define MQ136_A2 A2
#define MQ136_D6 6
#define MQ136_A3 A3
#define MQ136_D7 7

#define RELAY_IN1 A0
#define RELAY_IN2 A1

#define MOTOR_IN1_1 8
#define MOTOR_IN4_1 9
#define MOTOR_IN1_2 10
#define MOTOR_IN4_2 11

void setup() {
  Serial.begin(9600);
  dht1.begin();
  dht2.begin();

  pinMode(MQ136_A2, INPUT);
  pinMode(MQ136_D6, INPUT);
  pinMode(MQ136_A3, INPUT);
  pinMode(MQ136_D7, INPUT);

  pinMode(RELAY_IN1, OUTPUT);
  pinMode(RELAY_IN2, OUTPUT);

  pinMode(MOTOR_IN1_1, OUTPUT);
  pinMode(MOTOR_IN4_1, OUTPUT);
  pinMode(MOTOR_IN1_2, OUTPUT);
  pinMode(MOTOR_IN4_2, OUTPUT);
}

void loop() {
  float temp1 = dht1.readTemperature();
  float temp2 = dht2.readTemperature();

  int gas1 = analogRead(MQ136_A2);
  int gas2 = digitalRead(MQ136_D6);
  int gas3 = analogRead(MQ136_A3);
  int gas4 = digitalRead(MQ136_D7);

  Serial.print("Temp1: ");
  Serial.print(temp1);
  Serial.print(" C, Temp2: ");
  Serial.print(temp2);
  Serial.println(" C");

  Serial.print("Gas1: ");
  Serial.print(gas1);
  Serial.print(", Gas2: ");
  Serial.print(gas2);
  Serial.print(", Gas3: ");
  Serial.print(gas3);
  Serial.print(", Gas4: ");
  Serial.println(gas4);

  if (temp1 > 30 || temp2 > 30) {
    digitalWrite(RELAY_IN1, HIGH);
    digitalWrite(RELAY_IN2, HIGH);
  } else {
    digitalWrite(RELAY_IN1, LOW);
    digitalWrite(RELAY_IN2, LOW);
  }

  if (gas1 > 300 || gas2 == HIGH || gas3 > 300 || gas4 == HIGH) {
    digitalWrite(MOTOR_IN1_1, HIGH);
    digitalWrite(MOTOR_IN4_1, HIGH);
    digitalWrite(MOTOR_IN1_2, HIGH);
    digitalWrite(MOTOR_IN4_2, HIGH);
  } else {
    digitalWrite(MOTOR_IN1_1, LOW);
    digitalWrite(MOTOR_IN4_1, LOW);
    digitalWrite(MOTOR_IN1_2, LOW);
    digitalWrite(MOTOR_IN4_2, LOW);
  }

  delay(2000);
}

This code is responsible for initializing the sensors and actuators, reading temperature and gas levels, and controlling the relay and motors based on the sensor readings. It uses the DHT library for interfacing with the DHT22 sensors. The relay is activated if the temperature exceeds 30 degrees Celsius, and the motors are activated if any of the gas sensors detect a level higher than 300 or a digital HIGH signal.