Skip to content

Instantly share code, notes, and snippets.

@anoochit
Last active January 21, 2024 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoochit/347b239697d76352d05fe68192ceccb6 to your computer and use it in GitHub Desktop.
Save anoochit/347b239697d76352d05fe68192ceccb6 to your computer and use it in GitHub Desktop.
pms7003 with ESP32 hardware serial
#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...
}
@Hakonovrebo
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment