Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Feinstaubmessung
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
Service Desk
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
Christian Georg Strippel
Feinstaubmessung
Commits
19fe3e52
Commit
19fe3e52
authored
2 years ago
by
Christian Georg Strippel
Browse files
Options
Downloads
Patches
Plain Diff
Add new file (program for using SDS011 sensor with Arduino Uno and I2C display
parent
262fdd4f
No related branches found
Branches containing commit
Tags
4.5.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProgrammArduino
+42
-0
42 additions, 0 deletions
ProgrammArduino
with
42 additions
and
0 deletions
ProgrammArduino
0 → 100644
+
42
−
0
View file @
19fe3e52
#include <SdsDustSensor.h>
#include <LiquidCrystal.h>
// LCD setup
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
int rxPin = 12;
int txPin = 13;
SdsDustSensor sds(rxPin, txPin);
void setup() {
Serial.begin(9600);
sds.begin();
Serial.println(sds.queryFirmwareVersion().toString()); // prints firmware version
Serial.println(sds.setActiveReportingMode().toString()); // ensures sensor is in 'active' reporting mode
Serial.println(sds.setContinuousWorkingPeriod().toString()); // ensures sensor has continuous working period - default but not recommended
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0, 0); // move cursor to (0, 0)
}
void loop() {
PmResult pm = sds.readPm();
if (pm.isOk()) {
lcd.setCursor(0, 0);
lcd.print("PM2.5 = ");
lcd.print(pm.pm25);
lcd.setCursor(1, 1);
lcd.print("PM10 = ");
lcd.print(pm.pm10);
} else {
// notice that loop delay is set to 0.5s and some reads are not available
lcd.print("Could not read values from sensor, reason: ");
lcd.print(pm.statusToString());
}
delay(1000);
lcd.clear();
}
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