Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

704 lines
24 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
6 years ago
  1. // =============================================================================
  2. // SENSORS - General data
  3. // =============================================================================
  4. #define SENSOR_DEBUG 0 // Debug sensors
  5. #define SENSOR_READ_INTERVAL 6 // Read data from sensors every 6 seconds
  6. #define SENSOR_READ_MIN_INTERVAL 6 // Minimum read interval
  7. #define SENSOR_READ_MAX_INTERVAL 3600 // Maximum read interval
  8. #define SENSOR_INIT_INTERVAL 10000 // Try to re-init non-ready sensors every 10s
  9. #define SENSOR_REPORT_EVERY 10 // Report every this many readings
  10. #define SENSOR_REPORT_MIN_EVERY 1 // Minimum every value
  11. #define SENSOR_REPORT_MAX_EVERY 12 // Maximum
  12. #define SENSOR_USE_INDEX 0 // Use the index in topic (i.e. temperature/0)
  13. // even if just one sensor (0 for backwards compatibility)
  14. #ifndef SENSOR_TEMPERATURE_CORRECTION
  15. #define SENSOR_TEMPERATURE_CORRECTION 0.0 // Offset correction
  16. #endif
  17. #ifndef TEMPERATURE_MIN_CHANGE
  18. #define TEMPERATURE_MIN_CHANGE 0.0 // Minimum temperature change to report
  19. #endif
  20. #ifndef SENSOR_HUMIDITY_CORRECTION
  21. #define SENSOR_HUMIDITY_CORRECTION 0.0 // Offset correction
  22. #endif
  23. #ifndef HUMIDITY_MIN_CHANGE
  24. #define HUMIDITY_MIN_CHANGE 0 // Minimum humidity change to report
  25. #endif
  26. #define HUMIDITY_NORMAL 0
  27. #define HUMIDITY_COMFORTABLE 1
  28. #define HUMIDITY_DRY 2
  29. #define HUMIDITY_WET 3
  30. #define SENSOR_PUBLISH_ADDRESSES 0 // Publish sensor addresses
  31. #define SENSOR_ADDRESS_TOPIC "address" // Topic to publish sensor addresses
  32. //------------------------------------------------------------------------------
  33. // UNITS
  34. //------------------------------------------------------------------------------
  35. #define POWER_WATTS 0
  36. #define POWER_KILOWATTS 1
  37. #define ENERGY_JOULES 0
  38. #define ENERGY_KWH 1
  39. #define TMP_CELSIUS 0
  40. #define TMP_FAHRENHEIT 1
  41. #ifndef SENSOR_TEMPERATURE_UNITS
  42. #define SENSOR_TEMPERATURE_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  43. #endif
  44. #ifndef SENSOR_ENERGY_UNITS
  45. #define SENSOR_ENERGY_UNITS ENERGY_JOULES // Energy units (ENERGY_JOULES | ENERGY_KWH)
  46. #endif
  47. #ifndef SENSOR_POWER_UNITS
  48. #define SENSOR_POWER_UNITS POWER_WATTS // Power units (POWER_WATTS | POWER_KILOWATTS)
  49. #endif
  50. //--------------------------------------------------------------------------------
  51. // Sensor ID
  52. // These should remain over time, do not modify them, only add new ones at the end
  53. //--------------------------------------------------------------------------------
  54. #define SENSOR_DHTXX_ID 0x01
  55. #define SENSOR_DALLAS_ID 0x02
  56. #define SENSOR_EMON_ANALOG_ID 0x03
  57. #define SENSOR_EMON_ADC121_ID 0x04
  58. #define SENSOR_EMON_ADS1X15_ID 0x05
  59. #define SENSOR_HLW8012_ID 0x06
  60. #define SENSOR_V9261F_ID 0x07
  61. #define SENSOR_ECH1560_ID 0x08
  62. #define SENSOR_ANALOG_ID 0x09
  63. #define SENSOR_DIGITAL_ID 0x10
  64. #define SENSOR_EVENTS_ID 0x11
  65. #define SENSOR_PMSX003_ID 0x12
  66. #define SENSOR_BMX280_ID 0x13
  67. #define SENSOR_MHZ19_ID 0x14
  68. #define SENSOR_SI7021_ID 0x15
  69. #define SENSOR_SHT3X_I2C_ID 0x16
  70. #define SENSOR_BH1750_ID 0x17
  71. #define SENSOR_PZEM004T_ID 0x18
  72. //--------------------------------------------------------------------------------
  73. // Magnitudes
  74. //--------------------------------------------------------------------------------
  75. #define MAGNITUDE_NONE 0
  76. #define MAGNITUDE_TEMPERATURE 1
  77. #define MAGNITUDE_HUMIDITY 2
  78. #define MAGNITUDE_PRESSURE 3
  79. #define MAGNITUDE_CURRENT 4
  80. #define MAGNITUDE_VOLTAGE 5
  81. #define MAGNITUDE_POWER_ACTIVE 6
  82. #define MAGNITUDE_POWER_APPARENT 7
  83. #define MAGNITUDE_POWER_REACTIVE 8
  84. #define MAGNITUDE_POWER_FACTOR 9
  85. #define MAGNITUDE_ENERGY 10
  86. #define MAGNITUDE_ENERGY_DELTA 11
  87. #define MAGNITUDE_ANALOG 12
  88. #define MAGNITUDE_DIGITAL 13
  89. #define MAGNITUDE_EVENTS 14
  90. #define MAGNITUDE_PM1dot0 15
  91. #define MAGNITUDE_PM2dot5 16
  92. #define MAGNITUDE_PM10 17
  93. #define MAGNITUDE_CO2 18
  94. #define MAGNITUDE_LUX 19
  95. #define MAGNITUDE_MAX 20
  96. // =============================================================================
  97. // Specific data for each sensor
  98. // =============================================================================
  99. //------------------------------------------------------------------------------
  100. // Analog sensor
  101. // Enable support by passing ANALOG_SUPPORT=1 build flag
  102. //--------------------------------------------------------------------------------
  103. #ifndef ANALOG_SUPPORT
  104. #define ANALOG_SUPPORT 0
  105. #endif
  106. #if ANALOG_SUPPORT
  107. #undef ADC_VCC_ENABLED
  108. #define ADC_VCC_ENABLED 0
  109. #endif
  110. //------------------------------------------------------------------------------
  111. // BH1750
  112. // Enable support by passing BH1750_SUPPORT=1 build flag
  113. // http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf
  114. //------------------------------------------------------------------------------
  115. #ifndef BH1750_SUPPORT
  116. #define BH1750_SUPPORT 0
  117. #endif
  118. #ifndef BH1750_ADDRESS
  119. #define BH1750_ADDRESS 0x00 // 0x00 means auto
  120. #endif
  121. #define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE
  122. #if BH1750_SUPPORT
  123. #undef I2C_SUPPORT
  124. #define I2C_SUPPORT 1
  125. #endif
  126. //------------------------------------------------------------------------------
  127. // BME280/BMP280
  128. // Enable support by passing BMX280_SUPPORT=1 build flag
  129. //------------------------------------------------------------------------------
  130. #ifndef BMX280_SUPPORT
  131. #define BMX280_SUPPORT 0
  132. #endif
  133. #ifndef BMX280_ADDRESS
  134. #define BMX280_ADDRESS 0x00 // 0x00 means auto
  135. #endif
  136. #define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode
  137. #define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms
  138. // 3 for 250ms, 4 for 500ms, 5 for 1000ms
  139. // 6 for 10ms, 7 for 20ms
  140. #define BMX280_FILTER 0 // 0 for OFF, 1 for 2 values, 2 for 4 values, 3 for 8 values and 4 for 16 values
  141. #define BMX280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  142. #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
  143. #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  144. #if BMX280_SUPPORT
  145. #undef I2C_SUPPORT
  146. #define I2C_SUPPORT 1
  147. #endif
  148. //------------------------------------------------------------------------------
  149. // Dallas OneWire temperature sensors
  150. // Enable support by passing DALLAS_SUPPORT=1 build flag
  151. //------------------------------------------------------------------------------
  152. #ifndef DALLAS_SUPPORT
  153. #define DALLAS_SUPPORT 0
  154. #endif
  155. #ifndef DALLAS_PIN
  156. #define DALLAS_PIN 14
  157. #endif
  158. #define DALLAS_RESOLUTION 9 // Not used atm
  159. #define DALLAS_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds
  160. //------------------------------------------------------------------------------
  161. // DHTXX temperature/humidity sensor
  162. // Enable support by passing DHT_SUPPORT=1 build flag
  163. //------------------------------------------------------------------------------
  164. #ifndef DHT_SUPPORT
  165. #define DHT_SUPPORT 0
  166. #endif
  167. #ifndef DHT_PIN
  168. #define DHT_PIN 14
  169. #endif
  170. #ifndef DHT_TYPE
  171. #define DHT_TYPE DHT_CHIP_DHT22
  172. #endif
  173. //------------------------------------------------------------------------------
  174. // Digital sensor
  175. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  176. //------------------------------------------------------------------------------
  177. #ifndef DIGITAL_SUPPORT
  178. #define DIGITAL_SUPPORT 0
  179. #endif
  180. #ifndef DIGITAL_PIN
  181. #define DIGITAL_PIN 2
  182. #endif
  183. #ifndef DIGITAL_PIN_MODE
  184. #define DIGITAL_PIN_MODE INPUT_PULLUP
  185. #endif
  186. #ifndef DIGITAL_DEFAULT_STATE
  187. #define DIGITAL_DEFAULT_STATE 1
  188. #endif
  189. //------------------------------------------------------------------------------
  190. // ECH1560 based power sensor
  191. // Enable support by passing ECH1560_SUPPORT=1 build flag
  192. //------------------------------------------------------------------------------
  193. #ifndef ECH1560_SUPPORT
  194. #define ECH1560_SUPPORT 0
  195. #endif
  196. #ifndef ECH1560_CLK_PIN
  197. #define ECH1560_CLK_PIN 4 // CLK pin for the ECH1560
  198. #endif
  199. #ifndef ECH1560_MISO_PIN
  200. #define ECH1560_MISO_PIN 5 // MISO pin for the ECH1560
  201. #endif
  202. #ifndef ECH1560_INVERTED
  203. #define ECH1560_INVERTED 0 // Signal is inverted
  204. #endif
  205. //------------------------------------------------------------------------------
  206. // Energy Monitor general settings
  207. //------------------------------------------------------------------------------
  208. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  209. #define EMON_MAX_TIME 250 // Max time in ms to sample
  210. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  211. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  212. #define EMON_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  213. #define EMON_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  214. #define EMON_REPORT_CURRENT 0 // Report current
  215. #define EMON_REPORT_POWER 1 // Report power
  216. #define EMON_REPORT_ENERGY 1 // Report energy
  217. //------------------------------------------------------------------------------
  218. // Energy Monitor based on ADC121
  219. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  220. //------------------------------------------------------------------------------
  221. #ifndef EMON_ADC121_SUPPORT
  222. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  223. #endif
  224. #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
  225. #if EMON_ADC121_SUPPORT
  226. #undef I2C_SUPPORT
  227. #define I2C_SUPPORT 1
  228. #endif
  229. //------------------------------------------------------------------------------
  230. // Energy Monitor based on ADS1X15
  231. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  232. //------------------------------------------------------------------------------
  233. #ifndef EMON_ADS1X15_SUPPORT
  234. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  235. #endif
  236. #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
  237. #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
  238. #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
  239. #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
  240. #if EMON_ADS1X15_SUPPORT
  241. #undef I2C_SUPPORT
  242. #define I2C_SUPPORT 1
  243. #endif
  244. //------------------------------------------------------------------------------
  245. // Energy Monitor based on interval analog GPIO
  246. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  247. //------------------------------------------------------------------------------
  248. #ifndef EMON_ANALOG_SUPPORT
  249. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  250. #endif
  251. #if EMON_ANALOG_SUPPORT
  252. #undef ADC_VCC_ENABLED
  253. #define ADC_VCC_ENABLED 0
  254. #endif
  255. //------------------------------------------------------------------------------
  256. // Counter sensor
  257. // Enable support by passing EVENTS_SUPPORT=1 build flag
  258. //------------------------------------------------------------------------------
  259. #ifndef EVENTS_SUPPORT
  260. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  261. #endif
  262. #ifndef EVENTS_PIN
  263. #define EVENTS_PIN 2 // GPIO to monitor
  264. #endif
  265. #ifndef EVENTS_PIN_MODE
  266. #define EVENTS_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  267. #endif
  268. #ifndef EVENTS_INTERRUPT_MODE
  269. #define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  270. #endif
  271. #define EVENTS_DEBOUNCE 50 // Do not register events within less than 10 millis
  272. //------------------------------------------------------------------------------
  273. // HLW8012 Energy monitor IC
  274. // Enable support by passing HLW8012_SUPPORT=1 build flag
  275. //------------------------------------------------------------------------------
  276. #ifndef HLW8012_SUPPORT
  277. #define HLW8012_SUPPORT 0
  278. #endif
  279. #ifndef HLW8012_SEL_PIN
  280. #define HLW8012_SEL_PIN 5
  281. #endif
  282. #ifndef HLW8012_CF1_PIN
  283. #define HLW8012_CF1_PIN 13
  284. #endif
  285. #ifndef HLW8012_CF_PIN
  286. #define HLW8012_CF_PIN 14
  287. #endif
  288. #ifndef HLW8012_SEL_CURRENT
  289. #define HLW8012_SEL_CURRENT HIGH // SEL pin to HIGH to measure current
  290. #endif
  291. #ifndef HLW8012_CURRENT_R
  292. #define HLW8012_CURRENT_R 0.001 // Current resistor
  293. #endif
  294. #ifndef HLW8012_VOLTAGE_R_UP
  295. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Upstream voltage resistor
  296. #endif
  297. #ifndef HLW8012_VOLTAGE_R_DOWN
  298. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Downstream voltage resistor
  299. #endif
  300. #define HLW8012_USE_INTERRUPTS 1 // Use interrupts to trap HLW8012 signals
  301. //------------------------------------------------------------------------------
  302. // MHZ19 CO2 sensor
  303. // Enable support by passing MHZ19_SUPPORT=1 build flag
  304. //------------------------------------------------------------------------------
  305. #ifndef MHZ19_SUPPORT
  306. #define MHZ19_SUPPORT 0
  307. #endif
  308. #define MHZ19_RX_PIN 13
  309. #define MHZ19_TX_PIN 15
  310. //------------------------------------------------------------------------------
  311. // Particle Monitor based on Plantower PMSX003
  312. // Enable support by passing PMSX003_SUPPORT=1 build flag
  313. //------------------------------------------------------------------------------
  314. #ifndef PMSX003_SUPPORT
  315. #define PMSX003_SUPPORT 0
  316. #endif
  317. #define PMS_RX_PIN 13
  318. #define PMS_TX_PIN 15
  319. //------------------------------------------------------------------------------
  320. // PZEM004T based power monitor
  321. // Enable support by passing PZEM004T_SUPPORT=1 build flag
  322. //------------------------------------------------------------------------------
  323. #ifndef PZEM004T_SUPPORT
  324. #define PZEM004T_SUPPORT 0
  325. #endif
  326. #ifndef PZEM004T_USE_SOFT
  327. #define PZEM004T_USE_SOFT 1 // Use software serial
  328. #endif
  329. #ifndef PZEM004T_RX_PIN
  330. #define PZEM004T_RX_PIN 13 // Software serial RX GPIO (if PZEM004T_USE_SOFT == 1)
  331. #endif
  332. #ifndef PZEM004T_TX_PIN
  333. #define PZEM004T_TX_PIN 15 // Software serial TX GPIO (if PZEM004T_USE_SOFT == 1)
  334. #endif
  335. #ifndef PZEM004T_HW_PORT
  336. #define PZEM004T_HW_PORT Serial1 // Hardware serial port (if PZEM004T_USE_SOFT == 0)
  337. #endif
  338. //------------------------------------------------------------------------------
  339. // SHT3X I2C (Wemos) temperature & humidity sensor
  340. // Enable support by passing SHT3X_SUPPORT=1 build flag
  341. //------------------------------------------------------------------------------
  342. #ifndef SHT3X_I2C_SUPPORT
  343. #define SHT3X_I2C_SUPPORT 0
  344. #endif
  345. #ifndef SHT3X_I2C_ADDRESS
  346. #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto
  347. #endif
  348. #if SHT3X_I2C_SUPPORT
  349. #undef I2C_SUPPORT
  350. #define I2C_SUPPORT 1
  351. #endif
  352. //------------------------------------------------------------------------------
  353. // SI7021 temperature & humidity sensor
  354. // Enable support by passing SI7021_SUPPORT=1 build flag
  355. //------------------------------------------------------------------------------
  356. #ifndef SI7021_SUPPORT
  357. #define SI7021_SUPPORT 0
  358. #endif
  359. #ifndef SI7021_ADDRESS
  360. #define SI7021_ADDRESS 0x00 // 0x00 means auto
  361. #endif
  362. #if SI7021_SUPPORT
  363. #undef I2C_SUPPORT
  364. #define I2C_SUPPORT 1
  365. #endif
  366. //------------------------------------------------------------------------------
  367. // V9261F based power sensor
  368. // Enable support by passing SI7021_SUPPORT=1 build flag
  369. //------------------------------------------------------------------------------
  370. #ifndef V9261F_SUPPORT
  371. #define V9261F_SUPPORT 0
  372. #endif
  373. #ifndef V9261F_PIN
  374. #define V9261F_PIN 2 // TX pin from the V9261F
  375. #endif
  376. #ifndef V9261F_PIN_INVERSE
  377. #define V9261F_PIN_INVERSE 1 // Signal is inverted
  378. #endif
  379. #define V9261F_SYNC_INTERVAL 600 // Sync signal length (ms)
  380. #define V9261F_BAUDRATE 4800 // UART baudrate
  381. // Default ratios
  382. #define V9261F_CURRENT_FACTOR 79371434.0
  383. #define V9261F_VOLTAGE_FACTOR 4160651.0
  384. #define V9261F_POWER_FACTOR 153699.0
  385. #define V9261F_RPOWER_FACTOR V9261F_CURRENT_FACTOR
  386. // =============================================================================
  387. // Sensor helpers configuration
  388. // =============================================================================
  389. #ifndef SENSOR_SUPPORT
  390. #if ANALOG_SUPPORT || BH1750_SUPPORT || BMX280_SUPPORT || DALLAS_SUPPORT \
  391. || DHT_SUPPORT || DIGITAL_SUPPORT || ECH1560_SUPPORT \
  392. || EMON_ADC121_SUPPORT || EMON_ADS1X15_SUPPORT \
  393. || EMON_ANALOG_SUPPORT || EVENTS_SUPPORT || HLW8012_SUPPORT \
  394. || MHZ19_SUPPORT || PMSX003_SUPPORT || SHT3X_I2C_SUPPORT \
  395. || SI7021_SUPPORT || V9261F_SUPPORT
  396. #define SENSOR_SUPPORT 1
  397. #else
  398. #define SENSOR_SUPPORT 0
  399. #endif
  400. #endif
  401. // -----------------------------------------------------------------------------
  402. // I2C
  403. // -----------------------------------------------------------------------------
  404. #ifndef I2C_SUPPORT
  405. #define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
  406. #endif
  407. #define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
  408. #ifndef I2C_SDA_PIN
  409. #define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4)
  410. #endif
  411. #ifndef I2C_SCL_PIN
  412. #define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14)
  413. #endif
  414. #define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
  415. #define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
  416. #define I2C_CLEAR_BUS 0 // Clear I2C bus on boot
  417. #define I2C_PERFORM_SCAN 1 // Perform a bus scan on boot
  418. //--------------------------------------------------------------------------------
  419. // Internal power monitor
  420. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  421. // Do not enable this if using the analog GPIO for any other thing
  422. //--------------------------------------------------------------------------------
  423. #ifndef ADC_VCC_ENABLED
  424. #define ADC_VCC_ENABLED 1
  425. #endif
  426. #if ADC_VCC_ENABLED
  427. ADC_MODE(ADC_VCC);
  428. #endif
  429. //--------------------------------------------------------------------------------
  430. // Class loading
  431. //--------------------------------------------------------------------------------
  432. #if SENSOR_SUPPORT
  433. PROGMEM const unsigned char magnitude_decimals[] = {
  434. 0,
  435. 1, 0, 2,
  436. 3, 0, 0, 0, 0, 0, 0, 0,
  437. 0, 0, 0,
  438. 0, 0, 0,
  439. 0, 0
  440. };
  441. PROGMEM const char magnitude_unknown_topic[] = "unknown";
  442. PROGMEM const char magnitude_temperature_topic[] = "temperature";
  443. PROGMEM const char magnitude_humidity_topic[] = "humidity";
  444. PROGMEM const char magnitude_pressure_topic[] = "pressure";
  445. PROGMEM const char magnitude_current_topic[] = "current";
  446. PROGMEM const char magnitude_voltage_topic[] = "voltage";
  447. PROGMEM const char magnitude_active_power_topic[] = "power";
  448. PROGMEM const char magnitude_apparent_power_topic[] = "apparent";
  449. PROGMEM const char magnitude_reactive_power_topic[] = "reactive";
  450. PROGMEM const char magnitude_power_factor_topic[] = "factor";
  451. PROGMEM const char magnitude_energy_topic[] = "energy";
  452. PROGMEM const char magnitude_energy_delta_topic[] = "energy_delta";
  453. PROGMEM const char magnitude_analog_topic[] = "analog";
  454. PROGMEM const char magnitude_digital_topic[] = "digital";
  455. PROGMEM const char magnitude_events_topic[] = "events";
  456. PROGMEM const char magnitude_pm1dot0_topic[] = "pm1dot0";
  457. PROGMEM const char magnitude_pm2dot5_topic[] = "pm2dot5";
  458. PROGMEM const char magnitude_pm10_topic[] = "pm10";
  459. PROGMEM const char magnitude_co2_topic[] = "co2";
  460. PROGMEM const char magnitude_lux_topic[] = "lux";
  461. PROGMEM const char* const magnitude_topics[] = {
  462. magnitude_unknown_topic, magnitude_temperature_topic, magnitude_humidity_topic,
  463. magnitude_pressure_topic, magnitude_current_topic, magnitude_voltage_topic,
  464. magnitude_active_power_topic, magnitude_apparent_power_topic, magnitude_reactive_power_topic,
  465. magnitude_power_factor_topic, magnitude_energy_topic, magnitude_energy_delta_topic,
  466. magnitude_analog_topic, magnitude_digital_topic, magnitude_events_topic,
  467. magnitude_pm1dot0_topic, magnitude_pm2dot5_topic, magnitude_pm10_topic,
  468. magnitude_co2_topic, magnitude_lux_topic
  469. };
  470. PROGMEM const char magnitude_empty[] = "";
  471. PROGMEM const char magnitude_celsius[] = "C";
  472. PROGMEM const char magnitude_fahrenheit[] = "F";
  473. PROGMEM const char magnitude_percentage[] = "%";
  474. PROGMEM const char magnitude_hectopascals[] = "hPa";
  475. PROGMEM const char magnitude_amperes[] = "A";
  476. PROGMEM const char magnitude_volts[] = "V";
  477. PROGMEM const char magnitude_watts[] = "W";
  478. PROGMEM const char magnitude_kw[] = "kW";
  479. PROGMEM const char magnitude_joules[] = "J";
  480. PROGMEM const char magnitude_kwh[] = "kWh";
  481. PROGMEM const char magnitude_ugm3[] = "µg/m3";
  482. PROGMEM const char magnitude_ppm[] = "ppm";
  483. PROGMEM const char magnitude_lux[] = "lux";
  484. PROGMEM const char* const magnitude_units[] = {
  485. magnitude_empty, magnitude_celsius, magnitude_percentage,
  486. magnitude_hectopascals, magnitude_amperes, magnitude_volts,
  487. magnitude_watts, magnitude_watts, magnitude_watts,
  488. magnitude_percentage, magnitude_joules, magnitude_joules,
  489. magnitude_empty, magnitude_empty, magnitude_empty,
  490. magnitude_ugm3, magnitude_ugm3, magnitude_ugm3,
  491. magnitude_ppm, magnitude_lux
  492. };
  493. #include "../sensors/BaseSensor.h"
  494. #if ANALOG_SUPPORT
  495. #include "../sensors/AnalogSensor.h"
  496. #endif
  497. #if BH1750_SUPPORT
  498. #include "../sensors/BH1750Sensor.h"
  499. #endif
  500. #if BMX280_SUPPORT
  501. #include <SparkFunBME280.h>
  502. #include "../sensors/BMX280Sensor.h"
  503. #endif
  504. #if DALLAS_SUPPORT
  505. #include <OneWire.h>
  506. #include "../sensors/DallasSensor.h"
  507. #endif
  508. #if DHT_SUPPORT
  509. #include "../sensors/DHTSensor.h"
  510. #endif
  511. #if DIGITAL_SUPPORT
  512. #include "../sensors/DigitalSensor.h"
  513. #endif
  514. #if ECH1560_SUPPORT
  515. #include "../sensors/ECH1560Sensor.h"
  516. #endif
  517. #if EMON_ADC121_SUPPORT
  518. #include "../sensors/EmonADC121Sensor.h"
  519. #endif
  520. #if EMON_ADS1X15_SUPPORT
  521. #include "../sensors/EmonADS1X15Sensor.h"
  522. #endif
  523. #if EMON_ANALOG_SUPPORT
  524. #include "../sensors/EmonAnalogSensor.h"
  525. #endif
  526. #if EVENTS_SUPPORT
  527. #include "../sensors/EventSensor.h"
  528. #endif
  529. #if HLW8012_SUPPORT
  530. #include <HLW8012.h>
  531. #include "../sensors/HLW8012Sensor.h"
  532. #endif
  533. #if MHZ19_SUPPORT
  534. #include <SoftwareSerial.h>
  535. #include "../sensors/MHZ19Sensor.h"
  536. #endif
  537. #if PMSX003_SUPPORT
  538. #include <SoftwareSerial.h>
  539. #include <PMS.h>
  540. #include "../sensors/PMSX003Sensor.h"
  541. #endif
  542. #if PZEM004T_SUPPORT
  543. #include <SoftwareSerial.h>
  544. #include "../sensors/PZEM004TSensor.h"
  545. #endif
  546. #if SI7021_SUPPORT
  547. #include "../sensors/SI7021Sensor.h"
  548. #endif
  549. #if SHT3X_I2C_SUPPORT
  550. #include "../sensors/SHT3XI2CSensor.h"
  551. #endif
  552. #if V9261F_SUPPORT
  553. #include <SoftwareSerial.h>
  554. #include "../sensors/V9261FSensor.h"
  555. #endif
  556. #endif // SENSOR_SUPPORT