Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CODEV-CO2-2022
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LANGLAIS Charlotte
CODEV-CO2-2022
Commits
de6d1f98
Commit
de6d1f98
authored
2 years ago
by
GAUDE Raphael
Browse files
Options
Downloads
Patches
Plain Diff
Code pour le capteur SCD30
parent
263262a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SCD30-6-JUIN-2.ino
+163
-0
163 additions, 0 deletions
SCD30-6-JUIN-2.ino
with
163 additions
and
0 deletions
SCD30-6-JUIN-2.ino
0 → 100644
+
163
−
0
View file @
de6d1f98
// Code pour faire fonctionner capteur et les 3 leds ensemble avec les conditions
#include
<Adafruit_SCD30.h>
#include
<SPI.h>
#include
<SD.h>
#include
<Wire.h>
#include
<SPI.h>
Adafruit_SCD30
scd30
;
File
myFile
;
const
int
L1
=
7
;
//rouge
const
int
L2
=
3
;
//jaune
const
int
L3
=
2
;
//vert
void
save_co2
()
{
myFile
=
SD
.
open
(
"CO2.txt"
,
FILE_WRITE
);
myFile
.
println
(
scd30
.
CO2
);
myFile
.
close
();
}
void
setup
(
void
)
{
pinMode
(
L1
,
OUTPUT
);
pinMode
(
L2
,
OUTPUT
);
pinMode
(
L3
,
OUTPUT
);
Serial
.
begin
(
115200
);
while
(
!
Serial
)
delay
(
10
);
// will pause Zero, Leonardo, etc until serial console opens
Serial
.
println
(
"Adafruit SCD30 test!"
);
// Try to initialize!
if
(
!
scd30
.
begin
())
{
Serial
.
println
(
"Failed to find SCD30 chip"
);
while
(
1
)
{
delay
(
10
);
}
}
Serial
.
println
(
"SCD30 Found!"
);
// if (!scd30.setMeasurementInterval(10)){
// Serial.println("Failed to set measurement interval");
// while(1){ delay(10);}
// }
Serial
.
print
(
"Measurement Interval: "
);
Serial
.
print
(
scd30
.
getMeasurementInterval
());
Serial
.
println
(
" seconds"
);
// Initialisation de la carte SD
Serial
.
print
(
"Initializing SD card..."
);
if
(
!
SD
.
begin
(
10
))
{
Serial
.
println
(
"initialization failed!"
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
delay
(
200
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
delay
(
200
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
delay
(
200
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
delay
(
200
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
delay
(
200
);
digitalWrite
(
L1
,
HIGH
);
delay
(
200
);
digitalWrite
(
L1
,
LOW
);
while
(
1
);
}
Serial
.
println
(
"initialization done."
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
delay
(
200
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
delay
(
200
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
delay
(
200
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
delay
(
200
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
delay
(
200
);
digitalWrite
(
L3
,
HIGH
);
delay
(
200
);
digitalWrite
(
L3
,
LOW
);
myFile
=
SD
.
open
(
"CO2.txt"
,
FILE_WRITE
);
myFile
.
println
(
" "
);
myFile
.
println
(
"----------- NOUVELLE MESURE -------------"
);
myFile
.
close
();
}
void
loop
()
{
if
(
scd30
.
dataReady
()){
Serial
.
println
(
"Data available!"
);
if
(
!
scd30
.
read
()){
Serial
.
println
(
"Error reading sensor data"
);
return
;
}
Serial
.
print
(
"Temperature: "
);
Serial
.
print
(
scd30
.
temperature
);
Serial
.
println
(
" degrees C"
);
Serial
.
print
(
"Relative Humidity: "
);
Serial
.
print
(
scd30
.
relative_humidity
);
Serial
.
println
(
" %"
);
Serial
.
print
(
"CO2: "
);
Serial
.
print
(
scd30
.
CO2
,
3
);
Serial
.
println
(
" ppm"
);
Serial
.
println
(
""
);
save_co2
();
}
else
{
//Serial.println("No data");
}
delay
(
100
);
//programmation des LEDS
if
(
scd30
.
CO2
>
1000
){
//rouge
digitalWrite
(
L1
,
HIGH
);
digitalWrite
(
L2
,
LOW
);
digitalWrite
(
L3
,
LOW
);
}
else
if
(
scd30
.
CO2
<
800
and
scd30
.
CO2
>
300
)
{
//vert
digitalWrite
(
L1
,
LOW
);
digitalWrite
(
L2
,
LOW
);
digitalWrite
(
L3
,
HIGH
);
}
else
if
(
scd30
.
CO2
<
300
)
{
//stabilisation en attendant la calibration du capteur
digitalWrite
(
L1
,
LOW
);
digitalWrite
(
L2
,
LOW
);
digitalWrite
(
L3
,
LOW
);
delay
(
2000
);
}
else
{
//jaune
digitalWrite
(
L1
,
LOW
);
digitalWrite
(
L2
,
HIGH
);
digitalWrite
(
L3
,
LOW
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment