This circuit is designed to monitor environmental conditions using various sensors and display the data on an LCD. It includes temperature and humidity sensing, sound detection, and heartbeat monitoring. The circuit also features visual and auditory alerts using LEDs and a buzzer, and it controls a relay to manage a fan based on temperature thresholds.
Arduino Uno R3
LED: Two Pin (red)
DHT22
KY 038
LED: Two Pin (yellow)
LED: Two Pin (green)
Lcd 20x4 i2c
220 fan
240v Power Source
PTC
SSR-25A
buzzer
power jack
POSITIF
of the power jack.+
of DHT22, +
of KY 038, and 5v
of Lcd 20x4 i2c.cathode
of red LED, GND
of buzzer, -
of SSR-25A, -
of DHT22, G
of KY 038, cathode
of yellow LED, cathode
of green LED, and GND
of Lcd 20x4 i2c.A0
of KY 038.SCA
of Lcd 20x4 i2c.SCL
of Lcd 20x4 i2c.PIN
of buzzer.anode
of red LED.anode
of yellow LED.anode
of green LED.+
of SSR-25A.Out
of DHT22.GND
of Arduino Uno R3.7
of Arduino Uno R3.5V
of Arduino Uno R3.2
of Arduino Uno R3.GND
of Arduino Uno R3.5V
of Arduino Uno R3.GND
of Arduino Uno R3.A0
of Arduino Uno R3.GND
of Arduino Uno R3.6
of Arduino Uno R3.GND
of Arduino Uno R3.5
of Arduino Uno R3.GND
of Arduino Uno R3.5V
of Arduino Uno R3.A4/SDA
of Arduino Uno R3.A5/SCL
of Arduino Uno R3.Neutral
of PTC.Live
of PTC.1-in
of SSR-25A.Neutral
of PTC.Neutral
of 240v Power Source and N
of 220 fan.L
of 220 fan and 2-out
of SSR-25A.GND
of Arduino Uno R3.3
of Arduino Uno R3.Live
of 240v Power Source.Live
of PTC.8
of Arduino Uno R3.GND
of Arduino Uno R3.Power Jack
of Arduino Uno R3.#include <DHT.h>
#include <LiquidCrystal_I2C.h>
// DHT22 configuration
#define DHTPIN 2 // Pin connected to the DHT22 data pin
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
// LED pins
#define GREEN_LED 4
#define YELLOW_LED 5
#define RED_LED 6
// Sound sensor pins
#define SOUND_SENSOR_PIN 3 // Digital out pin
#define SOUND_SENSOR_ANALOG_PIN A1 // Analog out pin
// Heartbeat sensor pin
#define HEARTBEAT_PIN A0
// Buzzer pin
#define BUZZER_PIN 7
// Relay pin
#define RELAY_PIN 8
// LCD configuration
LiquidCrystal_I2C lcd(0x27, 20, 4); // Adjust the I2C address if necessary
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize the DHT sensor
dht.begin();
// Initialize LCD
lcd.begin(20, 4); // Use 20 columns and 4 rows
lcd.backlight();
// Initialize pins
pinMode(GREEN_LED, OUTPUT);
pinMode(YELLOW_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
pinMode(SOUND_SENSOR_PIN, INPUT);
pinMode(HEARTBEAT_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(RELAY_PIN, OUTPUT);
// Turn on relay initially
digitalWrite(RELAY_PIN, HIGH);
}
void loop() {
// Read temperature and humidity
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Read heartbeat sensor value
int heartbeatValue = analogRead(HEARTBEAT_PIN);
float heartbeatRate = map(heartbeatValue, 0, 1023, 60, 160); // Adjust mapping as needed
// Read sound sensor value
int soundDetected = digitalRead(SOUND_SENSOR_PIN);
int soundLevel = analogRead(SOUND_SENSOR_ANALOG_PIN); // Read analog sound level
// Display temperature, humidity, and heartbeat on LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print("C ");
lcd.print("Hum: ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Heart: ");
lcd.print(heartbeatRate);
lcd.print(" bpm