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

Arduino and ESP8266 Automated Climate Control and Lighting System

View and Edit Project In Cirkit DesignerImage of Arduino and ESP8266 Automated Climate Control and Lighting System

Circuit Documentation

Summary

The circuit is designed to manage and monitor an environment using various sensors and actuators. It includes a solar charge controller for power management, a step-down converter to provide 5V power, temperature and humidity sensing, light level detection, real-time clock tracking, and relay-controlled AC loads such as lights and a fan. Communication with the system is facilitated by an ESP8266 NodeMCU and an Arduino UNO, which also controls the sensors and actuators based on environmental readings and Bluetooth commands.

Component List

MPPT Solar Charge Controller (MPPT SCC)

12V to 5V Step Down Power Converter

KY-015 DHT11 Temperature and Humidity Sensor

Sensor LDR LM393 Light Sensor

Resistor (10k Ohms)

Relay 4 Channel 5V

LED Bulb AC

Arduino UNO

ESP8266 NodeMCU

RTC DS3231 Real-Time Clock

Fan

12V 5Ah Battery

Solar Panel

Wiring Details

MPPT Solar Charge Controller

12V to 5V Step Down Power Converter

KY-015 DHT11

Sensor LDR LM393

Resistor (10k Ohms)

Relay 4 Channel 5V

LED Bulb AC

Arduino UNO

ESP8266 NodeMCU

RTC DS3231

Fan

12V 5Ah Battery

Solar Panel

Documented Code

Arduino UNO Code (sketch.ino)

#include <DHT.h>
#include <Wire.h>
#include <RTClib.h>
#include <SoftwareSerial.h>  // For Bluetooth

#define DHTPIN 2       // Pin connected to DHT11
#define DHTTYPE DHT11  // DHT 11 sensor
#define RELAY_LIGHT 3  // Pin connected to Relay for Light
#define RELAY_FAN 4    // Pin connected to Relay for Fan
#define LDR_PIN A0     // Pin connected to LDR
#define PIR_PIN 5      // Pin connected to PIR sensor

DHT dht(DHTPIN, DHTTYPE);  // Initialize DHT sensor
RTC_DS3231 rtc;            // Real-Time Clock instance
SoftwareSerial bluetooth(10, 11);  // RX, TX for Bluetooth

void setup() {
  Serial.begin(9600);  // Start serial communication for debugging
  bluetooth.begin(9600); // Start Bluetooth communication
  
  // Initialize DHT sensor
  dht.begin();
  
  // Initialize relays as outputs
  pinMode(RELAY_LIGHT, OUTPUT);
  pinMode(RELAY_FAN, OUTPUT);
  
  // Initialize PIR sensor as input
  pinMode(PIR_PIN, INPUT);
  
  // Initialize RTC
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  
  if (rtc.lostPower()) {
    // Set RTC to current time
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop() {
  // Read temperature and humidity
  float temp = dht.readTemperature();
  float humidity = dht.readHumidity();
  
  // Check if readings are valid
  if (isnan(temp) || isnan(humidity)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Read LDR value
  int lightLevel = analogRead(LDR_PIN);

  // Read PIR sensor value
  int motionDetected = digitalRead(PIR_PIN);