ULTRASONIC SENSOR

Comprehensive Home Automation with Multi-Sensor Integration

The Comprehensive Home Automation System presented here leverages an array of sensors to create an intelligent and responsive living space.

The integration of ultrasonic distance measurement, light-dependent resistors (LDRs), gas concentration monitoring, PIR motion sensing, and temperature control using Arduino demonstrates a holistic approach to home automation.

The ultrasonic sensor efficiently manages lighting based on occupancy, while LDRs dynamically adjust light levels according to ambient conditions.

Gas sensors contribute to indoor air quality monitoring, PIR motion sensors enhance security, and temperature sensors facilitate climate control. The inclusion of a buzzer for close-range obstacles adds an extra layer of safety.

The circuit seamlessly combines ultrasonic, LDR, gas, PIR, and temperature sensors with the Arduino board. LEDs associated with each sensor visually represent their outputs, creating an easily understandable and expandable system.

The straightforward circuit design provides a solid foundation for users to build upon and customise according to their specific needs.

Component List:

NameQuantityComponent
U11Arduino Uno R3
PING11Ultrasonic Distance Sensor
Meter11Voltage Multimeter
PIEZO1
PIEZO2
PIEZO3
3Piezo
D1
D2
D6
D7
4Red LED
D31Orange LED
D41Yellow LED
D5
D8
2Green LED
R1
R2
R3
R4
R5
R7
6220 Ω Resistor
PIR111.2920847260530763 , -154.544126460279 , -107.88904638309225 PIR Sensor
R6
R11
21 kΩ Resistor
U21Temperature Sensor [TMP36]
R81Photoresistor
R91550 Ω Resistor
GAS11Gas Sensor
R1014.7 kΩ Resistor

Arduino Code:

const int PingPin = 7;
const int buzzPin = 4;
// const int sensorPin = A0;
// set pin numbers
// const won't change
const int ledPin = 2; // the number of the LED pin
const int ldrPin = A1; // the number of the LDR pin
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
#define PIN_LED_1 9
#define PIN_LED_2 8
#define PIN_LED_3 6
#define PIN_LED_4 5
#define PIN_LED_5 3
#define PIN_GAS A3
// Temperature Sensor
const int delayBetweenReads = 5000;
const int sensorPin = A5;
void setup() {
// initialize serial communication
Serial.begin(9600);
pinMode(buzzPin, OUTPUT);
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
pinMode(ldrPin, INPUT); // initialize the LDR pin as an input
pinMode(PIN_LED_1, OUTPUT);
pinMode(PIN_LED_2, OUTPUT);
pinMode(PIN_LED_3, OUTPUT);
pinMode(PIN_LED_4, OUTPUT);
pinMode(PIN_LED_5, OUTPUT);
pinMode(10, INPUT); // signal of PIR sensor
pinMode(11, OUTPUT); // output for motion detection
}
void loop() {
// establish variables for the duration of Ping
// give a short low pulse beforehand to ensure a clean high pulse
long duration, cm;
pinMode(PingPin, OUTPUT);
digitalWrite(PingPin, LOW);
delayMicroseconds(2);
digitalWrite(PingPin, HIGH);
delayMicroseconds(5);
digitalWrite(PingPin, LOW);
pinMode(PingPin, INPUT);
duration = pulseIn(PingPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.print("Distance: ");
Serial.print(cm);
Serial.print("cm");
delay(1000);
Serial.println();
if (cm < 100) {
digitalWrite(buzzPin, HIGH);
} else {
digitalWrite(buzzPin, LOW);
}
int ldrStatus = analogRead(ldrPin); // read the status of the LDR value
Serial.print(ldrStatus);
// check if the LDR status is <= 300
// if it is, the LED is HIGH
if (ldrStatus <= 300) {
digitalWrite(ledPin, HIGH);
// turn LED on
} else {
digitalWrite(ledPin, LOW); // turn LED off
}
int value = map(analogRead(PIN_GAS), 300, 750, 0, 100);
digitalWrite(PIN_LED_1, HIGH);
digitalWrite(PIN_LED_2, value >= 20 ? HIGH : LOW);
digitalWrite(PIN_LED_3, value >= 40 ? HIGH : LOW);
digitalWrite(PIN_LED_4, value >= 60 ? HIGH : LOW);
digitalWrite(PIN_LED_5, value >= 80 ? HIGH : LOW);
if (digitalRead(10) == HIGH) // check if PIR is triggered
{
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
}
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
float voltage = (sensorVal / 1024.0) * 5.0;
Serial.print(", Volts C: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
float temperature = (voltage - 0.5) * 100;
Serial.println(temperature);
if (temperature <= -40 && temperature >= 30)
digitalWrite(13, LOW);
else if (temperature < 30)
digitalWrite(13, HIGH);
delay(100);
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}

This Comprehensive Home Automation System showcases the versatility of Arduino-based projects. Beyond the amalgamation of sensors for environmental monitoring, it serves as a stepping stone for further home automation endeavors.

Whether enhancing energy efficiency, bolstering security, or optimizing climate conditions, this project demonstrates the potential for a smart and adaptable home.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button