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
47eed182
Commit
47eed182
authored
May 11, 2022
by
DESKTOP-95L9KLS\Sandun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All intergrated code
parent
abb1e118
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
480 additions
and
0 deletions
+480
-0
IT18203172/All_intergrated_with_wire/All_intergrated_with_wire.ino
...2/All_intergrated_with_wire/All_intergrated_with_wire.ino
+480
-0
No files found.
IT18203172/All_intergrated_with_wire/All_intergrated_with_wire.ino
0 → 100644
View file @
47eed182
char
c
;
int
x
,
spo2
,
avBMP
;
//MLX
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614
mlx
=
Adafruit_MLX90614
();
//lora
#include <SPI.h>
#include <LoRa.h>
//MLX
const
int
buzzer
=
13
;
const
int
threshold
=
38
;
int
gas
=
A2
;
int
value
=
0
;
int
sensorValue
;
int
t
;
//MQ7
int
sens
;
//int digitalValue;
//Flame
const
int
flamepin
=
A5
;
const
int
threshol
=
200
;
// sets threshold value for flame sensor
int
flamesensvalue
=
0
;
// initialize flamesensor reading
//Dust
int
measurePin
=
A7
;
int
ledPower
=
11
;
unsigned
int
samplingTime
=
280
;
unsigned
int
deltaTime
=
40
;
unsigned
int
sleepTime
=
9680
;
float
voMeasured
=
0
;
float
calcVoltage
=
0
;
float
dustDensity
=
0
;
//Alcohol Sensor = MQ-3
const
int
MQ3
=
A11
;
int
valuem
;
void
setup
()
{
//wire
Wire
.
begin
(
0x09
);
//MLX
Serial
.
begin
(
9600
);
Serial
.
println
(
"I-Helmet"
);
pinMode
(
13
,
OUTPUT
);
pinMode
(
12
,
OUTPUT
);
digitalWrite
(
buzzer
,
HIGH
);
mlx
.
begin
();
//Dust
pinMode
(
ledPower
,
OUTPUT
);
//Flame
pinMode
(
13
,
OUTPUT
);
pinMode
(
flamepin
,
INPUT
);
//MQ7
pinMode
(
A0
,
INPUT
);
pinMode
(
13
,
OUTPUT
);
pinMode
(
12
,
OUTPUT
);
Serial
.
begin
(
9600
);
//Pizero
Serial
.
begin
(
9600
);
pinMode
(
10
,
OUTPUT
);
//MQ2
pinMode
(
gas
,
INPUT
);
pinMode
(
13
,
OUTPUT
);
Serial
.
begin
(
9600
);
//MQ135
Serial
.
begin
(
9600
);
// sets the serial port to 9600
pinMode
(
13
,
OUTPUT
);
//MQ3
Serial
.
begin
(
9600
);
pinMode
(
MQ3
,
INPUT
);
//lora
while
(
!
Serial
);
Serial
.
println
(
"LoRa Sender"
);
if
(
!
LoRa
.
begin
(
433E6
))
{
// or 915E6, the MHz speed of your module
Serial
.
println
(
"Starting LoRa failed!"
);
while
(
1
);
}
}
void
loop
()
{
Wire
.
onReceive
(
receiveEvent
);
//run loop1 Heart Beat & SpO2 (have to add spo2 in loop 1)
delay
(
100
);
loop2
();
//run loop2 Human Body Temprature
loop3
();
//run loop3 Flame detected
loop4
();
//run loop4 MQ7
loop5
();
//run loop5 MQ2
loop6
();
//run loop6 MQ135
loop7
();
//run loop7 Pizero
loop8
();
//run loop8 Dust
loop9
();
//run loop9 MQ3
loop10
();
//run loop9 lora
}
//spo2 and pulse
void
receiveEvent
(
int
howMany
)
{
while
(
1
<
Wire
.
available
())
{
// loop through all but the last
c
=
Wire
.
read
();
// receive byte as a character
//Serial.print(c); // print the character
}
x
=
Wire
.
read
();
// receive byte as an integer
//Serial.println(x);
/////////////////////////////////
if
(
c
==
'S'
){
spo2
=
x
;
//Serial.println(spo2);
}
else
{
avBMP
=
x
;
//Serial.println(avBMP);
}
}
void
loop2
(){
//MLX
Serial
.
println
();
Serial
.
print
(
"Ambient = "
);
Serial
.
print
(
mlx
.
readAmbientTempC
());
//abtc=mlx.readAmbientTempC();
Serial
.
print
(
"*C
\t
Object = "
);
Serial
.
print
(
mlx
.
readObjectTempC
());
Serial
.
println
(
"*C"
);
//obtc=mlx.readObjectTempC();
Serial
.
print
(
"Ambient = "
);
Serial
.
print
(
mlx
.
readAmbientTempF
());
//abtf=mlx.readAmbientTempF();
Serial
.
print
(
"*F
\t
Object = "
);
Serial
.
print
(
mlx
.
readObjectTempF
());
Serial
.
println
(
"*F"
);
//obtf=mlx.readObjectTempF();
Serial
.
println
();
if
(
mlx
.
readObjectTempC
()
>
threshold
){
digitalWrite
(
buzzer
,
HIGH
);
digitalWrite
(
12
,
LOW
);
}
else
{
digitalWrite
(
buzzer
,
LOW
);
digitalWrite
(
12
,
HIGH
);
}
delay
(
100
);
}
void
loop3
(){
//Flame
flamesensvalue
=
analogRead
(
flamepin
);
// reads analog data from flame sensor
if
(
flamesensvalue
<=
threshol
)
{
// compares reading from flame sensor with the threshold value
digitalWrite
(
13
,
LOW
);
//turns on led and buzzer
Serial
.
print
(
"Flame range is Normal ,Flame was not detected "
);
Serial
.
println
(
flamesensvalue
);
// new adding value
delay
(
100
);
//stops program for 1 second
}
else
{
digitalWrite
(
13
,
HIGH
);
//turns led off led and buzzer
Serial
.
print
(
"Flame was detected detected "
);
Serial
.
println
(
flamesensvalue
);
// new adding value
digitalWrite
(
13
,
HIGH
);
//turns led off led and buzzer
//fsv=flamesensvalue;
}
}
void
loop4
(){
//MQ7
//carbon monoxide
sens
=
analogRead
(
A0
);
if
(
sens
>=
200
){
digitalWrite
(
13
,
HIGH
);
delay
(
500
);
digitalWrite
(
13
,
LOW
);
digitalWrite
(
12
,
HIGH
);
delay
(
100
);
digitalWrite
(
12
,
LOW
);
digitalWrite
(
13
,
HIGH
);
delay
(
500
);
digitalWrite
(
13
,
LOW
);
digitalWrite
(
12
,
HIGH
);
delay
(
10000
);
digitalWrite
(
12
,
LOW
);
}
else
{
digitalWrite
(
13
,
LOW
);
}
Serial
.
print
(
"MQ7 = "
);
Serial
.
println
(
sens
);
//MQ7= sens;
}
void
loop5
(){
//MQ2
//LPG & METHEN
value
=
analogRead
(
gas
);
Serial
.
print
(
"MQ2 = "
);
Serial
.
println
(
value
);
delay
(
100
);
if
(
value
>
200
){
//cahnge with your val
digitalWrite
(
13
,
HIGH
);
Serial
.
print
(
"LPG gas was detected"
);
Serial
.
println
(
value
);
//MQ2= value;
delay
(
100
);
}
else
{
digitalWrite
(
13
,
LOW
);
delay
(
100
);
}
}
void
loop6
(){
//MQ135
//CARBON DIOXIDE
sensorValue
=
analogRead
(
3
);
// read analog input pin 0
Serial
.
print
(
"MQ135 = "
);
Serial
.
println
(
sensorValue
,
DEC
);
//MQ135=sensorValue;
if
(
sensorValue
>
400
)
{
digitalWrite
(
13
,
HIGH
);
}
else
{
digitalWrite
(
13
,
LOW
);
//Serial.print("MQ135 = ");Serial.println(sensorValue, DEC); // prints the value read
}
delay
(
100
);
// wait 100ms for next reading
}
void
loop7
(){
//Pizero
t
=
analogRead
(
A1
);
//piz=t;
Serial
.
print
(
"Pizero"
);
Serial
.
println
(
t
);
delay
(
100
);
if
(
t
>
100
){
digitalWrite
(
10
,
HIGH
);
}
else
{
digitalWrite
(
10
,
LOW
);
}
}
void
loop8
(){
//Dust
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
;
//calv=calcVoltage;
//dstd=dustDensity;
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
(
100
);
}
void
loop9
()
{
//Alcohol sensor
valuem
=
analogRead
(
MQ3
);
Serial
.
println
(
value
);
//MQ3=valuem;
if
(
valuem
>
500
)
{
Serial
.
print
(
"Alcohol range is High ,Miner is Drunk "
);
Serial
.
print
(
valuem
);
}
else
{
Serial
.
print
(
"Not Drunk "
);
Serial
.
print
(
valuem
);
Serial
.
print
(
"
\n
"
);
}
delay
(
100
);
}
void
loop10
(){
//LoRa.beginPacket();
//Serial.println(MyMessage);
//LoRa.print(MyMessage);
LoRa
.
print
(
'='
);
Serial
.
println
(
"abtc"
);
LoRa
.
print
(
"abtc"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
mlx
.
readAmbientTempC
());
LoRa
.
print
(
mlx
.
readAmbientTempC
());
//Serial.println('\n');
LoRa
.
print
(
'@'
);
Serial
.
println
(
"obtc"
);
LoRa
.
print
(
"obtc"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
mlx
.
readObjectTempC
());
LoRa
.
print
(
mlx
.
readObjectTempC
());
//Serial.println('\n');
LoRa
.
print
(
'#'
);
Serial
.
println
(
"abtf"
);
LoRa
.
print
(
"abtf"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
mlx
.
readAmbientTempF
());
LoRa
.
print
(
mlx
.
readAmbientTempF
());
//Serial.println('\n');
LoRa
.
print
(
'$'
);
Serial
.
println
(
"obtf"
);
LoRa
.
print
(
"obtf"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
mlx
.
readObjectTempF
());
LoRa
.
print
(
mlx
.
readObjectTempF
());
//Serial.println('\n');
LoRa
.
print
(
'$'
);
Serial
.
println
(
"fsv"
);
LoRa
.
print
(
"afsv"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
flamesensvalue
);
LoRa
.
print
(
flamesensvalue
);
//Serial.println('\n');
LoRa
.
print
(
'^'
);
Serial
.
println
(
"MQ7"
);
LoRa
.
print
(
"MQ7"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
sens
);
LoRa
.
print
(
sens
);
//Serial.println('\n');
LoRa
.
print
(
'&'
);
Serial
.
println
(
"MQ2"
);
LoRa
.
print
(
"MQ2"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
value
);
LoRa
.
print
(
value
);
//Serial.println('\n');
LoRa
.
print
(
'*'
);
Serial
.
println
(
"MQ135"
);
LoRa
.
print
(
"MQ135"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
sensorValue
);
LoRa
.
print
(
sensorValue
);
//Serial.println('\n');
LoRa
.
print
(
'_'
);
Serial
.
println
(
"piz"
);
LoRa
.
print
(
"piz"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
t
);
LoRa
.
print
(
t
);
//Serial.println('\n');
LoRa
.
print
(
'<'
);
Serial
.
println
(
"calv"
);
LoRa
.
print
(
"calv"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
calcVoltage
);
LoRa
.
print
(
calcVoltage
);
//Serial.println('\n');
LoRa
.
print
(
'+'
);
Serial
.
println
(
"dstd"
);
LoRa
.
print
(
"dstd"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
dustDensity
);
LoRa
.
print
(
dustDensity
);
//Serial.println('\n');
LoRa
.
print
(
'|'
);
Serial
.
println
(
"MQ3"
);
LoRa
.
print
(
"MQ3"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
valuem
);
LoRa
.
print
(
valuem
);
//Serial.println('\n');
LoRa
.
print
(
':'
);
Serial
.
println
(
"spo2"
);
LoRa
.
print
(
"spo2"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
spo2
);
LoRa
.
print
(
spo2
);
//Serial.println('\n');
LoRa
.
print
(
'?'
);
Serial
.
println
(
"avBMP"
);
LoRa
.
print
(
"avBMP"
);
LoRa
.
print
(
'\n'
);
Serial
.
println
(
avBMP
);
LoRa
.
print
(
avBMP
);
LoRa
.
print
(
'{'
);
LoRa
.
endPacket
();
delay
(
100
);
avBMP
=
0
;
spo2
=
0
;
}
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