This program reads and processes data from three health-monitoring sensors (DHT11, KY-039, and AD8232) connected to an ESP8266 or Arduino. Based on the readings, it performs health checks and activates LEDs and a buzzer to indicate whether the readings are within normal ranges.
- DHT11 Sensor: Measures temperature.
- KY-039 Sensor: Measures pulse rate (heartbeats per minute).
- AD8232 Sensor: Measures ECG signals, which are used to estimate blood pressure (systolic and diastolic).
- Green LED: Indicates normal health parameters.
- Red LED and Buzzer: Indicate abnormal health parameters.
- The
DHT.h
library is included to interact with the DHT11 sensor. - The pins for the sensors and output components (LEDs and buzzer) are defined:
- DHTPIN (2): DHT11 data pin.
- KY039_PIN (A1): KY-039 Pulse Sensor connected to analog pin A1.
- AD8232_PIN (A0): AD8232 ECG Sensor connected to analog pin A0.
- LED and Buzzer Pins: Control green LED, red LED, and buzzer.
- Serial Communication: Initialized at
9600 baud
to send data to the serial monitor. - Sensor Initialization: The DHT sensor is started using
dht.begin()
. - Pin Modes: All LEDs and the buzzer are set as output, and their initial states are set to OFF.
The main logic runs continuously in the loop()
function:
- The temperature is read using the
dht.readTemperature()
function. - If the reading fails (
isnan
returns true), the program skips the current loop cycle to avoid invalid data processing.
- The raw signal from the KY-039 sensor is read using
analogRead(KY039_PIN)
. - The raw value (0-1023) is mapped to a heart rate range (60-100 BPM).
- The ECG signal is read from the AD8232 sensor using
analogRead(AD8232_PIN)
. - The raw ECG signal (0-1023) is mapped to approximate systolic (90-120 mmHg) and diastolic (60-80 mmHg) blood pressure ranges.
- Data is formatted as
temperature,pulseRate,systolicBP/diastolicBP
and sent to the serial monitor:- Example output:
36.5,72,110/75
- Example output:
-
The program checks if the sensor readings fall within normal health ranges:
- Temperature: 36.0°C to 37.5°C.
- Pulse Rate: 60 to 100 BPM.
- Blood Pressure:
- Systolic: 90 to 120 mmHg.
- Diastolic: 60 to 80 mmHg.
-
If all values are normal:
- Green LED: Turns ON.
- Red LED and Buzzer: Turn OFF.
-
If any value is abnormal:
- Red LED: Turns ON.
- Buzzer: Beeps (ON for 500ms, OFF for 500ms).
- Green LED: Turns OFF.
- The loop includes a
delay(1000)
to wait for 1 second before the next iteration. This ensures that the sensors have enough time to stabilize and provide accurate readings.
- Explain the Purpose: Monitor and display health parameters using sensors.
- Show Hardware Setup: Point out the DHT11, KY-039, AD8232 sensors, LEDs, and buzzer.
- Run the Program:
- Display real-time data in the serial monitor.
- Simulate abnormal conditions (e.g., change temperature or pulse inputs) to show LED and buzzer activation.
- Highlight Features:
- Real-time health monitoring.
- Immediate feedback through LEDs and buzzer.
- This program is a simple health-monitoring system.
- It collects real-time data, evaluates it against normal ranges, and provides visual and auditory feedback.
- The modular design makes it easy to expand with additional sensors or features in the future.