Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP8266 NodeMCU-Based Environmental Monitoring System with Motion Detection

Image of ESP8266 NodeMCU-Based Environmental Monitoring System with Motion Detection

Circuit Documentation

Summary

The circuit in question is designed to interface an ESP8266 NodeMCU microcontroller with a variety of sensors including a DHT22 temperature and humidity sensor, a PIR motion sensor, a TSL2561 Lux sensor for light intensity measurement, and an MMWave radar sensor for motion detection or range finding. The ESP8266 NodeMCU serves as the central processing unit, collecting data from the sensors and potentially controlling outputs based on sensor readings. The circuit is powered by the NodeMCU's 3V3 and VIN pins, with common ground connections throughout the components.

Component List

ESP8266 NodeMCU

  • Description: A WiFi-enabled microcontroller module that can be programmed for various IoT applications.
  • 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

DHT22

  • Description: A digital temperature and humidity sensor with a high precision and range.
  • Pins: + (Power), Out (Signal), - (Ground)

PIR Sensor

  • Description: A passive infrared sensor used to detect motion by measuring changes in the infrared levels emitted by surrounding objects.
  • Pins: VDD (Power), SIG (Signal), GND (Ground)

TSL2561 Lux Sensor

  • Description: An ambient light sensor that converts light intensity to a digital signal output.
  • Pins: INT, SDA, SCL, GND, VCC

MMWave Radar Sensor

  • Description: A sensor that uses millimeter-wave technology to detect objects and measure their range or relative speed.
  • Pins: TX, RX, IO1, IO2, GND, VGG

Wiring Details

ESP8266 NodeMCU

  • D1 connected to TSL2561 Lux Sensor SCL
  • D2 connected to TSL2561 Lux Sensor SDA
  • D3 connected to MMWave Radar Sensor TX
  • D4 connected to MMWave Radar Sensor RX
  • D6 connected to PIR Sensor SIG
  • D7 connected to DHT22 Out
  • GND connected to DHT22 -, TSL2561 Lux Sensor GND, MMWave Radar Sensor GND, PIR Sensor GND
  • 3V3 connected to DHT22 +, TSL2561 Lux Sensor VCC
  • VIN connected to MMWave Radar Sensor VGG, PIR Sensor VDD

DHT22

  • Out connected to ESP8266 NodeMCU D7
    • (Ground) connected to ESP8266 NodeMCU GND
    • (Power) connected to ESP8266 NodeMCU 3V3

PIR Sensor

  • SIG connected to ESP8266 NodeMCU D6
  • GND connected to ESP8266 NodeMCU GND
  • VDD connected to ESP8266 NodeMCU VIN

TSL2561 Lux Sensor

  • SCL connected to ESP8266 NodeMCU D1
  • SDA connected to ESP8266 NodeMCU D2
  • GND connected to ESP8266 NodeMCU GND
  • VCC connected to ESP8266 NodeMCU 3V3

MMWave Radar Sensor

  • TX connected to ESP8266 NodeMCU D3
  • RX connected to ESP8266 NodeMCU D4
  • GND connected to ESP8266 NodeMCU GND
  • VGG connected to ESP8266 NodeMCU VIN

Documented Code

// Code for the ESP8266 NodeMCU microcontroller

sensor:
  # Temperature / Humidity
  - platform: aht10   # Also for AHT20
    temperature:
      name: "Garage Temperature2"
      unit_of_measurement: "°F"
      device_class: temperature
    humidity:
      name: "Garage Humidity2"
      device_class: humidity
    update_interval: 120s

  # Analog Light Level
  - platform: adc
    pin: A0
    name: "Garage Analog Light Level"
    unit_of_measurement: lux
    device_class: illuminance
    update_interval: 10s
    filters:
      - lambda: |-
          return (2800/x) - 2700;  # only relative - not true lux

binary_sensor:
  # RCWL-0516 Motion
  - platform: gpio
    pin: D6
    name: "Garage Motion Front"
    device_class: motion
    
  # Photoresistor module DO light level
  - platform: gpio
    pin: D7
    name: "Garage Digital Light Level"

# RGB LED
light:
  - platform: rgb
    name: "Garage Sensor LED2"
    red: output_component1
    green: output_component2
    blue: output_component3

# LED output
output:
  - platform: esp8266_pwm
    id: output_component1
    pin: D3
  - platform: esp8266_pwm
    id: output_component2
    pin: D4
  - platform: esp8266_pwm
    id: output_component3
    pin: D5

This code snippet is designed to run on the ESP8266 NodeMCU and interfaces with the connected sensors. It includes configurations for temperature and humidity readings, light level measurements, motion detection, and control of an RGB LED. The code is structured for use with a home automation platform that supports YAML configuration, such as ESPHome or Home Assistant.