The circuit is designed to monitor various health parameters using an array of sensors, including a GSR sensor, an AD8232 heart rate monitor, a DFRobot DHT22 temperature and humidity sensor, a Myoware 2.0 muscle sensor, and a SIM800L GSM module for communication. The Arduino UNO serves as the central microcontroller, interfacing with the sensors and controlling a relay module, a buzzer, and an LED indicator. The data collected from the sensors is displayed on a 16x2 I2C LCD and can be sent via SMS using the GSM module. The circuit is powered by a 12V power supply, with the Arduino regulating the voltage for the other components.
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
// Pin Definitions
const int gsrPin = A0; // GSR Sensor
const int ecgPin = A1; // ECG Sensor
const int dhtPin = 2; // DHT22
const int emgPin = A5; // EMG Sensor
const int relayPin = 7; // Relay for steam generator
const int buzzerPin = 8; // Buzzer
const int ledPin = 9; // Red LED
// GSM Module Pins
SoftwareSerial gsmSerial(10, 11); // RX, TX
// DHT Sensor Initialization
DHT dht(dhtPin, DHT22);
// LCD Display Initialization
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Timing Variables
unsigned long startTime;
const unsigned long maxDuration = 20 * 60 * 1000; // 20 minutes
const unsigned long alertTime = 15 * 60 * 1000; // 15 minutes
void setup() {
Serial.begin(9600);
gsmSerial.begin(9600);
dht.begin();
pinMode(relayPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(relayPin, LOW); // Turn off steam generator
digitalWrite(buzzerPin, LOW); // Turn off buzzer
digitalWrite(ledPin, LOW); // Turn off LED
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.backlight();
startTime = millis();
}
void loop() {
unsigned long currentTime = millis();
if (currentTime - startTime >= maxDuration) {
digitalWrite(relayPin, LOW); // Turn off steam generator
return; // Stop the loop after 20 minutes
}
if (currentTime - startTime >= alertTime) {
digitalWrite(buzzerPin, HIGH); // Turn on buzzer
}
// Read Sensors
int gsrValue = analogRead(gsrPin);
int ecgValue = analogRead(ecgPin);
float temperature = dht.readTemperature();
int emgValue = analogRead(emgPin); // Read EMG sensor
// Control Steam Generator based on Temperature
if (temperature < 40) {
digitalWrite(relayPin, HIGH); // Turn on steam generator
} else if (temperature > 46) {
digitalWrite(relayPin, LOW); // Turn off steam generator
}
// Stop steam generator if hydration exceeds limit
if (gsrValue > 600) { // Example threshold
digitalWrite(relayPin, LOW); // Turn off steam generator
digitalWrite(buzzerPin, HIGH); // Turn on buzzer
digitalWrite(ledPin, HIGH); // Turn on LED
}
// Prepare data for GSM
String message = "GSR: " + String(gsrValue) +
", ECG: " + String(ecgValue) +
", Temp: " + String(temperature) +
", EMG: " + String(emgValue);
// Send data via GSM
sendSMS(message);
// Display on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: " + String(temperature) + "C");
lcd.setCursor(0, 1);
lcd.print("GSR: " + String(gsrValue));
delay(2000); // Update every 2 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ECG: " + String(ecgValue));
lcd.setCursor(0, 1);
lcd.print("EMG: " + String(emgValue));
delay(2000); // Update every 2 seconds
}
void sendSMS(String message) {
gsmSerial.println("AT+CMGF=1"); // Set SMS mode
delay(100);
gsmSerial.print("AT+CMGS=\"+1234567890\""); // Replace with doctor's phone number
delay(100);
gsmSerial.println(message); // Message content
delay(100);
gsmSerial.write(26); // Send Ctrl+Z to send SMS
delay(100);
}
This code is responsible for initializing the sensors and communication modules, reading sensor data, controlling the relay,