Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I_Helmet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 62
I_Helmet
Commits
4dd20bd1
Commit
4dd20bd1
authored
Jul 19, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intergrated with others
parent
f1d870fb
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
900 additions
and
0 deletions
+900
-0
IT18021080/IoT Project/Intergrated with other/arduino/datAsendhc12/datAsendhc12.ino
...ergrated with other/arduino/datAsendhc12/datAsendhc12.ino
+25
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/KY039.ino
...t/Intergrated with other/arduino/test1_i_helmet/KY039.ino
+225
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/Vibrator_Sensor.ino
...ted with other/arduino/test1_i_helmet/Vibrator_Sensor.ino
+5
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/dust_sensor.ino
...rgrated with other/arduino/test1_i_helmet/dust_sensor.ino
+31
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/gas_sensors.ino
...rgrated with other/arduino/test1_i_helmet/gas_sensors.ino
+9
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/piezo_sensor.ino
...grated with other/arduino/test1_i_helmet/piezo_sensor.ino
+4
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/send_data.ino
...tergrated with other/arduino/test1_i_helmet/send_data.ino
+8
-0
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/test1_i_helmet.ino
...ated with other/arduino/test1_i_helmet/test1_i_helmet.ino
+155
-0
IT18021080/IoT Project/Intergrated with other/dash/main.py
IT18021080/IoT Project/Intergrated with other/dash/main.py
+128
-0
IT18021080/IoT Project/Intergrated with other/dash/test.py
IT18021080/IoT Project/Intergrated with other/dash/test.py
+40
-0
IT18021080/IoT Project/Intergrated with other/dash/test2.py
IT18021080/IoT Project/Intergrated with other/dash/test2.py
+70
-0
IT18021080/IoT Project/Intergrated with other/zserver/manage.py
...1080/IoT Project/Intergrated with other/zserver/manage.py
+22
-0
IT18021080/IoT Project/Intergrated with other/zserver/zserver/__init__.py
...roject/Intergrated with other/zserver/zserver/__init__.py
+0
-0
IT18021080/IoT Project/Intergrated with other/zserver/zserver/asgi.py
...oT Project/Intergrated with other/zserver/zserver/asgi.py
+16
-0
IT18021080/IoT Project/Intergrated with other/zserver/zserver/settings.py
...roject/Intergrated with other/zserver/zserver/settings.py
+125
-0
IT18021080/IoT Project/Intergrated with other/zserver/zserver/urls.py
...oT Project/Intergrated with other/zserver/zserver/urls.py
+21
-0
IT18021080/IoT Project/Intergrated with other/zserver/zserver/wsgi.py
...oT Project/Intergrated with other/zserver/zserver/wsgi.py
+16
-0
No files found.
IT18021080/IoT Project/Intergrated with other/arduino/datAsendhc12/datAsendhc12.ino
0 → 100644
View file @
4dd20bd1
#include <SoftwareSerial.h>
SoftwareSerial
HC12
(
10
,
11
);
void
setup
()
{
// put your setup code here, to run once:
HC12
.
begin
(
9600
);
Serial
.
begin
(
9600
);
Serial
.
flush
();
// HC12.flush();
}
void
loop
()
{
// put your main code here, to run repeatedly:
datasend
();
}
char
datasend
(){
while
(
HC12
.
available
())
{
Serial
.
write
(
HC12
.
read
());
}
while
(
Serial
.
available
())
{
HC12
.
write
(
Serial
.
read
());
}
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/KY039.ino
0 → 100644
View file @
4dd20bd1
int
preheart
()
{
period
=
0
;
samples
=
0
;
for
(
int
i
=
0
;
i
<
maxperiod_siz
;
i
++
)
{
readsIRMM
[
i
]
=
0
;
readsREDMM
[
i
]
=
0
;
}
for
(
int
i
=
0
;
i
<
measures
;
i
++
)
{
measuresPeriods
[
i
]
=
0
;
measuresR
[
i
]
=
0
;
}
for
(
int
i
=
0
;
i
<
samp_siz
;
i
++
)
{
readsIR
[
i
]
=
0
;
readsRED
[
i
]
=
0
;
}
sumIR
=
0
;
sumRED
=
0
;
ptr
=
0
;
}
String
heart
()
{
// turn on IR LED
digitalWrite
(
REDLed
,
LOW
);
digitalWrite
(
IRLed
,
HIGH
);
n
=
0
;
start
=
millis
();
reader
=
0.
;
do
{
reader
+=
analogRead
(
sensorPin
);
n
++
;
}
while
(
millis
()
<
start
+
T
);
reader
/=
n
;
// we got an average
sumIR
-=
readsIR
[
ptr
];
sumIR
+=
reader
;
readsIR
[
ptr
]
=
reader
;
lastIR
=
sumIR
/
samp_siz
;
digitalWrite
(
REDLed
,
HIGH
);
digitalWrite
(
IRLed
,
LOW
);
n
=
0
;
start
=
millis
();
reader
=
0.
;
do
{
reader
+=
analogRead
(
sensorPin
);
n
++
;
}
while
(
millis
()
<
start
+
T
);
reader
/=
n
;
// we got an average
// Add the newest measurement to an array
// and subtract the oldest measurement from the array
// to maintain a sum of last measurements
sumRED
-=
readsRED
[
ptr
];
sumRED
+=
reader
;
readsRED
[
ptr
]
=
reader
;
lastRED
=
sumRED
/
samp_siz
;
// R CALCULATION
// save all the samples of a period both for IR and for RED
readsIRMM
[
ptrMM
]
=
lastIR
;
readsREDMM
[
ptrMM
]
=
lastRED
;
ptrMM
++
;
ptrMM
%=
maxperiod_siz
;
samplesCounter
++
;
//
// if I've saved all the samples of a period, look to find
// max and min values and calculate R parameter
if
(
samplesCounter
>=
samples
)
{
samplesCounter
=
0
;
IRmax
=
0
;
IRmin
=
1023
;
REDmax
=
0
;
REDmin
=
1023
;
for
(
int
i
=
0
;
i
<
maxperiod_siz
;
i
++
)
{
if
(
readsIRMM
[
i
]
>
IRmax
)
IRmax
=
readsIRMM
[
i
];
if
(
readsIRMM
[
i
]
>
0
&&
readsIRMM
[
i
]
<
IRmin
)
IRmin
=
readsIRMM
[
i
];
readsIRMM
[
i
]
=
0
;
if
(
readsREDMM
[
i
]
>
REDmax
)
REDmax
=
readsREDMM
[
i
];
if
(
readsREDMM
[
i
]
>
0
&&
readsREDMM
[
i
]
<
REDmin
)
REDmin
=
readsREDMM
[
i
];
readsREDMM
[
i
]
=
0
;
}
R
=
(
(
REDmax
-
REDmin
)
/
REDmin
)
/
(
(
IRmax
-
IRmin
)
/
IRmin
)
;
}
// check that the Ear is placed inside
// the sensor. If the Ear is missing
// RED curve is under the IR.
//
if
(
lastRED
<
lastIR
)
{
if
(
finger_status
==
true
)
{
finger_status
=
false
;
Serial
.
print
(
"No Ear ?"
);
}
}
else
{
if
(
finger_status
==
false
)
{
finger_status
=
true
;
}
}
float
avR
=
0
;
int
avBPM
;
int
SpO2
=
-
19
*
R
+
112
;
if
(
finger_status
==
true
)
{
// lastIR holds the average of the values in the array
// check for a rising curve (= a heart beat)
if
(
lastIR
>
beforeIR
)
{
rise_count
++
;
// count the number of samples that are rising
if
(
!
rising
&&
rise_count
>
rise_threshold
)
{
rising
=
true
;
measuresR
[
m
]
=
R
;
measuresPeriods
[
m
]
=
millis
()
-
last_beat
;
last_beat
=
millis
();
int
period
=
0
;
for
(
int
i
=
0
;
i
<
measures
;
i
++
)
period
+=
measuresPeriods
[
i
];
// calculate average period and number of samples
// to store to find min and max values
period
=
period
/
measures
;
samples
=
period
/
(
2
*
T
);
int
avPeriod
=
0
;
int
c
=
0
;
// c stores the number of good measures (not floating more than 10%),
// in the last 10 peaks
for
(
int
i
=
1
;
i
<
measures
;
i
++
)
{
if
(
(
measuresPeriods
[
i
]
<
measuresPeriods
[
i
-
1
]
*
1.1
)
&&
(
measuresPeriods
[
i
]
>
measuresPeriods
[
i
-
1
]
/
1.1
)
)
{
c
++
;
avPeriod
+=
measuresPeriods
[
i
];
avR
+=
measuresR
[
i
];
}
}
m
++
;
m
%=
measures
;
// bpm and R shown are calculated as the
// average of at least 5 good peaks
avBPM
=
60000
/
(
avPeriod
/
c
)
;
avR
=
avR
/
c
;
// if there are at last 5 measures
// lcd.setCursor(12, 1);
if
(
c
==
0
)
Serial
.
println
(
' '
);
// if there are at least 5 good measures...
if
(
c
>
4
)
{
//
// SATURTION IS A FUNCTION OF R (calibration)
// Y = k*x + m
// k and m are calculated with another oximeter
int
SpO2
=
-
19
*
R
+
112
;
// lcd.setCursor(4, 0);
if
(
avBPM
>
40
&&
avBPM
<
220
)
// lcd.print(String(avBPM) + " "); //else lcd.print("---");
Serial
.
println
(
' '
);
// lcd.setCursor(4, 1);
if
(
SpO2
>
70
&&
SpO2
<
150
)
Serial
.
println
(
' '
);
// lcd.print( " " + String(SpO2) + "% "); //else lcd.print("--% ");
}
else
{
if
(
c
<
3
)
{
}
}
}
}
else
{
// Ok, the curve is falling
rising
=
false
;
rise_count
=
0
;
// lcd.setCursor(3, 0); lcd.print(" ");
}
// to compare it with the new value and find peaks
beforeIR
=
lastIR
;
}
// finger is inside
if
(
finger_status
==
true
)
{
Serial
.
println
(
"SpO2 = "
);
Serial
.
println
(
SpO2
);
Serial
.
println
(
"BPM = "
);
Serial
.
println
(
avBPM
);
Serial
.
println
();
}
else
{
Serial
.
println
(
"No Finger"
);
}
if
(
60
<
avBPM
<
100
)
{
digitalWrite
(
9
,
HIGH
);
digitalWrite
(
13
,
LOW
);
}
else
{
digitalWrite
(
9
,
LOW
);
}
if
(
avBPM
>
120
)
{
digitalWrite
(
13
,
HIGH
);
digitalWrite
(
9
,
LOW
);
}
else
if
(
avBPM
<
40
)
{
digitalWrite
(
13
,
HIGH
);
digitalWrite
(
9
,
LOW
);
}
ptr
++
;
ptr
%=
samp_siz
;
String
send_vals
=
String
(
SpO2
)
+
","
+
String
(
avBPM
);
return
send_vals
;
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/Vibrator_Sensor.ino
0 → 100644
View file @
4dd20bd1
int
vibrator
()
{
// read the state of the pushbutton value:
buttonState
=
digitalRead
(
buttonPin
);
return
buttonState
;
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/dust_sensor.ino
0 → 100644
View file @
4dd20bd1
String
dust_sensor
(){
digitalWrite
(
ledPower
,
LOW
);
delayMicroseconds
(
samplingTime
);
voMeasured
=
analogRead
(
measurePin
);
delayMicroseconds
(
deltaTime
);
digitalWrite
(
ledPower
,
HIGH
);
delayMicroseconds
(
sleepTime
);
calcVoltage
=
voMeasured
*
(
5.0
/
1024
);
dustDensity
=
0.17
*
calcVoltage
-
0.1
;
if
(
dustDensity
<
0
)
{
dustDensity
=
0.00
;
}
// Serial.println("Raw Signal Value (0-1023):");
// Serial.println(voMeasured);
//
// Serial.println("Voltage:");
// Serial.println(calcVoltage);
//
// Serial.println("Dust Density:");
// Serial.println(dustDensity);
delay
(
1000
);
String
values
=
String
(
voMeasured
)
+
","
+
String
(
calcVoltage
)
+
","
+
String
(
dustDensity
);
return
values
;
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/gas_sensors.ino
0 → 100644
View file @
4dd20bd1
int
analogread
(
int
value
)
{
int
sensorValue
=
analogRead
(
value
);
// print out the value you read:
// Serial.print("sensor analog :");
// Serial.println(sensorValue);
delay
(
1
);
// delay in between reads for stability
return
sensorValue
;
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/piezo_sensor.ino
0 → 100644
View file @
4dd20bd1
int
piezo_sensor
(){
int
t
=
analogRead
(
A0
);
return
t
;
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/send_data.ino
0 → 100644
View file @
4dd20bd1
int
datasendrec
(
String
str1
){
while
(
HC12
.
available
()){
Serial
.
write
(
HC12
.
read
());
}
// while(Serial.available()){
HC12
.
println
(
str1
);
// }
}
IT18021080/IoT Project/Intergrated with other/arduino/test1_i_helmet/test1_i_helmet.ino
0 → 100644
View file @
4dd20bd1
#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial
HC12
(
10
,
11
);
int
gasSensor1
=
A8
;
int
gasSensor2
=
A9
;
int
gasSensor3
=
A10
;
int
gasSensor4
=
A11
;
int
gasSensor5
=
A13
;
int
measurePin
=
A5
;
int
ledPower
=
12
;
//vib
const
int
buttonPin
=
2
;
#define maxperiod_siz 80 // max number of samples in a period
#define measures 10 // number of periods stored
#define samp_siz 4 // number of samples for average
#define rise_threshold 3 // number of rising measures to determine a peak
int
T
=
20
;
// slot milliseconds to read a value from the sensor
int
sensorPin
=
A3
;
int
REDLed
=
3
;
int
IRLed
=
4
;
unsigned
int
samplingTime
=
280
;
unsigned
int
deltaTime
=
40
;
unsigned
int
sleepTime
=
9680
;
float
voMeasured
=
0
;
float
calcVoltage
=
0
;
float
dustDensity
=
0
;
byte
sym
[
3
][
8
]
=
{{
B00000
,
B01010
,
B11111
,
B11111
,
B01110
,
B00100
,
B00000
,
B00000
},
{
B00000
,
B00000
,
B00000
,
B11000
,
B00100
,
B01000
,
B10000
,
B11100
},
{
B00000
,
B00100
,
B01010
,
B00010
,
B00100
,
B00100
,
B00000
,
B00100
}
};
int
ptr
;
float
beforeIR
;
bool
rising
;
int
rise_count
;
int
n
;
long
int
last_beat
;
bool
finger_status
=
true
;
float
readsIR
[
samp_siz
],
sumIR
,
lastIR
,
reader
,
start
;
float
readsRED
[
samp_siz
],
sumRED
,
lastRED
;
int
period
,
samples
;
float
IRmax
=
0
;
float
IRmin
=
0
;
float
REDmax
=
0
;
float
REDmin
=
0
;
double
R
=
0
;
float
measuresR
[
measures
];
int
measuresPeriods
[
measures
];
int
m
=
0
;
int
samplesCounter
=
0
;
float
readsIRMM
[
maxperiod_siz
],
readsREDMM
[
maxperiod_siz
];
int
ptrMM
=
0
;
void
setup
()
{
pinMode
(
buttonPin
,
INPUT
);
pinMode
(
12
,
OUTPUT
);
digitalWrite
(
12
,
HIGH
);
Serial
.
begin
(
9600
);
HC12
.
begin
(
9600
);
Serial
.
flush
();
pinMode
(
sensorPin
,
INPUT
);
pinMode
(
REDLed
,
OUTPUT
);
pinMode
(
IRLed
,
OUTPUT
);
digitalWrite
(
REDLed
,
LOW
);
digitalWrite
(
IRLed
,
LOW
);
pinMode
(
ledPower
,
OUTPUT
);
preheart
();
}
void
loop
()
{
String
heart_read
=
heart
();
int
gasSensorReading1
=
analogread
(
gasSensor1
);
int
gasSensorReading2
=
analogread
(
gasSensor2
);
int
gasSensorReading3
=
analogread
(
gasSensor3
);
int
gasSensorReading4
=
analogread
(
gasSensor4
);
int
gasSensorReading5
=
analogread
(
gasSensor5
);
String
dust_sensor_value
=
dust_sensor
();
int
piezo_sensor_read
=
piezo_sensor
();
int
vibrator_val
=
vibrator
();
// Serial.print("sensor analog 1 :");
// Serial.println(gasSensorReading1);
// Serial.print("sensor analog 2 :");
// Serial.println(gasSensorReading2);
// Serial.print("sensor analog 3 :");
// Serial.println(gasSensorReading3);
// Serial.print("sensor analog 4 :");
// Serial.println(gasSensorReading4);
// Serial.print("sensor analog 5 :");
// Serial.println(gasSensorReading5);
// Serial.println(dust_sensor_value);
String
str1
=
String
(
gasSensorReading1
)
+
\
","
+
String
(
gasSensorReading2
)
+
\
","
+
String
(
gasSensorReading3
)
+
\
","
+
String
(
gasSensorReading4
)
+
\
","
+
String
(
gasSensorReading5
)
+
\
","
+
dust_sensor_value
+
\
","
+
heart_read
+
\
","
+
String
(
vibrator
);
Serial
.
println
(
str1
);
delay
(
100
);
datasendrec
(
str1
);
}
IT18021080/IoT Project/Intergrated with other/dash/main.py
0 → 100644
View file @
4dd20bd1
import
serial
import
streamlit
as
st
import
numpy
as
np
import
pandas
as
pd
import
time
def
connect_to_port
():
ser
=
serial
.
Serial
(
port
=
'COM4'
,
\
baudrate
=
9600
,
\
parity
=
serial
.
PARITY_NONE
,
\
stopbits
=
serial
.
STOPBITS_ONE
,
\
bytesize
=
serial
.
EIGHTBITS
,
\
timeout
=
0
)
print
(
"connected to: "
+
ser
.
portstr
)
return
ser
def
get_Data
(
ser
):
line
=
[]
all_vals
=
[]
sensor1
=
[]
sensor2
=
[]
sensor3
=
[]
sensor4
=
[]
sensor5
=
[]
while
True
:
try
:
value
=
ser
.
read
()
.
decode
(
"utf-8"
)
string
=
""
if
value
!=
""
:
if
value
==
'
\n
'
or
value
==
'
\r
'
:
for
i
in
line
:
string
+=
i
all_vals
=
string
.
split
(
','
)
if
len
(
all_vals
)
==
11
:
print
(
all_vals
)
sensor1
.
append
(
int
(
all_vals
[
0
]))
sensor2
.
append
(
int
(
all_vals
[
1
]))
sensor3
.
append
(
int
(
all_vals
[
2
]))
sensor4
.
append
(
int
(
all_vals
[
3
]))
sensor5
.
append
(
int
(
all_vals
[
4
]))
line
=
[]
elif
value
!=
"
\n
"
:
line
.
append
(
value
)
if
len
(
sensor1
)
==
1
:
return
sensor1
,
sensor2
,
sensor3
,
sensor4
,
sensor5
except
:
string
=
""
if
__name__
==
"__main__"
:
asd
=
True
ser
=
None
st
.
title
(
'I Helmet data'
)
st
.
subheader
(
"sensor 1"
)
gp1_chart
=
st
.
empty
()
st
.
subheader
(
"sensor 2"
)
gp2_chart
=
st
.
empty
()
st
.
subheader
(
"sensor 3"
)
gp3_chart
=
st
.
empty
()
st
.
subheader
(
"sensor 4"
)
gp4_chart
=
st
.
empty
()
st
.
subheader
(
"sensor 5"
)
gp5_chart
=
st
.
empty
()
# st.subheader("sensor 1")
gp1_vals
=
np
.
zeros
(
100
)
gp2_vals
=
np
.
zeros
(
100
)
gp3_vals
=
np
.
zeros
(
100
)
gp4_vals
=
np
.
zeros
(
100
)
gp5_vals
=
np
.
zeros
(
100
)
chart_data_1
=
pd
.
DataFrame
(
gp1_vals
)
chart_data_2
=
pd
.
DataFrame
(
gp2_vals
)
chart_data_3
=
pd
.
DataFrame
(
gp3_vals
)
chart_data_4
=
pd
.
DataFrame
(
gp4_vals
)
chart_data_5
=
pd
.
DataFrame
(
gp5_vals
)
if
asd
:
ser
=
connect_to_port
()
asd
=
False
# st.line_chart(chart_data)
while
range
(
500
):
values
=
get_Data
(
ser
)
gp1_vals
[
-
1
]
=
values
[
0
][
0
]
gp2_vals
[
-
1
]
=
values
[
1
][
0
]
gp3_vals
[
-
1
]
=
values
[
2
][
0
]
gp4_vals
[
-
1
]
=
values
[
3
][
0
]
gp5_vals
[
-
1
]
=
values
[
4
][
0
]
chart_data_1
=
pd
.
DataFrame
(
gp1_vals
)
chart_data_2
=
pd
.
DataFrame
(
gp2_vals
)
chart_data_3
=
pd
.
DataFrame
(
gp3_vals
)
chart_data_4
=
pd
.
DataFrame
(
gp4_vals
)
chart_data_5
=
pd
.
DataFrame
(
gp5_vals
)
gp1_chart
.
line_chart
(
chart_data_1
)
gp2_chart
.
line_chart
(
chart_data_2
)
gp3_chart
.
line_chart
(
chart_data_3
)
gp4_chart
.
line_chart
(
chart_data_4
)
gp5_chart
.
line_chart
(
chart_data_5
)
gp1_vals
=
np
.
roll
(
gp1_vals
,
-
1
)
gp2_vals
=
np
.
roll
(
gp2_vals
,
-
1
)
gp3_vals
=
np
.
roll
(
gp3_vals
,
-
1
)
gp4_vals
=
np
.
roll
(
gp4_vals
,
-
1
)
gp5_vals
=
np
.
roll
(
gp5_vals
,
-
1
)
# st.line_chart(chart_data)
# print(values[0])
ser
.
close
()
\ No newline at end of file
IT18021080/IoT Project/Intergrated with other/dash/test.py
0 → 100644
View file @
4dd20bd1
import
streamlit
as
st
import
pandas
as
pd
import
numpy
as
np
st
.
title
(
'Uber pickups in NYC'
)
dataframe
=
pd
.
DataFrame
(
np
.
random
.
randn
(
10
,
20
),
columns
=
(
'col
%
d'
%
i
for
i
in
range
(
20
)))
st
.
table
(
dataframe
)
st
.
write
(
"Here's our first attempt at using data to create a table:"
)
st
.
write
(
pd
.
DataFrame
({
'first column'
:
[
1
,
2
,
3
,
4
],
'second column'
:
[
10
,
20
,
30
,
40
]
}))
chart_data
=
pd
.
DataFrame
(
np
.
random
.
randn
(
20
,
3
),
columns
=
[
'a'
,
'b'
,
'c'
])
st
.
line_chart
(
chart_data
)
map_data
=
pd
.
DataFrame
(
np
.
random
.
randn
(
1000
,
2
)
/
[
50
,
50
]
+
[
37.76
,
-
122.4
],
columns
=
[
'lat'
,
'lon'
])
st
.
map
(
map_data
)
x
=
st
.
slider
(
'x'
)
# 👈 this is a widget
st
.
write
(
x
,
'squared is'
,
x
*
x
)
st
.
text_input
(
"Your name"
,
key
=
"name"
)
# You can access the value at any point with:
st
.
session_state
.
name
IT18021080/IoT Project/Intergrated with other/dash/test2.py
0 → 100644
View file @
4dd20bd1
import
serial
import
streamlit
as
st
import
numpy
as
np
import
pandas
as
pd
import
time
def
connect_to_port
():
ser
=
serial
.
Serial
(
port
=
'COM4'
,
\
baudrate
=
9600
,
\
parity
=
serial
.
PARITY_NONE
,
\
stopbits
=
serial
.
STOPBITS_ONE
,
\
bytesize
=
serial
.
EIGHTBITS
,
\
timeout
=
0
)
print
(
"connected to: "
+
ser
.
portstr
)
return
ser
def
get_Data
(
ser
):
line
=
[]
all_vals
=
[]
sensor1
=
[]
sensor2
=
[]
sensor3
=
[]
sensor4
=
[]
sensor5
=
[]
while
True
:
try
:
value
=
ser
.
read
()
.
decode
(
"utf-8"
)
string
=
""
if
value
!=
""
:
if
value
==
'
\n
'
or
value
==
'
\r
'
:
for
i
in
line
:
string
+=
i
all_vals
=
string
.
split
(
','
)
if
len
(
all_vals
)
==
11
:
print
(
all_vals
)
sensor1
.
append
(
int
(
all_vals
[
0
]))
sensor2
.
append
(
int
(
all_vals
[
1
]))
sensor3
.
append
(
int
(
all_vals
[
2
]))
sensor4
.
append
(
int
(
all_vals
[
3
]))
sensor5
.
append
(
int
(
all_vals
[
4
]))
line
=
[]
elif
value
!=
"
\n
"
:
line
.
append
(
value
)
if
len
(
sensor1
)
==
1
:
return
sensor1
,
sensor2
,
sensor3
,
sensor4
,
sensor5
except
:
string
=
""
if
__name__
==
"__main__"
:
asd
=
True
ser
=
None
if
asd
:
ser
=
connect_to_port
()
asd
=
False
while
True
:
values
=
get_Data
(
ser
)
print
(
values
)
ser
.
close
()
\ No newline at end of file
IT18021080/IoT Project/Intergrated with other/zserver/manage.py
0 → 100644
View file @
4dd20bd1
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import
os
import
sys
def
main
():
"""Run administrative tasks."""
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'zserver.settings'
)
try
:
from
django.core.management
import
execute_from_command_line
except
ImportError
as
exc
:
raise
ImportError
(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
from
exc
execute_from_command_line
(
sys
.
argv
)
if
__name__
==
'__main__'
:
main
()
IT18021080/IoT Project/Intergrated with other/zserver/zserver/__init__.py
0 → 100644
View file @
4dd20bd1
IT18021080/IoT Project/Intergrated with other/zserver/zserver/asgi.py
0 → 100644
View file @
4dd20bd1
"""
ASGI config for zserver project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
import
os
from
django.core.asgi
import
get_asgi_application
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'zserver.settings'
)
application
=
get_asgi_application
()
IT18021080/IoT Project/Intergrated with other/zserver/zserver/settings.py
0 → 100644
View file @
4dd20bd1
"""
Django settings for zserver project.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from
pathlib
import
Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'django-insecure-7e7df480m3duz8nqqgpl6f-pnxee$^grk^u5ek27phc68y$!8h'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
ALLOWED_HOSTS
=
[]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
]
MIDDLEWARE
=
[
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
]
ROOT_URLCONF
=
'zserver.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
'django.template.context_processors.request'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
],
},
},
]
WSGI_APPLICATION
=
'zserver.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
BASE_DIR
/
'db.sqlite3'
,
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS
=
[
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'UTC'
USE_I18N
=
True
USE_L10N
=
True
USE_TZ
=
True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL
=
'/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
IT18021080/IoT Project/Intergrated with other/zserver/zserver/urls.py
0 → 100644
View file @
4dd20bd1
"""zserver URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.contrib
import
admin
from
django.urls
import
path
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
]
IT18021080/IoT Project/Intergrated with other/zserver/zserver/wsgi.py
0 → 100644
View file @
4dd20bd1
"""
WSGI config for zserver project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import
os
from
django.core.wsgi
import
get_wsgi_application
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'zserver.settings'
)
application
=
get_wsgi_application
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment