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

Arduino Mega 2560-Based Smart Water and Temperature Monitoring System with LCD Display and Stepper Motor

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Smart Water and Temperature Monitoring System with LCD Display and Stepper Motor

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions such as temperature and water levels, and control a stepper motor and a fan based on these conditions. The circuit uses an Arduino Mega 2560 microcontroller to interface with various sensors and actuators, including a DHT11 temperature and humidity sensor, a water sensor, a stepper motor, an LCD display, and several tactile switches. The system also includes a real-time clock (RTC) module for timekeeping.

Component List

  1. DHT11

    • Description: Temperature and Humidity Sensor
    • Pins: DATA, GND, VCC
  2. Motor amarillo motorreductor hobby

    • Description: Hobby Gear Motor
    • Pins: vcc, GND
  3. 28BYJ-48 Stepper Motor

    • Description: Stepper Motor
    • Pins: BLUE, PINK, YELLOW, ORANGE, RED
  4. Water sensor

    • Description: Water Level Sensor
    • Pins: Signal, VCC, GND
  5. Arduino Mega 2560

    • Description: Microcontroller
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
  6. Tactile Switch Buttons - 12mm Square

    • Description: Push Button Switch
    • Pins: 3, 1, 4, 2
  7. DS1307 RTC (Wokwi Compatible)

    • Description: Real-Time Clock Module
    • Pins: GND, 5V, SDA, SCL, SQW
  8. LCD Display (16 pin)

    • Description: 16x2 Character LCD Display
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0-DB7, A, K
  9. Rotary Potentiometer

    • Description: Variable Resistor
    • Pins: leg1, wiper, leg2
    • Properties: Resistance: 10k Ohms
  10. MB102 Breadboard Power Supply Module 3.3V/5V

    • Description: Power Supply Module
    • Pins: VCC, GND, 3.3V, 5V

Wiring Details

DHT11

Motor amarillo motorreductor hobby

28BYJ-48 Stepper Motor

Water sensor

Arduino Mega 2560

Tactile Switch Buttons - 12mm Square

DS1307 RTC (Wokwi Compatible)

LCD Display (16 pin)

Rotary Potentiometer

MB102 Breadboard Power Supply Module 3.3V/5V

Documented Code

#include <Wire.h>
#include <LiquidCrystal.h>
#include <RTClib.h>
#include <DHT.h>
#include <Stepper.h>

// Pin Definitions
#define WATER_SENSOR_PIN A0
#define DHT_PIN 6  // Reassigned from D2 to D6
#define FAN_PIN 3
#define YELLOW_LED_PIN 4
#define GREEN_LED_PIN 5
#define RED_LED_PIN 6
#define BLUE_LED_PIN 7
#define START_BUTTON_PIN 18
#define STOP_BUTTON_PIN 19
#define RESET_BUTTON_PIN 20

// Constants
#define DHT_TYPE DHT11
#define STEPS_PER_REV 2048
#define WATER_THRESHOLD 500  // Example threshold value
#define TEMP_THRESHOLD 25    // Example temperature threshold

// Global Variables
DHT dht(DHT_PIN, DHT_TYPE);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
RTC_DS1307 rtc;
Stepper stepper(STEPS_PER_REV, 8, 9, 10, 7);  // Reassigned from D11 to D7

enum State { DISABLED, IDLE, ERROR, RUNNING };
State currentState = DISABLED;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  rtc.begin();
  dht.begin();
  stepper.setSpeed(10);

  pinMode(WATER_SENSOR_PIN, INPUT);
  pinMode(FAN_PIN, OUTPUT);
  pinMode(YELLOW_LED_PIN, OUTPUT