ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

ปัญหา Laser Dust Sensor pm2.5 PMS3003 ค่าขึ้นเป็นหมื่น

Suriya K.

พอรันตามนี้แล้วค่า pm1,2.5,10 มันขึ้นแปลกๆครับ บางครั้งขึ้นเป็นหลักหมื่นทั้งสามค่าแล้วค่าก็ไม่ลดเลย บางครั้งก็หลักร้อยครับ 

ผมอยากทราบว่าเป็นที่ code หรือตัวเซนเซอร์ครับ

code ที่ใช้ ร่วมกับจอ LCD

//library จอ LCD
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

//library เซ็นเซอร์ตรวจจับฝุ่นละออง PMS3003
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX
unsigned int pm1 = 0;
unsigned int pm2_5 = 0;
unsigned int pm10 = 0;

void setup() {
lcd.begin();
Serial.begin(9600);
while (!Serial) ;
mySerial.begin(9600);
}

void loop() {
int index = 0;
char value;
char previousValue;
while (mySerial.available()) {
value = mySerial.read();
if ((index == 0 && value != 0x42) || (index == 1 && value != 0x4d)){
Serial.println("Cannot find the data header.");
break;
}

if (index == 4 || index == 6 || index == 8 || index == 10 || index == 12 || index == 14) {
previousValue = value;
}
else if (index == 5) {
pm1 = 256 * previousValue + value;
Serial.print("pm1:");
Serial.print(pm1);
Serial.print(" ");
lcd.setCursor(0, 0);
lcd.print("pm1: ");
lcd.setCursor(0, 1);
lcd.print(pm1);
lcd.setCursor(4, 1);
lcd.print(" ");
}

else if (index == 7) {
pm2_5 = 256 * previousValue + value;
Serial.print("pm2.5:");
Serial.print(pm2_5);
Serial.print(" ug/m3");
Serial.print(" ");
lcd.setCursor(5, 0);
lcd.print("2.5: ");
lcd.setCursor(5, 1);
lcd.print(pm2_5);
lcd.setCursor(10, 1);
lcd.print(" ");
}

else if (index == 9) {
pm10 = 256 * previousValue + value;
Serial.print("pm10:");
Serial.print(pm10);
Serial.print(" ug/m3");
lcd.setCursor(11, 0);
lcd.print("10: ");
lcd.setCursor(11, 1);
lcd.print(pm10);
}

else if (index > 15) {
break;
}
index++;
}
while(mySerial.available()) mySerial.read();
Serial.println(" }");
delay(1000);
}

QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

ลองแยกทดสอบเฉพาะโมดูล PM2.5 โค้ดตัวอย่างตามนี้ครับ

https://wiki.dfrobot.com/PM2.5_laser_dust_sensor_SKU_SEN0177

แสดงความคิดเห็นที่ 1-1 จากทั้งหมด 1 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม