ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors

ESP8266 NodeMCU Smart Health & Environment Monitoring System | MakeMindz
ESP8266 NodeMCU Pulse Sensor DHT11/DHT22 PIR Motion IoT Health

ESP8266 NodeMCU
Smart Health & Environment
Monitoring System

A multi-sensor IoT platform combining heart rate, temperature, humidity, and motion detection — all transmitted wirelessly via WiFi for real-time cloud monitoring and smart automation.

🕐 45–60 min build 🔧 Intermediate 📡 WiFi IoT 🏷️ MakeMindz.com
❤️
Heart Rate
Pulse Sensor → A0
🌡️
Temperature
DHT11/22 → D4
💧
Humidity
DHT11/22 → D4
🚶
Motion
PIR → D6

📋 Project Overview

This IoT monitoring system uses the ESP8266 NodeMCU as its central hub, collecting data from four sensor types simultaneously. The pulse sensor measures heart rate via an analog signal on pin A0. The DHT11 or DHT22 sensor provides temperature and humidity readings over a single digital wire. The PIR motion sensor detects human presence and triggers automation or alerts. An additional light-level sensor (analog or digital) rounds out the environmental picture.

All readings are processed by the ESP8266 and transmitted over WiFi to a cloud platform, MQTT broker, or local web dashboard — making this an ideal foundation for patient monitoring, smart home sensing, and IoT lab projects.

Sensors at a glance

❤️
Pulse Sensor
Optical heart rate detection via fingertip. Outputs analog voltage proportional to blood flow intensity.
A0 (Analog)
🌡️
DHT11 / DHT22
Single-wire digital sensor. DHT22 offers higher accuracy (±0.5°C vs ±2°C for DHT11).
D4 (Digital)
🚶
PIR Motion Sensor
Passive infrared sensor detects body heat movement. Output goes HIGH when motion is detected.
D6 (Digital)
💡
Light Level (LDR)
Analog light level on A0 (mux with pulse sensor) or digital threshold output on D7.
D7 (Digital DO)

🔧 Components Required

1
ESP8266 NodeMCU
v2 or v3, built-in WiFi, USB programming via CH340
1
Pulse Sensor Module
Analog output, 3.3V–5V, clip or velcro finger mount
1
DHT11 or DHT22
Temperature + humidity; DHT22 for higher accuracy
1
PIR Motion Sensor (HC-SR501)
Adjustable sensitivity and delay via trimpots
1
LDR Light Sensor Module
Photoresistor with digital comparator DO output
1
RGB LED Module
Common cathode, PWM via D3/D4/D5
Breadboard + Jumper Wires
Half-size breadboard, male-to-female jumpers
1
Micro USB Cable
For programming and 5V power supply to NodeMCU
⚠️ Analog pin note: The ESP8266 has only one ADC pin (A0) with a 0–1V input range. Use a voltage divider (100kΩ + 220kΩ) if your pulse sensor outputs 0–3.3V. Do not connect 5V signals directly to A0.

Key Features

❤️ Real-time heart rate monitoring
🌡️ Temperature + humidity sensing
🚶 PIR motion detection
💡 Ambient light level sensing
📡 WiFi IoT connectivity
🌐 Cloud dashboard ready
⚡ Low power compact design
🔁 MQTT / HTTP data push

Circuit Diagram

All sensors connect to the NodeMCU's GPIO and analog pins. The RGB LED uses PWM-capable pins D3, D4, and D5 for colour mixing.

ESP8266 NodeMCU A0 ← Pulse Sensor (SIG) D4 ← DHT11/22 DATA D6 ← PIR OUT D7 ← LDR DO D3 → RGB RED D5 → RGB GREEN D8 → RGB BLUE 3V3 → Pulse VCC 3V3 → DHT VCC 5V → PIR VCC 3V3 → LDR VCC GND → Common GND Pulse Sensor SIG→A0 | VCC→3V3 | GND DHT11/22 Temp + Humidity DATA→D4 | VCC→3V3 | GND PIR HC-SR501 Motion sensor OUT→D6 | VCC→5V | GND LDR Module Light level sensor DO→D7 | VCC→3V3 | GND RGB LED R ← D3 (PWM) G ← D5 (PWM) B ← D8 (PWM) Common Ground — NodeMCU GND → All sensor GNDs → RGB LED GND Analog SIG DATA OUT DO

Simplified schematic — see pin wiring table below for all exact connections

🔌 Pin Wiring Reference

Sensor / ModuleSensor PinNodeMCU PinNotes
Pulse SensorSIG (Signal)A0Analog — use voltage divider if >1V
Pulse SensorVCC3V33.3V power
Pulse SensorGNDGNDCommon ground
DHT11/DHT22DATAD4 (GPIO2)Single-wire digital — add 10kΩ pull-up to 3V3
DHT11/DHT22VCC3V33.3V power
DHT11/DHT22GNDGNDCommon ground
PIR HC-SR501OUTD6 (GPIO12)Digital HIGH = motion detected
PIR HC-SR501VCCVIN / 5VPIR needs 5V — use VIN from USB power
PIR HC-SR501GNDGNDCommon ground
LDR ModuleDO (Digital Out)D7 (GPIO13)HIGH = below light threshold
LDR ModuleVCC3V33.3V power
LDR ModuleGNDGNDCommon ground
RGB LEDR (Red)D3 (GPIO0)PWM — 100Ω series resistor
RGB LEDG (Green)D5 (GPIO14)PWM — 100Ω series resistor
RGB LEDB (Blue)D8 (GPIO15)PWM — 100Ω series resistor
RGB LEDGND (common)GNDCommon cathode to GND
ℹ️ D4 (GPIO2) is connected to the onboard LED on most NodeMCU boards — it will blink during DHT reads. This is normal. If conflicts arise, move DHT data to D2 (GPIO4) and update the pin definition in the sketch.

🛠️ Step-by-Step Build Guide

1
Install required libraries in Arduino IDE
Open Arduino IDE → Library Manager and install: DHT sensor library by Adafruit, PulseSensorPlayground by World Famous Electronics, and ESP8266WiFi (included with the ESP8266 board package). Install the ESP8266 board package via: http://arduino.esp8266.com/stable/package_esp8266com_index.json
📦 Also install Adafruit Unified Sensor — it is a dependency of the DHT library and will cause compile errors if missing.
2
Wire the pulse sensor to A0
Connect the pulse sensor SIG pin to the NodeMCU A0 pin. Connect VCC to 3V3 and GND to the common ground rail. The A0 pin accepts 0–1V, so check your module's output range — most pulse sensor modules output 0–3.3V and require a resistor divider (100kΩ in series, 220kΩ to GND).
⚠️ Never connect a 5V signal directly to the ESP8266 A0 or GPIO pins — the chip is not 5V tolerant and will be permanently damaged.
3
Connect the DHT11 or DHT22 sensor
Connect DHT DATA pin to D4, VCC to 3V3, and GND to the common rail. Place a 10kΩ pull-up resistor between the DATA pin and 3V3. This is required for reliable single-wire communication — without it, readings will be intermittent or fail entirely.
💡 Use DHT22 if you need better accuracy (±0.5°C, ±2–5% RH). DHT11 is cheaper but less precise (±2°C, ±5% RH). The code works for both — just change DHT11 to DHT22 in the type definition.
4
Wire the PIR motion sensor (HC-SR501)
Connect PIR OUT to D6, VCC to the NodeMCU VIN pin (5V when powered via USB), and GND to the common rail. The HC-SR501 requires 5V to function — it will not trigger correctly on 3.3V. Its output is 3.3V HIGH when motion is detected, which is safe to read on D6.
💡 The HC-SR501 has two orange trimpots: one adjusts detection range (3–7m), the other sets the trigger-hold time (5–300 sec). Set both to minimum initially for fast testing.
5
Connect the LDR light sensor module
Connect the module DO (digital output) to D7, VCC to 3V3, and GND to the common rail. The onboard potentiometer sets the light threshold — when ambient light drops below the threshold, DO goes HIGH. Turn the pot clockwise to increase sensitivity.
6
Wire the RGB LED
Connect the common cathode (longest leg or GND pad) to ground. Wire the R, G, and B anodes through individual 100Ω resistors to D3, D5, and D8 respectively. These pins support PWM on the ESP8266, allowing full colour mixing via analogWrite().
⚠️ D8 (GPIO15) must be LOW at boot for the NodeMCU to start correctly. The RGB LED's blue channel being off at boot satisfies this requirement — do not add a pull-up on D8.
7
Connect all grounds to a common rail
All sensor GND pins, the RGB LED cathode, and the NodeMCU GND must share the same ground node. Use the breadboard's negative rail as the GND bus. This ensures stable analog readings and prevents floating sensor outputs.
8
Update WiFi credentials and upload
In the sketch below, update ssid and password with your WiFi network details. Select NodeMCU 1.0 (ESP-12E Module) as the board in Arduino IDE and set the upload speed to 115200. Upload via USB. Open Serial Monitor at 115200 baud to verify sensor readings and the assigned IP address.
📡 Once connected, navigate to the NodeMCU's IP address in a browser on the same network to see the live sensor dashboard.

💻 Full Source Code

This sketch reads all four sensors every 2 seconds, prints data to the Serial Monitor, and serves a simple live JSON endpoint over WiFi for dashboard integration.

SmartHealthMonitor.ino
/*
 * ESP8266 NodeMCU Smart Health & Environment Monitor
 * MakeMindz.com
 * Sensors: Pulse (A0), DHT22 (D4), PIR (D6), LDR (D7)
 * RGB LED status: D3 (R), D5 (G), D8 (B)
 */

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DHT.h>

// WiFi credentials
const char* ssid     = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

// Pin definitions
#define PULSE_PIN  A0
#define DHT_PIN    D4
#define DHT_TYPE   DHT22    // Change to DHT11 if needed
#define PIR_PIN    D6
#define LDR_PIN    D7
#define LED_R      D3
#define LED_G      D5
#define LED_B      D8

DHT dht(DHT_PIN, DHT_TYPE);
ESP8266WebServer server(80);

float temperature, humidity;
int   pulseValue;
bool  motionDetected, lowLight;

void setRGB(int r, int g, int b) {
  analogWrite(LED_R, r);
  analogWrite(LED_G, g);
  analogWrite(LED_B, b);
}

void readSensors() {
  temperature     = dht.readTemperature();
  humidity        = dht.readHumidity();
  pulseValue      = analogRead(PULSE_PIN);
  motionDetected  = digitalRead(PIR_PIN);
  lowLight        = digitalRead(LDR_PIN);

  // RGB feedback: green=normal, red=motion, blue=low light
  if (motionDetected)      setRGB(255, 0,   0);
  else if (lowLight)       setRGB(0,   0,   255);
  else                     setRGB(0,   150, 0);

  Serial.printf("Temp: %.1f°C  Humidity: %.1f%%  Pulse: %d  Motion: %s  LowLight: %s\n",
    temperature, humidity, pulseValue,
    motionDetected ? "YES" : "no",
    lowLight       ? "YES" : "no");
}

void handleRoot() {
  String json = "{";
  json += "\"temperature\":"    + String(temperature, 1) + ",";
  json += "\"humidity\":"       + String(humidity, 1)    + ",";
  json += "\"pulse\":"          + String(pulseValue)        + ",";
  json += "\"motion\":"         + String(motionDetected)    + ",";
  json += "\"lowLight\":"       + String(lowLight)          + "}";
  server.send(200, "application/json", json);
}

void setup() {
  Serial.begin(115200);
  dht.begin();
  pinMode(PIR_PIN, INPUT);
  pinMode(LDR_PIN, INPUT);
  pinMode(LED_R,   OUTPUT);
  pinMode(LED_G,   OUTPUT);
  pinMode(LED_B,   OUTPUT);
  setRGB(0, 0, 0);

  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
  Serial.println("\nConnected! IP: " + WiFi.localIP().toString());

  server.on("/", handleRoot);
  server.begin();
  Serial.println("Web server started — open IP in browser for JSON data");
}

void loop() {
  server.handleClient();
  readSensors();
  delay(2000);
}
The web server returns a JSON response at the NodeMCU's IP address — connect this to Node-RED, Blynk, Home Assistant, or any custom dashboard by fetching http://[IP]/ every few seconds.

📡 IoT Platform Integration

The ESP8266's built-in WiFi means this monitor can push data to any IoT platform without extra hardware:

🏠 Home Assistant (ESPHome)
📊 Blynk dashboard
🔁 MQTT / Node-RED
🔥 Firebase Realtime DB
📈 ThingSpeak charts
📱 Telegram bot alerts
📋 Google Sheets logging
🌐 Custom web dashboard
💡 The ESPHome YAML config shown in the project (AHT10 + ADC + GPIO binary sensors + RGB LED) is directly compatible with Home Assistant — flash using the ESPHome add-on and your sensors appear as entities automatically, no extra code needed.

🖥️ Run the Simulation

Test the circuit online before building on hardware:

🏥 Applications

  • IoT-based health monitoring — remote patient vitals tracking with WiFi data push
  • Smart home automation — motion-triggered lighting, climate-based HVAC control
  • Patient monitoring prototype — bedside heart rate and temperature logger
  • Environmental monitoring — office or server room temperature/humidity alerting
  • Wearable and remote sensing — battery-powered variant for field deployments
  • Engineering final-year projects — multi-sensor IoT system with cloud dashboard

© 2026 MakeMindz.com · ESP8266 NodeMCU Smart Health & Environment Monitoring Tutorial · MIT Licensed

Built for STEM learners, IoT developers & healthcare innovators.

Comments

try for free