Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoT_Project
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
robert.sharp
IoT_Project
Commits
1cbf2e39
Commit
1cbf2e39
authored
Jan 06, 2022
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update AirSensor_Test to use better library
parent
41533333
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
26 deletions
+52
-26
AirSensor_Test.ino
sketch_main/AirSensor_Test/AirSensor_Test.ino
+52
-26
No files found.
sketch_main/AirSensor_Test/AirSensor_Test.ino
View file @
1cbf2e39
#include"AirQuality.h"
/*
#include"Arduino.h"
Grove_Air_Quality_Sensor.ino
Demo for Grove - Air Quality Sensor.
Copyright (c) 2019 seeed technology inc.
Author : Lets Blu
Created Time : Jan 2019
Modified Time:
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "Air_Quality_Sensor.h"
AirQualitySensor
sensor
(
A0
);
static
int
mydata
=
-
1
;
void
setup
(
void
)
{
static
int
data2
=
-
1
;
AirQuality
airqualitysensor
;
void
setup
()
{
// put your setup code here, to run once:
Serial
.
begin
(
9600
);
Serial
.
begin
(
9600
);
airqualitysensor
.
init
(
A0
);
while
(
!
Serial
);
Serial
.
println
(
"Waiting sensor to init..."
);
delay
(
20000
);
if
(
sensor
.
init
())
{
Serial
.
println
(
"Sensor ready."
);
}
else
{
Serial
.
println
(
"Sensor ERROR!"
);
}
}
}
void
loop
()
{
void
loop
(
void
)
{
// put your main code here, to run repeatedly:
int
quality
=
sensor
.
slope
();
mydata
=
airqualitysensor
.
slope
();
//int16_t t = mydata;
delay
(
1000
);
Serial
.
print
(
"Sensor value: "
);
}
Serial
.
println
(
sensor
.
getValue
());
ISR
(
TIMER2_OVF_vect
){
if
(
quality
==
AirQualitySensor
::
FORCE_SIGNAL
)
{
if
(
airqualitysensor
.
counter
==
122
){
//set 2 seconds as a detected duty{
Serial
.
println
(
"High pollution! Force signal active."
);
airqualitysensor
.
last_vol
=
airqualitysensor
.
first_vol
;
}
else
if
(
quality
==
AirQualitySensor
::
HIGH_POLLUTION
)
{
airqualitysensor
.
first_vol
=
analogRead
(
A0
);
Serial
.
println
(
"High pollution!"
);
airqualitysensor
.
counter
=
0
;
}
else
if
(
quality
==
AirQualitySensor
::
LOW_POLLUTION
)
{
airqualitysensor
.
timer_index
=
1
;
Serial
.
println
(
"Low pollution!"
);
PORTB
=
PORTB
^
0x20
;
}
else
if
(
quality
==
AirQualitySensor
::
FRESH_AIR
)
{
}
else
{
Serial
.
println
(
"Fresh air."
);
airqualitysensor
.
counter
++
;
}
}
delay
(
1000
);
}
}
\ 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