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.

1118 lines
38 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
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 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 1 // 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 60 // 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_POWER_CHECK_STATUS
  15. #define SENSOR_POWER_CHECK_STATUS 1 // If set to 1 the reported power/current/energy will be 0 if the relay[0] is OFF
  16. #endif
  17. #ifndef SENSOR_TEMPERATURE_CORRECTION
  18. #define SENSOR_TEMPERATURE_CORRECTION 0.0 // Offset correction
  19. #endif
  20. #ifndef TEMPERATURE_MIN_CHANGE
  21. #define TEMPERATURE_MIN_CHANGE 0.0 // Minimum temperature change to report
  22. #endif
  23. #ifndef SENSOR_HUMIDITY_CORRECTION
  24. #define SENSOR_HUMIDITY_CORRECTION 0.0 // Offset correction
  25. #endif
  26. #ifndef HUMIDITY_MIN_CHANGE
  27. #define HUMIDITY_MIN_CHANGE 0 // Minimum humidity change to report
  28. #endif
  29. #ifndef ENERGY_MAX_CHANGE
  30. #define ENERGY_MAX_CHANGE 0 // Maximum energy change to report (if >0 it will allways report when delta(E) is greater than this)
  31. #endif
  32. #ifndef SENSOR_SAVE_EVERY
  33. #define SENSOR_SAVE_EVERY 0 // Save accumulating values to EEPROM (atm only energy)
  34. // A 0 means do not save and it's the default value
  35. // A number different from 0 means it should store the value in EEPROM
  36. // after these many reports
  37. // Warning: this might wear out flash fast!
  38. #endif
  39. #define SENSOR_PUBLISH_ADDRESSES 0 // Publish sensor addresses
  40. #define SENSOR_ADDRESS_TOPIC "address" // Topic to publish sensor addresses
  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. // Specific data for each sensor
  52. // =============================================================================
  53. //------------------------------------------------------------------------------
  54. // AM2320 Humidity & Temperature sensor over I2C
  55. // Enable support by passing AM2320_SUPPORT=1 build flag
  56. //------------------------------------------------------------------------------
  57. #ifndef AM2320_SUPPORT
  58. #define AM2320_SUPPORT 0
  59. #endif
  60. #ifndef AM2320_ADDRESS
  61. #define AM2320_ADDRESS 0x00 // 0x00 means auto
  62. #endif
  63. //------------------------------------------------------------------------------
  64. // Analog sensor
  65. // Enable support by passing ANALOG_SUPPORT=1 build flag
  66. //--------------------------------------------------------------------------------
  67. #ifndef ANALOG_SUPPORT
  68. #define ANALOG_SUPPORT 0
  69. #endif
  70. #ifndef ANALOG_SAMPLES
  71. #define ANALOG_SAMPLES 10 // Number of samples
  72. #endif
  73. #ifndef ANALOG_DELAY
  74. #define ANALOG_DELAY 0 // Delay between samples in micros
  75. #endif
  76. //Use the following to perform scaling of raw analog values
  77. // scaledRead = ( factor * rawRead ) + offset
  78. //
  79. //Please take note that the offset is not affected by the scaling factor
  80. #ifndef ANALOG_FACTOR
  81. #define ANALOG_FACTOR 1.0 // Multiply raw reading by this factor
  82. #endif
  83. #ifndef ANALOG_OFFSET
  84. #define ANALOG_OFFSET 0.0 // Add this offset to *scaled* value
  85. #endif
  86. // Round to this number of decimals
  87. #ifndef ANALOG_DECIMALS
  88. #define ANALOG_DECIMALS 2
  89. #endif
  90. //------------------------------------------------------------------------------
  91. // BH1750
  92. // Enable support by passing BH1750_SUPPORT=1 build flag
  93. // http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf
  94. //------------------------------------------------------------------------------
  95. #ifndef BH1750_SUPPORT
  96. #define BH1750_SUPPORT 0
  97. #endif
  98. #ifndef BH1750_ADDRESS
  99. #define BH1750_ADDRESS 0x00 // 0x00 means auto
  100. #endif
  101. #define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE
  102. //------------------------------------------------------------------------------
  103. // BMP085/BMP180
  104. // Enable support by passing BMP180_SUPPORT=1 build flag
  105. //------------------------------------------------------------------------------
  106. #ifndef BMP180_SUPPORT
  107. #define BMP180_SUPPORT 0
  108. #endif
  109. #ifndef BMP180_ADDRESS
  110. #define BMP180_ADDRESS 0x00 // 0x00 means auto
  111. #endif
  112. #define BMP180_MODE 3 // 0 for ultra-low power, 1 for standard, 2 for high resolution and 3 for ultrahigh resolution
  113. //------------------------------------------------------------------------------
  114. // BME280/BMP280
  115. // Enable support by passing BMX280_SUPPORT=1 build flag
  116. //------------------------------------------------------------------------------
  117. #ifndef BMX280_SUPPORT
  118. #define BMX280_SUPPORT 0
  119. #endif
  120. #ifndef BMX280_NUMBER
  121. #define BMX280_NUMBER 1 // Number of sensors present. Either 1 or 2 allowed
  122. #endif
  123. #ifndef BMX280_ADDRESS
  124. #define BMX280_ADDRESS 0x00 // 0x00 means auto (0x76 or 0x77 allowed) for sensor #0
  125. #endif // If (BMX280_NUMBER == 2) and
  126. // (BMX280_ADDRESS == 0x00) then sensor #1 is auto-discovered
  127. // (BMX280_ADDRESS != 0x00) then sensor #1 is the unnamed address
  128. #define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode
  129. #define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms
  130. // 3 for 250ms, 4 for 500ms, 5 for 1000ms
  131. // 6 for 10ms, 7 for 20ms
  132. #define BMX280_FILTER 0 // 0 for OFF, 1 for 2 values, 2 for 4 values, 3 for 8 values and 4 for 16 values
  133. #define BMX280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  134. // 0b000 = 0 = Skip measurement
  135. // 0b001 = 1 = 1x 16bit/0.0050C resolution
  136. // 0b010 = 2 = 2x 17bit/0.0025C
  137. // 0b011 = 3 = 4x 18bit/0.0012C
  138. // 0b100 = 4 = 8x 19bit/0.0006C
  139. // 0b101 = 5 = 16x 20bit/0.0003C
  140. #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
  141. // 0b000 = 0 = Skip measurement
  142. // 0b001 = 1 = 1x 0.07% resolution
  143. // 0b010 = 2 = 2x 0.05%
  144. // 0b011 = 3 = 4x 0.04%
  145. // 0b100 = 4 = 8x 0.03%
  146. // 0b101 = 5 = 16x 0.02%
  147. #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  148. // 0b000 = 0 = Skipped
  149. // 0b001 = 1 = 1x 16bit/2.62 Pa resolution
  150. // 0b010 = 2 = 2x 17bit/1.31 Pa
  151. // 0b011 = 3 = 4x 18bit/0.66 Pa
  152. // 0b100 = 4 = 8x 19bit/0.33 Pa
  153. // 0b101 = 5 = 16x 20bit/0.16 Pa
  154. //------------------------------------------------------------------------------
  155. // Dallas OneWire temperature sensors
  156. // Enable support by passing DALLAS_SUPPORT=1 build flag
  157. //------------------------------------------------------------------------------
  158. #ifndef DALLAS_SUPPORT
  159. #define DALLAS_SUPPORT 0
  160. #endif
  161. #ifndef DALLAS_PIN
  162. #define DALLAS_PIN 14
  163. #endif
  164. #define DALLAS_RESOLUTION 9 // Not used atm
  165. #define DALLAS_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds
  166. //------------------------------------------------------------------------------
  167. // DHTXX temperature/humidity sensor
  168. // Enable support by passing DHT_SUPPORT=1 build flag
  169. //------------------------------------------------------------------------------
  170. #ifndef DHT_SUPPORT
  171. #define DHT_SUPPORT 0
  172. #endif
  173. #ifndef DHT_PIN
  174. #define DHT_PIN 14
  175. #endif
  176. #ifndef DHT_TYPE
  177. #define DHT_TYPE DHT_CHIP_DHT22
  178. #endif
  179. //------------------------------------------------------------------------------
  180. // CSE7766 based power sensor
  181. // Enable support by passing CSE7766_SUPPORT=1 build flag
  182. //------------------------------------------------------------------------------
  183. #ifndef CSE7766_SUPPORT
  184. #define CSE7766_SUPPORT 0
  185. #endif
  186. #ifndef CSE7766_PIN
  187. #define CSE7766_PIN 1 // TX pin from the CSE7766
  188. #endif
  189. #ifndef CSE7766_PIN_INVERSE
  190. #define CSE7766_PIN_INVERSE 0 // Signal is inverted
  191. #endif
  192. #define CSE7766_SYNC_INTERVAL 300 // Safe time between transmissions (ms)
  193. #define CSE7766_BAUDRATE 4800 // UART baudrate
  194. #define CSE7766_V1R 1.0 // 1mR current resistor
  195. #define CSE7766_V2R 1.0 // 1M voltage resistor
  196. //------------------------------------------------------------------------------
  197. // Digital sensor
  198. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  199. //------------------------------------------------------------------------------
  200. #ifndef DIGITAL_SUPPORT
  201. #define DIGITAL_SUPPORT 0
  202. #endif
  203. #ifndef DIGITAL_PIN
  204. #define DIGITAL_PIN 2
  205. #endif
  206. #ifndef DIGITAL_PIN_MODE
  207. #define DIGITAL_PIN_MODE INPUT_PULLUP
  208. #endif
  209. #ifndef DIGITAL_DEFAULT_STATE
  210. #define DIGITAL_DEFAULT_STATE 1
  211. #endif
  212. //------------------------------------------------------------------------------
  213. // ECH1560 based power sensor
  214. // Enable support by passing ECH1560_SUPPORT=1 build flag
  215. //------------------------------------------------------------------------------
  216. #ifndef ECH1560_SUPPORT
  217. #define ECH1560_SUPPORT 0
  218. #endif
  219. #ifndef ECH1560_CLK_PIN
  220. #define ECH1560_CLK_PIN 4 // CLK pin for the ECH1560
  221. #endif
  222. #ifndef ECH1560_MISO_PIN
  223. #define ECH1560_MISO_PIN 5 // MISO pin for the ECH1560
  224. #endif
  225. #ifndef ECH1560_INVERTED
  226. #define ECH1560_INVERTED 0 // Signal is inverted
  227. #endif
  228. //------------------------------------------------------------------------------
  229. // Energy Monitor general settings
  230. //------------------------------------------------------------------------------
  231. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  232. #define EMON_MAX_TIME 250 // Max time in ms to sample
  233. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  234. #define EMON_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  235. #ifndef EMON_MAINS_VOLTAGE
  236. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  237. #endif
  238. #ifndef EMON_CURRENT_RATIO
  239. #define EMON_CURRENT_RATIO 30 // Current ratio in the clamp (30A/1V)
  240. #endif
  241. #ifndef EMON_REPORT_CURRENT
  242. #define EMON_REPORT_CURRENT 0 // Report current
  243. #endif
  244. #ifndef EMON_REPORT_POWER
  245. #define EMON_REPORT_POWER 1 // Report power
  246. #endif
  247. #ifndef EMON_REPORT_ENERGY
  248. #define EMON_REPORT_ENERGY 1 // Report energy
  249. #endif
  250. //------------------------------------------------------------------------------
  251. // Energy Monitor based on ADC121
  252. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  253. //------------------------------------------------------------------------------
  254. #ifndef EMON_ADC121_SUPPORT
  255. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  256. #endif
  257. #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
  258. //------------------------------------------------------------------------------
  259. // Energy Monitor based on ADS1X15
  260. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  261. //------------------------------------------------------------------------------
  262. #ifndef EMON_ADS1X15_SUPPORT
  263. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  264. #endif
  265. #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
  266. #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
  267. #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
  268. #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
  269. //------------------------------------------------------------------------------
  270. // Energy Monitor based on interval analog GPIO
  271. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  272. //------------------------------------------------------------------------------
  273. #ifndef EMON_ANALOG_SUPPORT
  274. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  275. #endif
  276. //------------------------------------------------------------------------------
  277. // Counter sensor
  278. // Enable support by passing EVENTS_SUPPORT=1 build flag
  279. //------------------------------------------------------------------------------
  280. #ifndef EVENTS_SUPPORT
  281. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  282. #endif
  283. #ifndef EVENTS_TRIGGER
  284. #define EVENTS_TRIGGER 1 // 1 to trigger callback on events,
  285. // 0 to only count them and report periodically
  286. #endif
  287. #ifndef EVENTS_PIN
  288. #define EVENTS_PIN 2 // GPIO to monitor
  289. #endif
  290. #ifndef EVENTS_PIN_MODE
  291. #define EVENTS_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  292. #endif
  293. #ifndef EVENTS_INTERRUPT_MODE
  294. #define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  295. #endif
  296. #define EVENTS_DEBOUNCE 50 // Do not register events within less than 50 millis
  297. //------------------------------------------------------------------------------
  298. // Geiger sensor
  299. // Enable support by passing GEIGER_SUPPORT=1 build flag
  300. //------------------------------------------------------------------------------
  301. #ifndef GEIGER_SUPPORT
  302. #define GEIGER_SUPPORT 0 // Do not build with geiger support by default
  303. #endif
  304. #ifndef GEIGER_PIN
  305. #define GEIGER_PIN D1 // GPIO to monitor "D1" => "GPIO5"
  306. #endif
  307. #ifndef GEIGER_PIN_MODE
  308. #define GEIGER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  309. #endif
  310. #ifndef GEIGER_INTERRUPT_MODE
  311. #define GEIGER_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  312. #endif
  313. #define GEIGER_DEBOUNCE 25 // Do not register events within less than 25 millis.
  314. // Value derived here: Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter
  315. #define GEIGER_CPM2SIEVERT 240 // CPM to µSievert per hour conversion factor
  316. // Typically the literature uses the invers, but I find an integer type more convienient.
  317. #define GEIGER_REPORT_SIEVERTS 1 // Enabler for local dose rate reports in µSv/h
  318. #define GEIGER_REPORT_CPM 1 // Enabler for local dose rate reports in counts per minute
  319. //------------------------------------------------------------------------------
  320. // GUVAS12SD UV Sensor (analog)
  321. // Enable support by passing GUVAS12SD_SUPPORT=1 build flag
  322. //------------------------------------------------------------------------------
  323. #ifndef GUVAS12SD_SUPPORT
  324. #define GUVAS12SD_SUPPORT 0
  325. #endif
  326. #ifndef GUVAS12SD_PIN
  327. #define GUVAS12SD_PIN 14
  328. #endif
  329. //------------------------------------------------------------------------------
  330. // HLW8012 Energy monitor IC
  331. // Enable support by passing HLW8012_SUPPORT=1 build flag
  332. //------------------------------------------------------------------------------
  333. #ifndef HLW8012_SUPPORT
  334. #define HLW8012_SUPPORT 0
  335. #endif
  336. #ifndef HLW8012_SEL_PIN
  337. #define HLW8012_SEL_PIN 5
  338. #endif
  339. #ifndef HLW8012_CF1_PIN
  340. #define HLW8012_CF1_PIN 13
  341. #endif
  342. #ifndef HLW8012_CF_PIN
  343. #define HLW8012_CF_PIN 14
  344. #endif
  345. #ifndef HLW8012_SEL_CURRENT
  346. #define HLW8012_SEL_CURRENT HIGH // SEL pin to HIGH to measure current
  347. #endif
  348. #ifndef HLW8012_CURRENT_R
  349. #define HLW8012_CURRENT_R 0.001 // Current resistor
  350. #endif
  351. #ifndef HLW8012_VOLTAGE_R_UP
  352. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Upstream voltage resistor
  353. #endif
  354. #ifndef HLW8012_VOLTAGE_R_DOWN
  355. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Downstream voltage resistor
  356. #endif
  357. #ifndef HLW8012_CURRENT_RATIO
  358. #define HLW8012_CURRENT_RATIO 0 // Set to 0 to use factory defaults
  359. #endif
  360. #ifndef HLW8012_VOLTAGE_RATIO
  361. #define HLW8012_VOLTAGE_RATIO 0 // Set to 0 to use factory defaults
  362. #endif
  363. #ifndef HLW8012_POWER_RATIO
  364. #define HLW8012_POWER_RATIO 0 // Set to 0 to use factory defaults
  365. #endif
  366. #ifndef HLW8012_USE_INTERRUPTS
  367. #define HLW8012_USE_INTERRUPTS 1 // Use interrupts to trap HLW8012 signals
  368. #endif
  369. #ifndef HLW8012_WAIT_FOR_WIFI
  370. #define HLW8012_WAIT_FOR_WIFI 0 // Weather to enable interrupts only after
  371. // wifi connection has been stablished
  372. #endif
  373. #ifndef HLW8012_INTERRUPT_ON
  374. #define HLW8012_INTERRUPT_ON CHANGE // When to trigger the interrupt
  375. // Use CHANGE for HLW8012
  376. // Use FALLING for BL0937 / HJL0
  377. #endif
  378. //------------------------------------------------------------------------------
  379. // MHZ19 CO2 sensor
  380. // Enable support by passing MHZ19_SUPPORT=1 build flag
  381. //------------------------------------------------------------------------------
  382. #ifndef MHZ19_SUPPORT
  383. #define MHZ19_SUPPORT 0
  384. #endif
  385. #ifndef MHZ19_RX_PIN
  386. #define MHZ19_RX_PIN 13
  387. #endif
  388. #ifndef MHZ19_TX_PIN
  389. #define MHZ19_TX_PIN 15
  390. #endif
  391. //------------------------------------------------------------------------------
  392. // MICS-2710 (and MICS-4514) NO2 sensor
  393. // Enable support by passing MICS2710_SUPPORT=1 build flag
  394. //------------------------------------------------------------------------------
  395. #ifndef MICS2710_SUPPORT
  396. #define MICS2710_SUPPORT 0
  397. #endif
  398. #ifndef MICS2710_NOX_PIN
  399. #define MICS2710_NOX_PIN 0
  400. #endif
  401. #ifndef MICS2710_PRE_PIN
  402. #define MICS2710_PRE_PIN 4
  403. #endif
  404. #define MICS2710_PREHEAT_TIME 10000 // 10s preheat for NOX read
  405. #define MICS2710_RL 820 // RL, load resistor
  406. #define MICS2710_R0 2200 // R0 calibration value for NO2 sensor,
  407. // Typical value as per datasheet
  408. //------------------------------------------------------------------------------
  409. // MICS-5525 (and MICS-4514) CO sensor
  410. // Enable support by passing MICS5525_SUPPORT=1 build flag
  411. //------------------------------------------------------------------------------
  412. #ifndef MICS5525_SUPPORT
  413. #define MICS5525_SUPPORT 0
  414. #endif
  415. #ifndef MICS5525_RED_PIN
  416. #define MICS5525_RED_PIN 0
  417. #endif
  418. #define MICS5525_RL 820 // RL, load resistor
  419. #define MICS5525_R0 750000 // R0 calibration value for NO2 sensor,
  420. // Typical value as per datasheet
  421. //------------------------------------------------------------------------------
  422. // NTC sensor
  423. // Enable support by passing NTC_SUPPORT=1 build flag
  424. //--------------------------------------------------------------------------------
  425. #ifndef NTC_SUPPORT
  426. #define NTC_SUPPORT 0
  427. #endif
  428. #ifndef NTC_SAMPLES
  429. #define NTC_SAMPLES 10 // Number of samples
  430. #endif
  431. #ifndef NTC_DELAY
  432. #define NTC_DELAY 0 // Delay between samples in micros
  433. #endif
  434. #ifndef NTC_R_UP
  435. #define NTC_R_UP 0 // Resistor upstream, set to 0 if none
  436. #endif
  437. #ifndef NTC_R_DOWN
  438. #define NTC_R_DOWN 10000 // Resistor downstream, set to 0 if none
  439. #endif
  440. #ifndef NTC_T0
  441. #define NTC_T0 298.15 // 25 Celsius
  442. #endif
  443. #ifndef NTC_R0
  444. #define NTC_R0 10000 // Resistance at T0
  445. #endif
  446. #ifndef NTC_BETA
  447. #define NTC_BETA 3977 // Beta coeficient
  448. #endif
  449. //------------------------------------------------------------------------------
  450. // Particle Monitor based on Plantower PMS
  451. // Enable support by passing PMSX003_SUPPORT=1 build flag
  452. //------------------------------------------------------------------------------
  453. #ifndef PMSX003_SUPPORT
  454. #define PMSX003_SUPPORT 0
  455. #endif
  456. #ifndef PMS_TYPE
  457. #define PMS_TYPE PMS_TYPE_X003
  458. #endif
  459. // You can enable smart sleep (read 6-times then sleep on 24-reading-cycles) to extend PMS sensor's life.
  460. // Otherwise the default lifetime of PMS sensor is about 8000-hours/1-years.
  461. // The PMS's fan will stop working on sleeping cycle, and will wake up on reading cycle.
  462. #ifndef PMS_SMART_SLEEP
  463. #define PMS_SMART_SLEEP 0
  464. #endif
  465. #ifndef PMS_USE_SOFT
  466. #define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0
  467. #endif
  468. #ifndef PMS_RX_PIN
  469. #define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1)
  470. #endif
  471. #ifndef PMS_TX_PIN
  472. #define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1)
  473. #endif
  474. #ifndef PMS_HW_PORT
  475. #define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0)
  476. #endif
  477. //------------------------------------------------------------------------------
  478. // Pulse Meter Energy monitor
  479. // Enable support by passing PULSEMETER_SUPPORT=1 build flag
  480. //------------------------------------------------------------------------------
  481. #ifndef PULSEMETER_SUPPORT
  482. #define PULSEMETER_SUPPORT 0
  483. #endif
  484. #ifndef PULSEMETER_PIN
  485. #define PULSEMETER_PIN 5
  486. #endif
  487. #ifndef PULSEMETER_ENERGY_RATIO
  488. #define PULSEMETER_ENERGY_RATIO 4000 // In pulses/kWh
  489. #endif
  490. #ifndef PULSEMETER_INTERRUPT_ON
  491. #define PULSEMETER_INTERRUPT_ON FALLING
  492. #endif
  493. #ifndef PULSEMETER_DEBOUNCE
  494. #define PULSEMETER_DEBOUNCE 50 // Do not register pulses within less than 50 millis
  495. #endif
  496. //------------------------------------------------------------------------------
  497. // PZEM004T based power monitor
  498. // Enable support by passing PZEM004T_SUPPORT=1 build flag
  499. //------------------------------------------------------------------------------
  500. #ifndef PZEM004T_SUPPORT
  501. #define PZEM004T_SUPPORT 0
  502. #endif
  503. #ifndef PZEM004T_USE_SOFT
  504. #define PZEM004T_USE_SOFT 0 // Software serial is not working atm, use hardware serial
  505. #endif
  506. #ifndef PZEM004T_RX_PIN
  507. #define PZEM004T_RX_PIN 13 // Software serial RX GPIO (if PZEM004T_USE_SOFT == 1)
  508. #endif
  509. #ifndef PZEM004T_TX_PIN
  510. #define PZEM004T_TX_PIN 15 // Software serial TX GPIO (if PZEM004T_USE_SOFT == 1)
  511. #endif
  512. #ifndef PZEM004T_HW_PORT
  513. #define PZEM004T_HW_PORT Serial // Hardware serial port (if PZEM004T_USE_SOFT == 0)
  514. #endif
  515. #ifndef PZEM004T_ADDRESSES
  516. #define PZEM004T_ADDRESSES "192.168.1.1" // Device(s) address(es), separated by space, "192.168.1.1 192.168.1.2 192.168.1.3"
  517. #endif
  518. #ifndef PZEM004T_READ_INTERVAL
  519. #define PZEM004T_READ_INTERVAL 1500 // Read interval between same device
  520. #endif
  521. #ifndef PZEM004T_MAX_DEVICES
  522. #define PZEM004T_MAX_DEVICES 3
  523. #endif
  524. //------------------------------------------------------------------------------
  525. // SDS011 particulates sensor
  526. // Enable support by passing SDS011_SUPPORT=1 build flag
  527. //------------------------------------------------------------------------------
  528. #ifndef SDS011_SUPPORT
  529. #define SDS011_SUPPORT 0
  530. #endif
  531. #ifndef SDS011_RX_PIN
  532. #define SDS011_RX_PIN 14
  533. #endif
  534. #ifndef SDS011_TX_PIN
  535. #define SDS011_TX_PIN 12
  536. #endif
  537. //------------------------------------------------------------------------------
  538. // SenseAir CO2 sensor
  539. // Enable support by passing SENSEAIR_SUPPORT=1 build flag
  540. //------------------------------------------------------------------------------
  541. #ifndef SENSEAIR_SUPPORT
  542. #define SENSEAIR_SUPPORT 0
  543. #endif
  544. #ifndef SENSEAIR_RX_PIN
  545. #define SENSEAIR_RX_PIN 0
  546. #endif
  547. #ifndef SENSEAIR_TX_PIN
  548. #define SENSEAIR_TX_PIN 2
  549. #endif
  550. //------------------------------------------------------------------------------
  551. // SHT3X I2C (Wemos) temperature & humidity sensor
  552. // Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
  553. //------------------------------------------------------------------------------
  554. #ifndef SHT3X_I2C_SUPPORT
  555. #define SHT3X_I2C_SUPPORT 0
  556. #endif
  557. #ifndef SHT3X_I2C_ADDRESS
  558. #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto
  559. #endif
  560. //------------------------------------------------------------------------------
  561. // SI7021 temperature & humidity sensor
  562. // Enable support by passing SI7021_SUPPORT=1 build flag
  563. //------------------------------------------------------------------------------
  564. #ifndef SI7021_SUPPORT
  565. #define SI7021_SUPPORT 0
  566. #endif
  567. #ifndef SI7021_ADDRESS
  568. #define SI7021_ADDRESS 0x00 // 0x00 means auto
  569. #endif
  570. //------------------------------------------------------------------------------
  571. // Sonar
  572. // Enable support by passing SONAR_SUPPORT=1 build flag
  573. //------------------------------------------------------------------------------
  574. #ifndef SONAR_SUPPORT
  575. #define SONAR_SUPPORT 0
  576. #endif
  577. #ifndef SONAR_TRIGGER
  578. #define SONAR_TRIGGER 12 // GPIO for the trigger pin (output)
  579. #endif
  580. #ifndef SONAR_ECHO
  581. #define SONAR_ECHO 14 // GPIO for the echo pin (input)
  582. #endif
  583. #ifndef SONAR_MAX_DISTANCE
  584. #define SONAR_MAX_DISTANCE MAX_SENSOR_DISTANCE // Max sensor distance in cm
  585. #endif
  586. #ifndef SONAR_ITERATIONS
  587. #define SONAR_ITERATIONS 5 // Number of iterations to ping for
  588. #endif // error correction.
  589. //------------------------------------------------------------------------------
  590. // TMP3X analog temperature sensor
  591. // Enable support by passing TMP3X_SUPPORT=1 build flag
  592. //------------------------------------------------------------------------------
  593. #ifndef TMP3X_SUPPORT
  594. #define TMP3X_SUPPORT 0
  595. #endif
  596. #ifndef TMP3X_TYPE
  597. #define TMP3X_TYPE TMP3X_TMP35
  598. #endif
  599. //------------------------------------------------------------------------------
  600. // V9261F based power sensor
  601. // Enable support by passing SI7021_SUPPORT=1 build flag
  602. //------------------------------------------------------------------------------
  603. #ifndef V9261F_SUPPORT
  604. #define V9261F_SUPPORT 0
  605. #endif
  606. #ifndef V9261F_PIN
  607. #define V9261F_PIN 2 // TX pin from the V9261F
  608. #endif
  609. #ifndef V9261F_PIN_INVERSE
  610. #define V9261F_PIN_INVERSE 1 // Signal is inverted
  611. #endif
  612. #define V9261F_SYNC_INTERVAL 600 // Sync signal length (ms)
  613. #define V9261F_BAUDRATE 4800 // UART baudrate
  614. // Default ratios
  615. #define V9261F_CURRENT_FACTOR 79371434.0
  616. #define V9261F_VOLTAGE_FACTOR 4160651.0
  617. #define V9261F_POWER_FACTOR 153699.0
  618. #define V9261F_RPOWER_FACTOR V9261F_CURRENT_FACTOR
  619. //------------------------------------------------------------------------------
  620. // VEML6075 based power sensor
  621. // Enable support by passing VEML6075_SUPPORT=1 build flag
  622. //------------------------------------------------------------------------------
  623. #ifndef VEML6075_SUPPORT
  624. #define VEML6075_SUPPORT 0
  625. #endif
  626. #ifndef VEML6075_INTEGRATION_TIME
  627. #define VEML6075_INTEGRATION_TIME VEML6075::IT_100MS // The time, in milliseconds, allocated for a single
  628. #endif // measurement. A longer timing budget allows for more
  629. // accurate results at the cost of power.
  630. #ifndef VEML6075_DYNAMIC_MODE
  631. #define VEML6075_DYNAMIC_MODE VEML6075::DYNAMIC_NORMAL // The dynamic mode can either be normal or high. In high
  632. #endif // dynamic mode, the resolution increases by about two
  633. // times.
  634. //------------------------------------------------------------------------------
  635. // VL53L1X
  636. // Enable support by passing VL53L1X_SUPPORT=1 build flag
  637. //------------------------------------------------------------------------------
  638. #ifndef VL53L1X_SUPPORT
  639. #define VL53L1X_SUPPORT 0
  640. #endif
  641. #ifndef VL53L1X_I2C_ADDRESS
  642. #define VL53L1X_I2C_ADDRESS 0x00 // 0x00 means auto
  643. #endif
  644. #ifndef VL53L1X_DISTANCE_MODE
  645. #define VL53L1X_DISTANCE_MODE VL53L1X::Long // The distance mode of the sensor. Can be one of
  646. #endif // `VL53L1X::Short`, `VL53L1X::Medium`, or `VL53L1X::Long.
  647. // Shorter distance modes are less affected by ambient light
  648. // but have lower maximum ranges, especially in the dark.
  649. #ifndef VL53L1X_MEASUREMENT_TIMING_BUDGET
  650. #define VL53L1X_MEASUREMENT_TIMING_BUDGET 140000 // The time, in microseconds, allocated for a single
  651. // measurement. A longer timing budget allows for more
  652. // accurate at the cost of power. The minimum budget is
  653. // 20 ms (20000 us) in short distance mode and 33 ms for
  654. // medium and long distance modes.
  655. #endif
  656. #ifndef VL53L1X_INTER_MEASUREMENT_PERIOD
  657. #define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how
  658. #endif // often the sensor takes a measurement.
  659. //------------------------------------------------------------------------------
  660. // MAX6675
  661. // Enable support by passing MAX6675_SUPPORT=1 build flag
  662. //------------------------------------------------------------------------------
  663. #ifndef MAX6675_CS_PIN
  664. #define MAX6675_CS_PIN 13
  665. #endif
  666. #ifndef MAX6675_SO_PIN
  667. #define MAX6675_SO_PIN 12
  668. #endif
  669. #ifndef MAX6675_SCK_PIN
  670. #define MAX6675_SCK_PIN 14
  671. #endif
  672. //------------------------------------------------------------------------------
  673. // EZOPH pH meter
  674. // Enable support by passing EZOPH_SUPPORT=1 build flag
  675. //------------------------------------------------------------------------------
  676. #ifndef EZOPH_SUPPORT
  677. #define EZOPH_SUPPORT 0
  678. #endif
  679. #ifndef EZOPH_RX_PIN
  680. #define EZOPH_RX_PIN 13 // Software serial RX GPIO
  681. #endif
  682. #ifndef EZOPH_TX_PIN
  683. #define EZOPH_TX_PIN 15 // Software serial TX GPIO
  684. #endif
  685. #ifndef EZOPH_SYNC_INTERVAL
  686. #define EZOPH_SYNC_INTERVAL 1000 // Amount of time (in ms) sync new readings.
  687. #endif
  688. // =============================================================================
  689. // Sensor helpers configuration - can't move to dependencies.h
  690. // =============================================================================
  691. #ifndef SENSOR_SUPPORT
  692. #define SENSOR_SUPPORT ( \
  693. AM2320_SUPPORT || \
  694. ANALOG_SUPPORT || \
  695. BH1750_SUPPORT || \
  696. BMP180_SUPPORT || \
  697. BMX280_SUPPORT || \
  698. CSE7766_SUPPORT || \
  699. DALLAS_SUPPORT || \
  700. DHT_SUPPORT || \
  701. DIGITAL_SUPPORT || \
  702. ECH1560_SUPPORT || \
  703. EMON_ADC121_SUPPORT || \
  704. EMON_ADS1X15_SUPPORT || \
  705. EMON_ANALOG_SUPPORT || \
  706. EVENTS_SUPPORT || \
  707. GEIGER_SUPPORT || \
  708. GUVAS12SD_SUPPORT || \
  709. HLW8012_SUPPORT || \
  710. MICS2710_SUPPORT || \
  711. MICS5525_SUPPORT || \
  712. MHZ19_SUPPORT || \
  713. NTC_SUPPORT || \
  714. SDS011_SUPPORT || \
  715. SENSEAIR_SUPPORT || \
  716. PMSX003_SUPPORT || \
  717. PZEM004T_SUPPORT || \
  718. PULSEMETER_SUPPORT || \
  719. SHT3X_I2C_SUPPORT || \
  720. SI7021_SUPPORT || \
  721. SONAR_SUPPORT || \
  722. TMP3X_SUPPORT || \
  723. V9261F_SUPPORT || \
  724. VEML6075_SUPPORT || \
  725. VL53L1X_SUPPORT || \
  726. MAX6675_SUPPORT || \
  727. EZOPH_SUPPORT \
  728. )
  729. #endif
  730. // -----------------------------------------------------------------------------
  731. // ADC
  732. // -----------------------------------------------------------------------------
  733. // Default ADC mode is to monitor internal power supply
  734. #ifndef ADC_MODE_VALUE
  735. #define ADC_MODE_VALUE ADC_VCC
  736. #endif
  737. // -----------------------------------------------------------------------------
  738. // I2C
  739. // -----------------------------------------------------------------------------
  740. #ifndef I2C_SUPPORT
  741. #define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
  742. #endif
  743. #define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
  744. #ifndef I2C_SDA_PIN
  745. #define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4)
  746. #endif
  747. #ifndef I2C_SCL_PIN
  748. #define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14)
  749. #endif
  750. #define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
  751. #define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
  752. #define I2C_CLEAR_BUS 0 // Clear I2C bus on boot
  753. #define I2C_PERFORM_SCAN 1 // Perform a bus scan on boot
  754. //--------------------------------------------------------------------------------
  755. // Class loading
  756. //--------------------------------------------------------------------------------
  757. #if SENSOR_SUPPORT
  758. #if AM2320_SUPPORT
  759. #include "../sensors/AM2320Sensor.h"
  760. #endif
  761. #if ANALOG_SUPPORT
  762. #include "../sensors/AnalogSensor.h"
  763. #endif
  764. #if BH1750_SUPPORT
  765. #include "../sensors/BH1750Sensor.h"
  766. #endif
  767. #if BMP180_SUPPORT
  768. #include "../sensors/BMP180Sensor.h"
  769. #endif
  770. #if BMX280_SUPPORT
  771. #include "../sensors/BMX280Sensor.h"
  772. #endif
  773. #if CSE7766_SUPPORT
  774. #include "../sensors/CSE7766Sensor.h"
  775. #endif
  776. #if DALLAS_SUPPORT
  777. #include "../sensors/DallasSensor.h"
  778. #endif
  779. #if DHT_SUPPORT
  780. #include "../sensors/DHTSensor.h"
  781. #endif
  782. #if DIGITAL_SUPPORT
  783. #include "../sensors/DigitalSensor.h"
  784. #endif
  785. #if ECH1560_SUPPORT
  786. #include "../sensors/ECH1560Sensor.h"
  787. #endif
  788. #if EMON_ADC121_SUPPORT
  789. #include "../sensors/EmonADC121Sensor.h"
  790. #endif
  791. #if EMON_ADS1X15_SUPPORT
  792. #include "../sensors/EmonADS1X15Sensor.h"
  793. #endif
  794. #if EMON_ANALOG_SUPPORT
  795. #include "../sensors/EmonAnalogSensor.h"
  796. #endif
  797. #if EVENTS_SUPPORT
  798. #include "../sensors/EventSensor.h"
  799. #endif
  800. #if EZOPH_SUPPORT
  801. #include "../sensors/EZOPHSensor.h"
  802. #endif
  803. #if GEIGER_SUPPORT
  804. #include "../sensors/GeigerSensor.h"
  805. #endif
  806. #if GUVAS12SD_SUPPORT
  807. #include "../sensors/GUVAS12SDSensor.h"
  808. #endif
  809. #if HLW8012_SUPPORT
  810. #include "../sensors/HLW8012Sensor.h"
  811. #endif
  812. #if MAX6675_SUPPORT
  813. #include "../sensors/MAX6675Sensor.h"
  814. #endif
  815. #if MHZ19_SUPPORT
  816. #include "../sensors/MHZ19Sensor.h"
  817. #endif
  818. #if MICS2710_SUPPORT
  819. #include "../sensors/MICS2710Sensor.h"
  820. #endif
  821. #if MICS5525_SUPPORT
  822. #include "../sensors/MICS5525Sensor.h"
  823. #endif
  824. #if NTC_SUPPORT
  825. #include "../sensors/NTCSensor.h"
  826. #endif
  827. #if SDS011_SUPPORT
  828. #include "../sensors/SDS011Sensor.h"
  829. #endif
  830. #if SENSEAIR_SUPPORT
  831. #include "../sensors/SenseAirSensor.h"
  832. #endif
  833. #if PMSX003_SUPPORT
  834. #include "../sensors/PMSX003Sensor.h"
  835. #endif
  836. #if PULSEMETER_SUPPORT
  837. #include "../sensors/PulseMeterSensor.h"
  838. #endif
  839. #if PZEM004T_SUPPORT
  840. #include "../sensors/PZEM004TSensor.h"
  841. #endif
  842. #if SI7021_SUPPORT
  843. #include "../sensors/SI7021Sensor.h"
  844. #endif
  845. #if SHT3X_I2C_SUPPORT
  846. #include "../sensors/SHT3XI2CSensor.h"
  847. #endif
  848. #if SONAR_SUPPORT
  849. #include "../sensors/SonarSensor.h"
  850. #endif
  851. #if TMP3X_SUPPORT
  852. #include "../sensors/TMP3XSensor.h"
  853. #endif
  854. #if V9261F_SUPPORT
  855. #include "../sensors/V9261FSensor.h"
  856. #endif
  857. #if VEML6075_SUPPORT
  858. #include "../sensors/VEML6075Sensor.h"
  859. #endif
  860. #if VL53L1X_SUPPORT
  861. #include "../sensors/VL53L1XSensor.h"
  862. #endif
  863. #endif // SENSOR_SUPPORT