Browse Source

Begin with PMSx003 support

fastled
Oscar Rovira 7 years ago
parent
commit
610f161be7
5 changed files with 30 additions and 0 deletions
  1. +2
    -0
      code/.gitignore
  2. +6
    -0
      code/espurna/config/general.h
  3. +4
    -0
      code/espurna/config/hardware.h
  4. +14
    -0
      code/espurna/sensor.ino
  5. +4
    -0
      code/espurna/sensors/BaseSensor.h

+ 2
- 0
code/.gitignore View File

@ -4,3 +4,5 @@
.piolibdeps
.vscode/c_cpp_properties.json
core_version.h
.pioenvs
.piolibdeps

+ 6
- 0
code/espurna/config/general.h View File

@ -774,6 +774,9 @@ PROGMEM const char* const custom_reset_string[] = {
#define SENSOR_POWER_DECIMALS 0
#define SENSOR_POWER_FACTOR_DECIMALS 0
#define SENSOR_ENERGY_DECIMALS 0
#define SENSOR_PM1dot0_DECIMALS 0
#define SENSOR_PM2dot5_DECIMALS 0
#define SENSOR_PM10_DECIMALS 0
#define SENSOR_UNKNOWN_TOPIC "unknown"
#define SENSOR_TEMPERATURE_TOPIC "temperature"
@ -787,6 +790,9 @@ PROGMEM const char* const custom_reset_string[] = {
#define SENSOR_POWER_FACTOR_TOPIC "factor"
#define SENSOR_ENERGY_TOPIC "energy"
#define SENSOR_ENERGY_DELTA_TOPIC "energy_delta"
#define SENSOR_PM1dot0_TOPIC "pm1dot0"
#define SENSOR_PM2dot5_TOPIC "pm2dot5"
#define SENSOR_PM10_TOPIC "pm10"
#define SENSOR_ANALOG_TOPIC "analog"
#define SENSOR_EVENTS_TOPIC "events"


+ 4
- 0
code/espurna/config/hardware.h View File

@ -43,6 +43,10 @@
#define LED1_PIN 2
#define LED1_PIN_INVERSE 1
#define PMSX003_SUPPORT true
#define PMS_RX_PIN 13
#define PMS_TX_PIN 15
#elif defined(WEMOS_D1_MINI_RELAYSHIELD)
// Info


+ 14
- 0
code/espurna/sensor.ino View File

@ -48,6 +48,9 @@ String _sensorTopic(magnitude_t type) {
if (type == MAGNITUDE_POWER_FACTOR) return String(SENSOR_POWER_FACTOR_TOPIC);
if (type == MAGNITUDE_ENERGY) return String(SENSOR_ENERGY_TOPIC);
if (type == MAGNITUDE_ENERGY_DELTA) return String(SENSOR_ENERGY_DELTA_TOPIC);
if (type == MAGNITUDE_PM1dot0) return String(SENSOR_PM1dot0_TOPIC);
if (type == MAGNITUDE_PM2dot5) return String(SENSOR_PM2dot5_TOPIC);
if (type == MAGNITUDE_PM10) return String(SENSOR_PM10_TOPIC);
if (type == MAGNITUDE_ANALOG) return String(SENSOR_ANALOG_TOPIC);
if (type == MAGNITUDE_EVENTS) return String(SENSOR_EVENTS_TOPIC);
return String(SENSOR_UNKNOWN_TOPIC);
@ -65,6 +68,9 @@ unsigned char _sensorDecimals(magnitude_t type) {
if (type == MAGNITUDE_POWER_FACTOR) return SENSOR_POWER_FACTOR_DECIMALS;
if (type == MAGNITUDE_ENERGY) return SENSOR_ENERGY_DECIMALS;
if (type == MAGNITUDE_ENERGY_DELTA) return SENSOR_ENERGY_DECIMALS;
if (type == MAGNITUDE_PM1dot0) return SENSOR_PM1dot0_DECIMALS;
if (type == MAGNITUDE_PM2dot5) return SENSOR_PM2dot5_DECIMALS;
if (type == MAGNITUDE_PM10) return SENSOR_PM10_DECIMALS;
if (type == MAGNITUDE_ANALOG) return SENSOR_ANALOG_DECIMALS;
if (type == MAGNITUDE_EVENTS) return SENSOR_EVENTS_DECIMALS;
return 0;
@ -80,6 +86,9 @@ String _sensorUnits(magnitude_t type) {
if (type == MAGNITUDE_POWER_APPARENT) return String("W");
if (type == MAGNITUDE_POWER_REACTIVE) return String("W");
if (type == MAGNITUDE_POWER_FACTOR) return String("%");
if (type == MAGNITUDE_PM1dot0) return String("µg/m3");
if (type == MAGNITUDE_PM2dot5) return String("µg/m3");
if (type == MAGNITUDE_PM10) return String("µg/m3");
if (type == MAGNITUDE_ENERGY) return String("J");
if (type == MAGNITUDE_ENERGY_DELTA) return String("J");
if (type == MAGNITUDE_EVENTS) return String("/m");
@ -252,6 +261,11 @@ void sensorInit() {
#include "sensors/EmonADS1115Sensor.h"
sensorRegister(new EmonADS1115Sensor(EMON_ADS1115_I2C_ADDRESS, EMON_ADS1115_PORT_MASK, EMON_MAINS_VOLTAGE, EMON_ADS1115_ADC_BITS, EMON_ADS1115_REFERENCE_VOLTAGE, EMON_ADS1115_CURRENT_RATIO));
#endif
#if PMSX003_SUPPORT
#include "sensors/PMSX003Sensor.h"
sensorRegister(new PMSX003Sensor(PMS_RX_PIN, PMS_TX_PIN));
#endif
#if COUNTER_SUPPORT
if (_sensor_isr == 0xFF) {


+ 4
- 0
code/espurna/sensors/BaseSensor.h View File

@ -23,6 +23,10 @@ typedef enum magnitude_t {
MAGNITUDE_ENERGY_DELTA,
MAGNITUDE_POWER_FACTOR,
MAGNITUDE_PM1dot0,
MAGNITUDE_PM2dot5,
MAGNITUDE_PM10,
MAGNITUDE_ANALOG,
MAGNITUDE_EVENTS,


Loading…
Cancel
Save