diff --git a/code/espurna/config/progmem.h b/code/espurna/config/progmem.h index 1181178351..88402a723d 100644 --- a/code/espurna/config/progmem.h +++ b/code/espurna/config/progmem.h @@ -231,7 +231,8 @@ PROGMEM const unsigned char magnitude_decimals[] = { 1, 0, 2, // THP 3, 0, 0, 0, 0, 0, 0, 0, // Power decimals 0, 0, 0, // analog, digital, event - 0, 0, 0, // PM + 0, 0, 0, // PM1.0, PM2.5, PM10 + 0, 0, 0, 0, 0, 0, // Particles count 0, 0, 3, 3, 0, 4, 4, // Geiger Counter decimals 0, @@ -256,6 +257,12 @@ PROGMEM const char magnitude_event_topic[] = "event"; PROGMEM const char magnitude_pm1dot0_topic[] = "pm1dot0"; PROGMEM const char magnitude_pm2dot5_topic[] = "pm2dot5"; PROGMEM const char magnitude_pm10_topic[] = "pm10"; +PROGMEM const char magnitude_particles_0dot3_topic[] = "particles0dot3"; +PROGMEM const char magnitude_particles_0dot5_topic[] = "particles0dot5"; +PROGMEM const char magnitude_particles_1_topic[] = "particles1"; +PROGMEM const char magnitude_particles_2dot5_topic[] = "particles2dot5"; +PROGMEM const char magnitude_particles_5_topic[] = "particles5"; +PROGMEM const char magnitude_particles_10_topic[] = "particles10"; PROGMEM const char magnitude_co2_topic[] = "co2"; PROGMEM const char magnitude_lux_topic[] = "lux"; PROGMEM const char magnitude_uv_topic[] = "uv"; @@ -275,6 +282,8 @@ PROGMEM const char* const magnitude_topics[] = { magnitude_power_factor_topic, magnitude_energy_topic, magnitude_energy_delta_topic, magnitude_analog_topic, magnitude_digital_topic, magnitude_event_topic, magnitude_pm1dot0_topic, magnitude_pm2dot5_topic, magnitude_pm10_topic, + magnitude_particles_0dot3_topic, magnitude_particles_0dot5_topic, magnitude_particles_1_topic, + magnitude_particles_2dot5_topic, magnitude_particles_5_topic, magnitude_particles_10_topic, magnitude_co2_topic, magnitude_lux_topic, magnitude_uv_topic, magnitude_distance_topic, magnitude_hcho_topic, magnitude_geiger_cpm_topic, magnitude_geiger_sv_topic, @@ -302,6 +311,7 @@ PROGMEM const char magnitude_mgm3[] = "mg/m³"; PROGMEM const char magnitude_geiger_cpm[] = "cpm"; // Counts per Minute: Unit of local dose rate (Geiger counting) PROGMEM const char magnitude_geiger_sv[] = "µSv/h"; // µSievert per hour: 2nd unit of local dose rate (Geiger counting) PROGMEM const char magnitude_resistance[] = "ohm"; +PROGMEM const char magnitude_particles_l[] = "particles/l"; PROGMEM const char* const magnitude_units[] = { @@ -310,7 +320,9 @@ PROGMEM const char* const magnitude_units[] = { magnitude_watts, magnitude_watts, magnitude_watts, magnitude_percentage, magnitude_joules, magnitude_joules, magnitude_empty, magnitude_empty, magnitude_empty, - magnitude_ugm3, magnitude_ugm3, magnitude_ugm3, + magnitude_ugm3, magnitude_ugm3, magnitude_ugm3, // PM1.0, PM2.5, PM10 + magnitude_particles_l, magnitude_particles_l, magnitude_particles_l, // Particles + magnitude_particles_l, magnitude_particles_l, magnitude_particles_l, // Particles magnitude_ppm, magnitude_lux, magnitude_uv, magnitude_distance, magnitude_mgm3, magnitude_geiger_cpm, magnitude_geiger_sv, // Geiger counter units diff --git a/code/espurna/config/types.h b/code/espurna/config/types.h index a984bb7e4d..4d1fc210fd 100644 --- a/code/espurna/config/types.h +++ b/code/espurna/config/types.h @@ -301,17 +301,23 @@ #define MAGNITUDE_EVENT 14 #define MAGNITUDE_PM1dot0 15 #define MAGNITUDE_PM2dot5 16 -#define MAGNITUDE_PM10 17 -#define MAGNITUDE_CO2 18 -#define MAGNITUDE_LUX 19 -#define MAGNITUDE_UV 20 -#define MAGNITUDE_DISTANCE 21 -#define MAGNITUDE_HCHO 22 -#define MAGNITUDE_GEIGER_CPM 23 -#define MAGNITUDE_GEIGER_SIEVERT 24 -#define MAGNITUDE_COUNT 25 -#define MAGNITUDE_NO2 26 -#define MAGNITUDE_CO 27 -#define MAGNITUDE_RESISTANCE 28 +#define MAGNITUDE_PARTICLES_0dot3 17 +#define MAGNITUDE_PARTICLES_0dot5 18 +#define MAGNITUDE_PARTICLES_1 19 +#define MAGNITUDE_PARTICLES_2dot5 20 +#define MAGNITUDE_PARTICLES_5 21 +#define MAGNITUDE_PARTICLES_10 22 +#define MAGNITUDE_PM10 23 +#define MAGNITUDE_CO2 24 +#define MAGNITUDE_LUX 25 +#define MAGNITUDE_UV 26 +#define MAGNITUDE_DISTANCE 27 +#define MAGNITUDE_HCHO 28 +#define MAGNITUDE_GEIGER_CPM 29 +#define MAGNITUDE_GEIGER_SIEVERT 30 +#define MAGNITUDE_COUNT 31 +#define MAGNITUDE_NO2 32 +#define MAGNITUDE_CO 33 +#define MAGNITUDE_RESISTANCE 34 #define MAGNITUDE_MAX 29 diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index 48fef408f1..0a7ba96f5a 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -1114,7 +1114,7 @@ String magnitudeTopicIndex(unsigned char index) { String magnitudeUnits(unsigned char type) { - char buffer[8] = {0}; + char buffer[14] = {0}; if (type < MAGNITUDE_MAX) { if ((type == MAGNITUDE_TEMPERATURE) && (_sensor_temperature_units == TMP_FAHRENHEIT)) { strncpy_P(buffer, magnitude_fahrenheit, sizeof(buffer)); diff --git a/code/espurna/sensors/PMSX003Sensor.h b/code/espurna/sensors/PMSX003Sensor.h index c117849da9..6ba1951d47 100644 --- a/code/espurna/sensors/PMSX003Sensor.h +++ b/code/espurna/sensors/PMSX003Sensor.h @@ -24,7 +24,7 @@ #define PMS_TYPE_5003ST 3 // Sensor type specified data -#define PMS_SLOT_MAX 4 +#define PMS_SLOT_MAX 9 #define PMS_DATA_MAX 17 const static struct { const char *name; @@ -32,8 +32,23 @@ const static struct { unsigned char slot_count; unsigned char slot_types[PMS_SLOT_MAX]; } pms_specs[] = { - {"PMSX003", 13, 3, {MAGNITUDE_PM1dot0, MAGNITUDE_PM2dot5, MAGNITUDE_PM10}}, - {"PMSX003_9", 9, 3, {MAGNITUDE_PM1dot0, MAGNITUDE_PM2dot5, MAGNITUDE_PM10}}, + {"PMSX003", 13, 9, { + MAGNITUDE_PM1dot0, + MAGNITUDE_PM2dot5, + MAGNITUDE_PM10, + MAGNITUDE_PARTICLES_0dot3, + MAGNITUDE_PARTICLES_0dot5, + MAGNITUDE_PARTICLES_1, + MAGNITUDE_PARTICLES_2dot5, + MAGNITUDE_PARTICLES_5, + MAGNITUDE_PARTICLES_10 + } + }, + {"PMSX003_9", 9, 3, { + MAGNITUDE_PM1dot0, + MAGNITUDE_PM2dot5, + MAGNITUDE_PM10 + }}, {"PMS5003T", 13, 3, {MAGNITUDE_PM2dot5, MAGNITUDE_TEMPERATURE, MAGNITUDE_HUMIDITY}}, {"PMS5003ST", 17, 4, {MAGNITUDE_PM2dot5, MAGNITUDE_TEMPERATURE, MAGNITUDE_HUMIDITY, MAGNITUDE_HCHO}} }; @@ -314,6 +329,12 @@ class PMSX003Sensor : public BaseSensor, PMSX003 { _slot_values[0] = data[3]; _slot_values[1] = data[4]; _slot_values[2] = data[5]; + _slot_values[3] = data[6] * 10; // convert particles per 0.1L of air to 1L + _slot_values[4] = data[7] * 10; // convert particles per 0.1L of air to 1L + _slot_values[5] = data[8] * 10; // convert particles per 0.1L of air to 1L + _slot_values[6] = data[9] * 10; // convert particles per 0.1L of air to 1L + _slot_values[7] = data[10] * 10; // convert particles per 0.1L of air to 1L + _slot_values[8] = data[11] * 10; // convert particles per 0.1L of air to 1L } } diff --git a/code/html/custom.js b/code/html/custom.js index f10f4d2c3b..50128d902b 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -61,7 +61,10 @@ function magnitudeType(type) { "Current", "Voltage", "Active Power", "Apparent Power", "Reactive Power", "Power Factor", "Energy", "Energy (delta)", "Analog", "Digital", "Event", - "PM1.0", "PM2.5", "PM10", "CO2", "Lux", "UV", "Distance" , "HCHO", + "PM1.0", "PM2.5", "PM10", + "Particles ≧0.3 ﹤0.5", "Particles ≧0.5 ﹤1", "Particles ≧1 ﹤2.5 ", + "Particles ≧2.5 ﹤5", "Particles ≧5 ﹤10", "Particles ≧10", + "CO2", "Lux", "UV", "Distance" , "HCHO", "Local Dose Rate", "Local Dose Rate", "Count", "NO2", "CO", "Resistance"