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

ESP8266 NodeMCU Environment Monitoring System with Stepper Motor and Sensors

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU Environment Monitoring System with Stepper Motor and Sensors

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to monitor environmental conditions using an ESP8266 NodeMCU microcontroller. The circuit includes a DHT11 sensor for temperature and humidity measurements, an LDR module for light intensity detection, and a 28BYJ-48 stepper motor controlled via a ULN2003A driver. The microcontroller processes the sensor data and can control the stepper motor based on the readings.

Component List

  1. ESP8266 NodeMCU

    • Description: A low-cost Wi-Fi microcontroller with multiple GPIO pins.
    • Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
  2. 28BYJ-48 Stepper Motor

    • Description: A small, inexpensive stepper motor commonly used in various applications.
    • Pins: BLUE, PINK, YELLOW, ORANGE, RED
  3. ULN2003A Breakout Board

    • Description: A driver board for controlling the 28BYJ-48 stepper motor.
    • Pins: In 1, In 2, In 3, In 4, In 5, In 6, In 7, 0V, +5V, ON/OFF jumper switch, BLUE wire, PINK wire, YELLOW wire, ORANGE wire, RED wire
  4. LDR Module 3 Pin

    • Description: A light-dependent resistor module for measuring light intensity.
    • Pins: VCC, GND, DO
  5. DHT11 Sensor V2

    • Description: A digital temperature and humidity sensor.
    • Pins: GND, DAT, VCC
  6. DC Source 5V

    • Description: A 5V DC power source.
    • Pins: VCC, GND

Wiring Details

ESP8266 NodeMCU

28BYJ-48 Stepper Motor

ULN2003A Breakout Board

LDR Module 3 Pin

DHT11 Sensor V2

DC Source 5V

Code Documentation

/*
 * ESP8266 NodeMCU Controlled Environment Monitoring System
 * with Stepper Motor and Sensors
 *
 * This code controls a stepper motor using a ULN2003A driver, reads data from
 * a DHT11 temperature and humidity sensor, and an LDR module for light
 * intensity. The data is processed and can be used for various applications
 * such as controlling the environment based on sensor readings.
 */

#include <DHT.h>

// Pin definitions
#define DHTPIN D5
#define DHTTYPE DHT11
#define LDRPIN A0
#define IN1 D1
#define IN2 D2
#define IN3 D3
#define IN4 D4

// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(115200);
  // Initialize DHT sensor
  dht.begin();
  // Initialize stepper motor pins
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  // Read temperature and humidity from DHT11 sensor
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // Read light intensity from LDR module
  int lightIntensity = analogRead(LDRPIN);
  // Print sensor values to serial monitor
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C\t");
  Serial.print("Light Intensity: ");
  Serial.println(lightIntensity);
  // Control stepper motor (example: rotate 1 step)
  stepMotor();
  // Wait for 2 seconds before next loop
  delay(2000);
}

void stepMotor() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  delay(10);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  delay(10);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  delay(10);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  delay(10);
}

This code initializes the DHT11 sensor and the stepper motor pins, reads sensor data, and controls the stepper motor. The sensor values are printed to the serial monitor, and the stepper motor is rotated one step in each loop iteration.