Skip to content

Commit a6da4e1

Browse files
authoredFeb 5, 2023
Add files via upload
1 parent 836282e commit a6da4e1

9 files changed

+979
-0
lines changed
 

‎README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Arduino iOT project
2+
![alt text](https://github.com/abhineetraj1/arduino-iot-project/blob/main/fav.png?raw=true)
3+
4+
RGB led blinking through website
5+
6+
Python + Arduino project.
7+
8+
## Installation
9+
1) Download Arduino IDE and python3.x
10+
2) Upload StandardFirmata.ino code in arduino
11+
3) Install python3.X and libraries in requirements.txt
12+
13+
``` pip3 install -r requirements.txt```
14+
15+
16+
## Circuit of Arduino
17+
18+
* Pin 2 = Positive terminal of buzzer
19+
* Pin 3 = Red terminal of rgb light
20+
* Pin 4 = Green terminal of rgb light
21+
* Pin 5 = Blue terminal of rgb light
22+
* GND = Negative terminal of buzzer
23+
* 5V = Cathode point of RGB light
24+
25+
## Execution
26+
* Connect arduino with your system
27+
* Open file StandardFirmata.ino and upload the folder
28+
* Open the folder of code
29+
* Open terminal in that folder
30+
* Enter folder code into terminal and hit enter
31+
```
32+
flask run -h 0.0.0.0
33+
```
34+
* Open any device that is connected to same network or wifi
35+
* Open the url (printed in the terminal)
36+
* Enjoy!!
37+
38+
### Note:-
39+
Make sure you have connected the laptop and the mobile with same network or wifi
40+
41+
## Uses
42+
* This can be used as an application in smart home system, where your can turn on and off appliances according to your will thorugh your mobile phone or devices connected under home network.
43+
* This can be used in smart office, where your can turn on and off office lights, systems ...etc according to your will thorugh your mobile phone or devices connected under home network.
44+
* This can be used as an application in smart class, where your can turn on and off hall lights according to your will thorugh your mobile phone or devices connected under home network.
45+
46+
## Programming languages used
47+
<a href="https://www.arduino.cc/" target="_blank" rel="noreferrer"> <img src="https://cdn.arduino.cc/header-footer/prod/assets/favicon-arduino/favicon.ico" alt="blender" width="40" height="40"/> </a><a href="https://www.python.org/" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/danielcranney/readme-generator/main/public/icons/skills/python-colored.svg" width="36" height="36" alt="Python" /></a>
48+
49+
## Author
50+
* [abhineetraj1](http://github.com/abhineetraj1)

‎StandardFirmata.ino

+823
Large diffs are not rendered by default.

‎app.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from time import sleep
2+
from flask import *
3+
from flask import render_template
4+
from pyfirmata import Arduino
5+
6+
# Trying to connect computer with boarding
7+
for i in range(1,6):
8+
try:
9+
ard=Arduino("COM"+str(i))
10+
break
11+
except:
12+
print("Error")
13+
14+
# Turning off all the switches in circuit
15+
ard.digital[3].write(1)
16+
ard.digital[4].write(1)
17+
ard.digital[2].write(0)
18+
ard.digital[5].write(1)
19+
20+
# Creating a function to give output through arduino
21+
def funcn(n):
22+
if "on" in n:
23+
if "red" in n:
24+
ard.digital[3].write(1)
25+
ard.digital[4].write(1)
26+
ard.digital[5].write(0)
27+
elif "green" in n:
28+
ard.digital[4].write(1)
29+
ard.digital[5].write(1)
30+
ard.digital[3].write(0)
31+
elif "blue" in n:
32+
ard.digital[3].write(1)
33+
ard.digital[5].write(1)
34+
ard.digital[4].write(0)
35+
elif "buzzer" in n:
36+
ard.digital[2].write(1)
37+
else:
38+
return "error"
39+
elif "off" in n:
40+
ard.digital[3].write(1)
41+
ard.digital[4].write(1)
42+
ard.digital[2].write(0)
43+
ard.digital[5].write(1)
44+
elif n == "emergency":
45+
# Declaring function for emergency, where buzzer will sound beep beep in loop
46+
ard.digital[5].write(0)
47+
for i in range(0,21):
48+
ard.digital[2].write(i%2)
49+
sleep(0.3)
50+
ard.digital[5].write(1)
51+
else:
52+
return "error"
53+
54+
#Setting up server and declaring routes
55+
app = Flask(__name__, template_folder="temp", static_folder="static")
56+
57+
# Making route for user handling
58+
@app.route("/", methods=["POST","GET"])
59+
def a():
60+
if request.method == "GET":
61+
return render_template("index.html")
62+
else:
63+
funcn(request.data.decode("utf-8"))
64+
return render_template("index.html")
65+
66+
# Made by Abhineet Raj (https://github.com/abhineetraj1)
67+
if __name__ == '__main__':
68+
app.run()

‎fav.png

60.8 KB
Loading

‎requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyfirmata
2+
flask

‎static/motherboard.png

14.8 KB
Loading

‎static/script.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function request_server(value) {
2+
var a = new XMLHttpRequest();
3+
a.open("POST","/", true);
4+
a.send(value);
5+
}

‎static/style.css

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
body{
2+
background: #13b90b;
3+
}
4+
.btn{
5+
padding: 3px;
6+
margin: 3px;
7+
background: white;
8+
font-size: 20px;
9+
border-radius: 8px;
10+
border: solid;
11+
}

‎temp/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>Arduino project</title>
7+
<link rel="stylesheet" type="text/css" href="/static/style.css">
8+
<link rel="shortcut icon" href="/static/motherboard.png">
9+
<script type="text/javascript" src="/static/script.js"></script>
10+
</head>
11+
<body>
12+
<button class="btn" onclick="request_server('on blue')">Turn on blue light</button><br>
13+
<button class="btn" onclick="request_server('on red')">Turn on red light</button><br>
14+
<button class="btn" onclick="request_server('on green')">Turn on green light</button><br>
15+
<button class="btn" onclick="request_server('on buzzer')">Turn on buzzer</button><br>
16+
<button class="btn" onclick="request_server('off')">Turn off</button><br>
17+
<button class="btn" onclick="request_server('emergency')">Emergency</button>
18+
<!--Made by Abhineet Raj (https://github.com/abhineetraj1)-->
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.