Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- RXD,4
- TXD,5
- A,1
- B,0
- Q,13
- 3.3,3.3
- D1,A5
- D2,A4
- GND,GND
- 5V,5V
- */
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <BLINKER_PMSX003ST.h>
- char recd_dat; // variable for receiving data from bluetooth serial port
- int on_brd_led = 8; // On-board LED pin detail
- int Al=1;
- LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
- #if defined(ESP32)
- LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
- HardwareSerial pmsSerial(2);// UART1/Serial1 pins 16,17
- #else
- #include <SoftwareSerial.h>
- SoftwareSerial pmsSerial(2,3);
- #endif
- BLINKER_PMSX003ST pms;
- void setup() {
- pinMode(8, OUTPUT);
- pinMode(13, INPUT);
- lcd.init(); //initialize the lcd
- lcd.backlight(); //open the backlight
- Serial.begin(115200);
- Serial.println("\nStart");
- pinMode(on_brd_led, OUTPUT);
- digitalWrite(on_brd_led, LOW);
- pmsSerial.begin(9600);
- pms.begin(pmsSerial);
- // pms.wakeUp();
- pms.setMode(PASSIVE);
- lcd.init(); //initialize the lcd
- lcd.backlight(); //open the backlight
- }
- void loop() {
- pms.request();
- if(Al == 1)
- {
- Serial.print("OK");
- }
- else
- {
- Serial.print("?");
- }
- if(13 == HIGH)
- {
- if(Al ==1 )
- {
- int Al = 2;
- delay (1000);
- }
- if(Al = 2)
- {
- int Al = 1;
- delay (1000);
- }
- }
- ç
- lcd.clear();
- Serial.print("PM1.0(CF1)\t");
- Serial.print(pms.getPmCf1(1.0));
- Serial.println("ug/m3");
- Serial.print("PM2.5(CF1)\t");
- Serial.print(pms.getPmCf1(2.5));
- Serial.println("ug/m3");
- Serial.print("PM10(CF1)\t");
- Serial.print(pms.getPmCf1(10));
- Serial.println("ug/m3");
- Serial.print("PM1.0(ATO)\t");
- Serial.print(pms.getPmAto(1.0));
- Serial.println("ug/m3");
- Serial.print("PM2.5(ATO)\t");
- Serial.print(pms.getPmAto(2.5));
- Serial.println("ug/m3");
- Serial.print("PM10(ATO)\t");
- Serial.print(pms.getPmAto(10));
- Serial.println("ug/m3");
- Serial.print(" PCS0.3\t");
- Serial.print(pms.getPcs(0.3));
- Serial.println("pcs/0.1L");
- Serial.print(" PCS0.5\t");
- Serial.print(pms.getPcs(0.5));
- Serial.println("pcs/0.1L");
- Serial.print(" PCS1.0\t");
- Serial.print(pms.getPcs(1));
- Serial.println("pcs/0.1L");
- Serial.print(" PCS2.5\t");
- Serial.print(pms.getPcs(2.5));
- Serial.println("pcs/0.1L");
- Serial.print(" PCS5.0\t");
- Serial.print(pms.getPcs(5));
- Serial.println("pcs/0.1L");
- Serial.print(" PCS10\t");
- Serial.print(pms.getPcs(10));
- Serial.println("pcs/0.1L");
- Serial.print("Formalde\t");
- Serial.print(pms.getForm());
- Serial.println("ug/m3");
- Serial.print("Temperat\t");
- Serial.print(pms.getTemp());
- Serial.println("'C");
- Serial.print("Humidity\t");
- Serial.print(pms.getHumi());
- Serial.println("%");
- Serial.println();
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("PM2.5 ");
- lcd.print(pms.getPmAto(2.5));
- lcd.print("ug/m3");
- lcd.setCursor(25,2); // set the cursor to column 15, line 1
- lcd.print(pms.getTemp());
- lcd.print("C ");
- lcd.print(pms.getHumi());
- lcd.print("%");
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement