DEV Community

Alice Brown
Alice Brown

Posted on

Home Automation System with Arduino and C++

Hello Devs!
I am a student of mechatronics engineering, and I love embedded systems. Although I am a learner, I've seen multiple projects of my seniors, and I am excited to start practicing in this field. here is my first project in Arduino IDE.
This project offers a substantial learning opportunity for professionals in the area by fusing physical hardware and C++ programming to enable the management of a variety of household appliances.

The project's main goal is to use an Arduino board to create a simple home automation system. The goal of this system is to make it possible to operate LED lights, a temperature sensor to monitor the surrounding environment, and a servo motor that doubles as a door lock. Control can be applied manually using traditional switches or using a smartphone application. The usage of C++ is required for the implementation. This is my code:
`

include

include

define DHTPIN 7

define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

Servo myServo;
int ledPin = 13;
int buttonPin1 = 2;
int buttonPin2 = 3;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);

myServo.attach(9);
Serial.begin(9600);
dht.begin();
}

void loop() {

float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");

if (digitalRead(buttonPin1) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

// Check button state for Servo motor (Door lock control)
if (digitalRead(buttonPin2) == HIGH) {
myServo.write(90);
} else {
myServo.write(0); }

delay(200);
}`
To enable the remote control of many devices, a Bluetooth terminal application has been utilized to transmit orders to an Arduino board over Bluetooth technology.

For instance, the command 'L' turns on an LED light, while the command 'D' starts a servo motor to unlock a door. The system has been configured to react to particular orders. It is expected that future advancements will involve the development of a custom application using MIT App Inventor with the goal of enhancing the system control user interface.

This project has provided significant educational benefits, greatly enhancing the understanding of Arduino hardware and C++ programming languages. The integration of sensors, motors, and Bluetooth control mechanisms has opened up numerous possibilities for further exploration. As progress continues, it is expected that the system will be refined and augmented with additional features.

Input from peers and experts in the domain is encouraged, as is the sharing of experiences related to similar home automation projects that incorporate Arduino or C++. Such collaborative discussions are intended to promote knowledge sharing and foster collective expertise in the field.

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay