Last active
January 21, 2024 17:50
-
-
Save anoochit/347b239697d76352d05fe68192ceccb6 to your computer and use it in GitHub Desktop.
pms7003 with ESP32 hardware serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "PMS.h" | |
HardwareSerial SerialPMS(1); | |
PMS pms(SerialPMS); | |
PMS::DATA data; | |
#define RXD2 23 | |
#define TXD2 22 | |
// ESP32 --> Pantower PMS7003 | |
// 22 --> RX | |
// 23 --> TX | |
// GND --> GND | |
void setup() | |
{ | |
Serial.begin(9600); | |
SerialPMS.begin(9600, SERIAL_8N1, RXD2, TXD2); | |
} | |
void loop() | |
{ | |
if (pms.read(data)) | |
{ | |
Serial.print("PM 1.0 (ug/m3): "); | |
Serial.println(data.PM_AE_UG_1_0); | |
Serial.print("PM 2.5 (ug/m3): "); | |
Serial.println(data.PM_AE_UG_2_5); | |
Serial.print("PM 10.0 (ug/m3): "); | |
Serial.println(data.PM_AE_UG_10_0); | |
Serial.println(); | |
} | |
// Do other stuff... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this code dosent seam to work. it cant read the PSM7003 i only get
PM 1.0 (ug/m3): 0
PM 2.5 (ug/m3): 0
PM 10.0 (ug/m3): 0