added CO2 and VOC sensor
This commit is contained in:
@@ -10,6 +10,9 @@ char g_command_topic[50]; // MQTT topic for receiving commands
|
||||
#define PMS_STATE_ASLEEP 0 // Low power mode, laser and fan off
|
||||
#define PMS_STATE_WAKING_UP 1 // Laser and fan on, not ready yet
|
||||
#define PMS_STATE_READY 2 // Warmed up, ready to give data
|
||||
#define PMSMAX 50
|
||||
#define PSMMIN 0
|
||||
#define PPDMAX 2000
|
||||
uint8_t g_pms_state = PMS_STATE_WAKING_UP;
|
||||
|
||||
uint32_t g_pms_state_start = 0; // Timestamp when PMS state last changed
|
||||
@@ -18,20 +21,19 @@ uint8_t g_pms_ppd_readings_taken = 0; // 0/1: whether PPD readings have been tak
|
||||
|
||||
uint8_t samples = 3600 / g_pms_report_period;
|
||||
|
||||
AQSSensor g_pm1p0_sp("SP_1P0", device_name, samples);
|
||||
AQSSensor g_pm2p5_sp("SP_2P5", device_name, samples);
|
||||
AQSSensor g_pm10p0_sp("SP_10P0", device_name, samples);
|
||||
|
||||
AQSSensor g_pm1p0_ae("AE_1P0", device_name, samples);
|
||||
AQSSensor g_pm2p5_ae("AE_2P5", device_name, samples);
|
||||
AQSSensor g_pm10p0_ae("AE_10P0", device_name, samples);
|
||||
|
||||
AQSSensor g_pm0p3_ppd("PPD_0P3", device_name, samples);
|
||||
AQSSensor g_pm0p5_ppd("PPD_0P5", device_name, samples);
|
||||
AQSSensor g_pm1p0_ppd("PPD_1P0", device_name, samples);
|
||||
AQSSensor g_pm2p5_ppd("PPD_2P5", device_name, samples);
|
||||
AQSSensor g_pm5p0_ppd("PPD_5P0", device_name, samples);
|
||||
AQSSensor g_pm10p0_ppd("PPD_10P0", device_name, samples);
|
||||
// name enum unit device name samples/h, min, max
|
||||
AQSSensor g_pm1p0_sp("SP_1P0", SP_1P0, "", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm2p5_sp("SP_2P5", SP_2P5, "", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm10p0_sp("SP_10P0", SP_10P0, "", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm1p0_ae("AE_1P0", AE_1P0, "ug/m3", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm2p5_ae("AE_2P5", AE_2P5, "ug/m3", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm10p0_ae("AE_10P0", AE_10P0, "ug/m3", device_name, samples, PSMMIN, PMSMAX);
|
||||
AQSSensor g_pm0p3_ppd("PPD_0P3", PPD_0P3, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
AQSSensor g_pm0p5_ppd("PPD_0P5", PPD_0P5, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
AQSSensor g_pm1p0_ppd("PPD_1P0", PPD_1P0, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
AQSSensor g_pm2p5_ppd("PPD_2P5", PPD_2P5, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
AQSSensor g_pm5p0_ppd("PPD_5P0", PPD_5P0, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
AQSSensor g_pm10p0_ppd("PPD_10P0",PPD_10P0, "", device_name, samples, PSMMIN, PPDMAX);
|
||||
|
||||
void PMS_publishSensors(void );
|
||||
|
||||
@@ -62,7 +64,6 @@ uint32_t getLCDvalue(void)
|
||||
|
||||
void PMS_publishSensors(void )
|
||||
{
|
||||
String message_string;
|
||||
|
||||
/* Report PM1.0 AE value */
|
||||
g_pm1p0_ae.publish();
|
||||
@@ -87,7 +88,7 @@ void PMS_publishSensors(void )
|
||||
|
||||
void initParticles( void )
|
||||
{
|
||||
Serial.print("initPMS:");
|
||||
Serial.println("PMS: Init");
|
||||
// Open a connection to the PMS and put it into passive mode
|
||||
Serial2.begin(PMS_BAUD_RATE, SERIAL_8N1, PMS_RX_PIN, PMS_TX_PIN); // Connection for PMS5003
|
||||
pms.activeMode(); // Tell PMS to stop sending data automatically
|
||||
@@ -98,7 +99,7 @@ void initParticles( void )
|
||||
|
||||
PMS_AddSensors();
|
||||
|
||||
Serial.println(" OK");
|
||||
Serial.println("PMS: Init OK");
|
||||
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ void handleParticles( void )
|
||||
if (time_now - g_pms_state_start >= ((g_pms_report_period * 1000) - (g_pms_warmup_period * 1000)))
|
||||
{
|
||||
// It's time to wake up the sensor
|
||||
Serial.println("Waking up sensor");
|
||||
Serial.println("PMS: Waking up sensor");
|
||||
pms.wakeUp();
|
||||
g_pms_state_start = time_now;
|
||||
g_pms_state = PMS_STATE_WAKING_UP;
|
||||
@@ -170,4 +171,5 @@ void handleParticles( void )
|
||||
g_pms_state = PMS_STATE_ASLEEP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user