Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neOCampus-arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
GIS-neOCampus
neOSensor
neOCampus-arduino
Commits
0a74dc12
Commit
0a74dc12
authored
3 years ago
by
thiebolt
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
4ea309ab
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
tests/pms5003/pms5003.ino
+21
-10
21 additions, 10 deletions
tests/pms5003/pms5003.ino
with
21 additions
and
10 deletions
tests/pms5003/pms5003.ino
+
21
−
10
View file @
0a74dc12
...
@@ -218,8 +218,9 @@ void PMS::loop()
...
@@ -218,8 +218,9 @@ void PMS::loop()
/* Declarations */
/* Declarations */
//#define DEBUG_SERIAL
#define PM_PASSIVE_MODE 1 // PASSIVE vs ACTIVE modes
#define PM_PASSIVE_MODE 1 // PASSIVE vs ACTIVE modes
//
#define PM_POWER_SAVING 1 // enable sleep() wakeUp() cycles to save power
#define PM_POWER_SAVING 1 // enable sleep() wakeUp() cycles to save power
#define PM_COOLDOWN 30 // seconds inactive betwwen two measures
#define PM_COOLDOWN 30 // seconds inactive betwwen two measures
#define PM_ENABLE 5 // PMS5003 has an Enable pin featuring a pullup resistor:
#define PM_ENABLE 5 // PMS5003 has an Enable pin featuring a pullup resistor:
...
@@ -249,38 +250,48 @@ void setup() {
...
@@ -249,38 +250,48 @@ void setup() {
Serial
.
print
(
F
(
"
\n
[PMS5003] setup Serial2"
));
Serial
.
flush
();
Serial
.
print
(
F
(
"
\n
[PMS5003] setup Serial2"
));
Serial
.
flush
();
Serial2
.
begin
(
9600
);
// PMS link
Serial2
.
begin
(
9600
);
// PMS link
delay
(
50
);
#ifdef
PM_PASSIVE_MODE
#if
def
ined(
PM_PASSIVE_MODE
)
Serial
.
print
(
F
(
"
\n
[PMS5003] switch to passive mode & empty receive buffer"
));
Serial
.
flush
();
Serial
.
print
(
F
(
"
\n
[PMS5003] switch to passive mode & empty receive buffer"
));
Serial
.
flush
();
pms
.
passiveMode
();
delay
(
1
0
);
pms
.
passiveMode
();
delay
(
5
0
);
while
(
Serial2
.
available
()
)
Serial2
.
read
();
// flush input buffer
while
(
Serial2
.
available
()
)
Serial2
.
read
();
// flush input buffer
#else
#else
Serial
.
print
(
F
(
"
\n
[PMS5003] switch to active mode"
));
Serial
.
flush
();
Serial
.
print
(
F
(
"
\n
[PMS5003] switch to active mode"
));
Serial
.
flush
();
pms
.
activeMode
();
pms
.
activeMode
();
#endif
/* PM_PASSIVE_MODE */
#endif
/* PM_PASSIVE_MODE */
#if
ndef
PM_POWER_SAVING
#if
not defined(
PM_POWER_SAVING
)
Serial
.
print
(
F
(
"
\n
[PMS5003] power saving mode disabled !! ... 30s warmup procedure ..."
));
Serial
.
flush
();
Serial
.
print
(
F
(
"
\n
[PMS5003] power saving mode disabled !! ... 30s warmup procedure ..."
));
Serial
.
flush
();
pms
.
wakeUp
();
delay
(
30
*
1000
);
pms
.
wakeUp
();
delay
(
30
*
1000
);
#endif
/* PM_POWER_SAVING */
#endif
/* PM_POWER_SAVING */
// enable pin is input as default
// enable pin is input as default
pinMode
(
PM_ENABLE
,
INPUT
);
pinMode
(
PM_ENABLE
,
INPUT
);
digitalWrite
(
PM_ENABLE
,
LOW
);
// useless ... till we set it as an ouput
digitalWrite
(
PM_ENABLE
,
LOW
);
// useless ... till we set it as an ouput
/*
/* PM_ENABLE gpio
Serial.println(F("\n[PMS5003] disabling "));Serial.flush();
Serial.println(F("\n[PMS5003] disabling "));Serial.flush();
pinMode( PM_ENABLE, OUTPUT );
pinMode( PM_ENABLE, OUTPUT );
while( true ) {
while( true ) {
Serial.print(F("."));Serial.flush();
Serial.print(F("."));Serial.flush();
delay(1000);
delay(1000);
}
}
*/
/* DEBUG
* raw print of serial messages
*/
#ifdef DEBUG_SERIAL
delay
(
50
);
pms
.
passiveMode
();
delay
(
50
);
pms
.
wakeUp
();
delay
(
50
);
pms
.
activeMode
();
delay
(
50
);
Serial
.
println
(
F
(
"
\n
[PMS5003] PMS is active ..."
));
Serial
.
flush
();
Serial
.
println
(
F
(
"
\n
[PMS5003] PMS is active ..."
));
Serial
.
flush
();
_lastActive = millis();
delay
(
5000
);
delay(500);
while
(
true
)
{
while
(
true
)
{
while
(
Serial2
.
available
()
)
{
while
(
Serial2
.
available
()
)
{
char msg[
1
6];
char
msg
[
6
4
];
char
_cur
=
Serial2
.
read
();
char
_cur
=
Serial2
.
read
();
if
(
_cur
==
0x42
)
{
if
(
_cur
==
0x42
)
{
Serial
.
print
(
F
(
"
\n
[new frame] = "
));
Serial
.
print
(
F
(
"
\n
[new frame] = "
));
...
@@ -290,7 +301,7 @@ void setup() {
...
@@ -290,7 +301,7 @@ void setup() {
}
}
delay
(
250
);
delay
(
250
);
}
}
*/
#endif
/* DEBUG_SERIAL
*/
}
}
/*
/*
...
...
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