Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino IOT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bryan.quispe
arduino IOT
Commits
6a27ac1c
Commit
6a27ac1c
authored
Jan 24, 2024
by
bryan.quispe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
sketch_jan22b.ino
sketch_jan22b.ino
+34
-0
No files found.
sketch_jan22b.ino
0 → 100644
View file @
6a27ac1c
int
pin
=
8
;
unsigned
long
duration
;
unsigned
long
starttime
;
unsigned
long
sampletime_ms
=
30000
;
//sampe 30s ;
unsigned
long
lowpulseoccupancy
=
0
;
float
ratio
=
0
;
float
concentration
=
0
;
void
setup
()
{
Serial
.
begin
(
9600
);
pinMode
(
pin
,
INPUT
);
starttime
=
millis
();
//get the current time;
}
void
loop
()
{
duration
=
pulseIn
(
pin
,
LOW
);
lowpulseoccupancy
=
lowpulseoccupancy
+
duration
;
if
((
millis
()
-
starttime
)
>
sampletime_ms
)
//if the sampel time == 30s
{
ratio
=
lowpulseoccupancy
/
(
sampletime_ms
*
10.0
);
// Integer percentage 0=>100
concentration
=
1.1
*
pow
(
ratio
,
3
)
-
3.8
*
pow
(
ratio
,
2
)
+
520
*
ratio
+
0.62
;
// using spec sheet curve
Serial
.
print
(
lowpulseoccupancy
);
Serial
.
print
(
","
);
Serial
.
print
(
ratio
);
Serial
.
print
(
","
);
Serial
.
println
(
concentration
);
lowpulseoccupancy
=
0
;
starttime
=
millis
();
}
}
\ No newline at end of file
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