Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karser/karserdsm501
Arduino library for DSM501 dust sensor
https://github.com/karser/karserdsm501
air-pollution air-quality arduino arduino-library arduino-nano dsm501a dust-sensor
Last synced: 9 days ago
JSON representation
Arduino library for DSM501 dust sensor
- Host: GitHub
- URL: https://github.com/karser/karserdsm501
- Owner: karser
- Created: 2021-02-20T17:04:53.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-02-20T17:29:08.000Z (over 3 years ago)
- Last Synced: 2024-10-11T13:12:46.526Z (about 1 month ago)
- Topics: air-pollution, air-quality, arduino, arduino-library, arduino-nano, dsm501a, dust-sensor
- Language: C++
- Homepage:
- Size: 1000 Bytes
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Arduino library for DSM501 dust sensor
### Example
```
#define DUST_SENSOR_PIN_PM10 3 //Must be the pins that
#define DUST_SENSOR_PIN_PM25 2 //support interrupts#define INTERVAL_COUNTDOWN 1000
#define INTERVAL_READ 30000#include
// ISRs forward declaration
void pm10_handleInterrupt();
void pm25_handleInterrupt();
// init pm10 and pm25 instances
KarserDSM501 pm10(DUST_SENSOR_PIN_PM10, pm10_handleInterrupt);
KarserDSM501 pm25(DUST_SENSOR_PIN_PM25, pm25_handleInterrupt);
// handle ISRs
void pm10_handleInterrupt() { pm10.handleInterrupt(); }
void pm25_handleInterrupt() { pm25.handleInterrupt(); }unsigned long timer = 0;
void setup() {
Serial.begin(9600);
}void loop() {
if (!pm10.isReady() && (millis() >= timer + INTERVAL_COUNTDOWN)) {
Serial.println("DSM501 warm up: " + String(pm10.getReadyCountdown()));
timer += INTERVAL_COUNTDOWN;
} else if (millis() >= timer + INTERVAL_READ) {
timer += INTERVAL_READ;
Serial.println("pm10: "+String(pm10.readPM())+" pm2.5: "+String(pm25.readPM()));
}
}
```Here is the console output
```
18:53:40.791 -> DSM501 warm up: 59
...
18:54:36.845 -> DSM501 warm up: 3
18:54:37.841 -> DSM501 warm up: 2
18:54:38.837 -> DSM501 warm up: 1
18:54:39.832 -> DSM501 warm up: 0
18:55:09.855 -> pm10: 21.39 pm2.5: 6.65
18:55:39.872 -> pm10: 20.31 pm2.5: 5.57
18:56:09.897 -> pm10: 28.64 pm2.5: 7.07
18:56:39.920 -> pm10: 17.89 pm2.5: 6.92
18:57:09.940 -> pm10: 25.84 pm2.5: 7.86
18:57:39.937 -> pm10: 23.35 pm2.5: 6.83
18:58:09.959 -> pm10: 29.80 pm2.5: 6.84
18:58:39.980 -> pm10: 18.68 pm2.5: 6.98
18:59:10.003 -> pm10: 27.84 pm2.5: 7.54
```