Skip to content

pikumandal2005/Python-Based-Smart-Fan-Controlling-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’‘ Mobile-Controlled Light using Arduino & Python πŸ“±πŸŒ A Smart Room Automation Project by Piku Mandal

πŸ‘¨β€πŸŽ“ About the Project Hi! I’m Piku Mandal, a 1st year B.Tech Electrical Engineering student at Ghani Khan Chowdhury Institute of Engineering And Technology (GKCIET), Malda.

This is my mini-project titled β€œAutomated Room”, where I control a relay-connected light using a mobile phone via a custom web interface built using Python Flask, with no Bluetooth or Wi-Fi module required.

🎯 Objective To remotely switch ON/OFF a room light using a mobile phone browser, where the phone sends the signal to a laptop server, and the laptop forwards that signal via USB serial to the Arduino, which controls the light using a relay module.

πŸ› οΈ Components Used Arduino Uno

Relay Module

Mobile Phone (with Wi-Fi)

Laptop (running Flask + Python)

USB cable (Arduino to laptop)

πŸ”Œ Step 1: Connect Relay/LED to Arduino Use the following pin connection for the relay module:

nginx Copy Edit Relay IN β†’ Arduino Pin 8
Relay VCC β†’ 5V
Relay GND β†’ GND You can connect a 220V light bulb to the relay using the COM and NO terminals.

πŸ‘¨β€πŸ’» Step 2: Upload Arduino Code Upload this code to your Arduino using the Arduino IDE:

cpp Copy Edit String voice;

void setup() { Serial.begin(9600); pinMode(8, OUTPUT); // Relay or LED pin digitalWrite(8, LOW); }

void loop() { if (Serial.available()) { voice = Serial.readStringUntil('\n'); voice.trim(); // Remove newline/space

if (voice == "ON") {
  digitalWrite(8, HIGH);  // Light ON
} else if (voice == "OFF") {
  digitalWrite(8, LOW);   // Light OFF
}

} } βœ… Step 3: Python Flask Web Interface Save the following code as web_arduino_control.py on your laptop:

python Copy Edit from flask import Flask, request, render_template_string import serial

Replace 'COM3' with your actual Arduino COM port

arduino = serial.Serial('COM3', 9600)

app = Flask(name)

HTML = """

<title>Automated Room - Piku Mandal</title> <style> body { background: #f2f2f2; font-family: Arial, sans-serif; text-align: center; padding-top: 50px; } .container { background: white; display: inline-block; padding: 30px; border-radius: 20px; box-shadow: 0 0 20px rgba(0,0,0,0.1); } h1 { color: #007acc; margin-bottom: 10px; } h2, h3 { margin: 5px 0; } button { font-size: 24px; padding: 15px 30px; margin: 20px; border: none; border-radius: 10px; background-color: #007acc; color: white; cursor: pointer; } button:hover { background-color: #005f99; } </style>

Automated Room Control

Piku Mandal

Electrical (B.Tech), Sem 2

Project: Automated Room

πŸ’‘ Turn ON Light πŸ’‘ Turn OFF Light
"""

@app.route("/", methods=["GET", "POST"]) def control(): if request.method == "POST": cmd = request.form["command"] arduino.write((cmd + '\n').encode()) return render_template_string(HTML)

if name == "main": app.run(host="0.0.0.0", port=5000) βœ… Step 4: Run the Project

  1. Install required Python libraries: bash Copy Edit pip install flask pyserial
  2. Replace COM3 with your actual Arduino port (like COM4).
  3. Run the server: bash Copy Edit python web_arduino_control.py πŸ“± Step 5: Control from Your Phone Connect your mobile and laptop to the same Wi-Fi network.

On your laptop, check your IP address using:

nginx Copy Edit ipconfig (on CMD) Open browser on mobile and go to:

cpp Copy Edit http://:5000 Example: http://192.168.1.5:5000

Tap "Turn ON Light" or "Turn OFF Light" to control the bulb in real-time!

πŸŽ“ Conclusion This project showcases a low-cost, easy-to-build smart room automation system using Arduino and Python, without needing expensive modules or IoT devices.

πŸ’‘ Want to expand it? You can add:

Fan control

Multiple rooms

Google Assistant integration

Voice input via mobile

πŸ“ƒ Credits Project by: πŸ‘¨β€πŸŽ“ Piku Mandal πŸ“š 1st Year, B.Tech in Electrical Engineering 🏫 Ghani Khan Chowdhury Institute of Engineering and Technology (GKCIET) πŸ“… Semester 2

About

My Projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published