The YYS JW01 (often labeled JW01-V2.2 or JW01-CO2) is a semiconductor air quality sensor module for detecting carbon dioxide ( ), commonly integrated into home appliances. It features UART output (5V level), 350-2000ppm detection range, high sensitivity, and automatic calibration with temperature/humidity compensation
รองรับการโอนเงินผ่านธนาคาร, บัตรเครดิต, Cryptocurrency และการชำระเงินออนไลน์
รองรับการจัดส่งทั่วโลกด้วยราคาที่ถูกที่สุด พัสดุทางอากาศ, EMS, ด่วนแบบ Door-to-Door
ให้ข้อมูลผลิตภัณฑ์แก่คุณโดยวิศวกรฝ่ายสนับสนุนลูกค้าของเรา
The YYS JW01 (often labeled JW01-V2.2 or JW01-CO2) is a semiconductor air quality sensor module for detecting carbon dioxide ( ), commonly integrated into home appliances. It features UART output (5V level), 350-2000ppm detection range, high sensitivity, and automatic calibration with temperature/humidity compensation

#include <SoftwareSerial.h>
#define JW_RX D5
#define JW_TX D6
#define NUM_SAMPLES 5 // number of readings to average
SoftwareSerial jwSerial(JW_RX, JW_TX);
byte frame[6];
int readings[NUM_SAMPLES];
int idx = 0; // renamed from 'index'
bool filled = false;
void setup() {
Serial.begin(115200);
jwSerial.begin(9600);
Serial.println("JW01 CO2 Sensor with Smoothing Ready");
// initialize readings array
for (int i = 0; i < NUM_SAMPLES; i++) readings[i] = 0;
}
void loop() {
while (jwSerial.available()) {
byte b = jwSerial.read();
if (b == 0x2C) { // start byte detected
frame[0] = b;
int i = 1;
while (i < 6) {
if (jwSerial.available()) {
frame[i] = jwSerial.read();
i++;
}
}
// Decode CO2: B4 * 100 (based on your frames)
int co2 = frame[3] * 100;
// Save reading for smoothing
readings[idx] = co2;
idx++;
if (idx >= NUM_SAMPLES) {
idx = 0;
filled = true;
}
// Compute moving average
int sum = 0;
int count = filled ? NUM_SAMPLES : idx;
for (int j = 0; j < count; j++) sum += readings[j];
int co2_avg = sum / count;
// Print raw and smoothed CO2
Serial.print("Raw CO2: ");
Serial.print(co2);
Serial.print(" ppm, Smoothed CO2: ");
Serial.print(co2_avg);
Serial.println(" ppm");
}
}
}