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.

1433 lines
48 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 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
  1. // =============================================================================
  2. // SENSORS - General configuration
  3. // =============================================================================
  4. #pragma once
  5. #ifndef SENSOR_DEBUG
  6. #define SENSOR_DEBUG 0 // Debug sensors
  7. #endif
  8. #ifndef SENSOR_READ_INTERVAL
  9. #define SENSOR_READ_INTERVAL 6 // Read data from sensors every 6 seconds
  10. #endif
  11. #ifndef SENSOR_READ_MIN_INTERVAL
  12. #define SENSOR_READ_MIN_INTERVAL 1 // Minimum read interval
  13. #endif
  14. #ifndef SENSOR_READ_MAX_INTERVAL
  15. #define SENSOR_READ_MAX_INTERVAL 3600 // Maximum read interval
  16. #endif
  17. #ifndef SENSOR_INIT_INTERVAL
  18. #define SENSOR_INIT_INTERVAL 10000 // Try to re-init non-ready sensors every 10s
  19. #endif
  20. #ifndef SENSOR_REPORT_EVERY
  21. #define SENSOR_REPORT_EVERY 10 // Report every this many readings
  22. #endif
  23. #ifndef SENSOR_REPORT_MIN_EVERY
  24. #define SENSOR_REPORT_MIN_EVERY 1 // Minimum every value
  25. #endif
  26. #ifndef SENSOR_REPORT_MAX_EVERY
  27. #define SENSOR_REPORT_MAX_EVERY 60 // Maximum
  28. #endif
  29. #ifndef SENSOR_USE_INDEX
  30. #define SENSOR_USE_INDEX 0 // Use the index in topic (i.e. temperature/0)
  31. #endif
  32. // even if just one sensor (0 for backwards compatibility)
  33. #ifndef SENSOR_POWER_CHECK_STATUS
  34. #define SENSOR_POWER_CHECK_STATUS 1 // If set to 1 the reported power/current/energy will be 0 if the relay[0] is OFF
  35. #endif
  36. #ifndef TEMPERATURE_MIN_CHANGE
  37. #define TEMPERATURE_MIN_CHANGE 0.0 // Minimum temperature change to report
  38. #endif
  39. #ifndef HUMIDITY_MIN_CHANGE
  40. #define HUMIDITY_MIN_CHANGE 0.0 // Minimum humidity change to report
  41. #endif
  42. #ifndef ENERGY_MAX_CHANGE
  43. #define ENERGY_MAX_CHANGE 0.0 // Maximum energy change to report (if >0 it will allways report when delta(E) is greater than this)
  44. #endif
  45. #ifndef SENSOR_SAVE_EVERY
  46. #define SENSOR_SAVE_EVERY 0 // Save accumulating values to EEPROM (atm only energy)
  47. // A 0 means do not save and it's the default value
  48. // A number different from 0 means it should store the value in EEPROM
  49. // after these many reports
  50. // Warning: this might wear out flash fast!
  51. #endif
  52. #define SENSOR_PUBLISH_ADDRESSES 0 // Publish sensor addresses
  53. #define SENSOR_ADDRESS_TOPIC "address" // Topic to publish sensor addresses
  54. #ifndef SENSOR_TEMPERATURE_UNITS
  55. #define SENSOR_TEMPERATURE_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  56. #endif
  57. #ifndef SENSOR_ENERGY_UNITS
  58. #define SENSOR_ENERGY_UNITS ENERGY_JOULES // Energy units (ENERGY_JOULES | ENERGY_KWH)
  59. #endif
  60. #ifndef SENSOR_POWER_UNITS
  61. #define SENSOR_POWER_UNITS POWER_WATTS // Power units (POWER_WATTS | POWER_KILOWATTS)
  62. #endif
  63. // -----------------------------------------------------------------------------
  64. // Magnitude offset correction
  65. // -----------------------------------------------------------------------------
  66. #ifndef SENSOR_TEMPERATURE_CORRECTION
  67. #define SENSOR_TEMPERATURE_CORRECTION 0.0
  68. #endif
  69. #ifndef SENSOR_HUMIDITY_CORRECTION
  70. #define SENSOR_HUMIDITY_CORRECTION 0.0
  71. #endif
  72. #ifndef SENSOR_PRESSURE_CORRECTION
  73. #define SENSOR_PRESSURE_CORRECTION 0.0
  74. #endif
  75. #ifndef SENSOR_LUX_CORRECTION
  76. #define SENSOR_LUX_CORRECTION 0.0
  77. #endif
  78. // =============================================================================
  79. // Specific data for each sensor
  80. // =============================================================================
  81. //------------------------------------------------------------------------------
  82. // AM2320 Humidity & Temperature sensor over I2C
  83. // Enable support by passing AM2320_SUPPORT=1 build flag
  84. //------------------------------------------------------------------------------
  85. #ifndef AM2320_SUPPORT
  86. #define AM2320_SUPPORT 0
  87. #endif
  88. #ifndef AM2320_ADDRESS
  89. #define AM2320_ADDRESS 0x00 // 0x00 means auto
  90. #endif
  91. //------------------------------------------------------------------------------
  92. // Analog sensor
  93. // Enable support by passing ANALOG_SUPPORT=1 build flag
  94. //--------------------------------------------------------------------------------
  95. #ifndef ANALOG_SUPPORT
  96. #define ANALOG_SUPPORT 0
  97. #endif
  98. #ifndef ANALOG_SAMPLES
  99. #define ANALOG_SAMPLES 10 // Number of samples
  100. #endif
  101. #ifndef ANALOG_DELAY
  102. #define ANALOG_DELAY 0 // Delay between samples in micros
  103. #endif
  104. //Use the following to perform scaling of raw analog values
  105. // scaledRead = ( factor * rawRead ) + offset
  106. //
  107. //Please take note that the offset is not affected by the scaling factor
  108. #ifndef ANALOG_FACTOR
  109. #define ANALOG_FACTOR 1.0 // Multiply raw reading by this factor
  110. #endif
  111. #ifndef ANALOG_OFFSET
  112. #define ANALOG_OFFSET 0.0 // Add this offset to *scaled* value
  113. #endif
  114. // Round to this number of decimals
  115. #ifndef ANALOG_DECIMALS
  116. #define ANALOG_DECIMALS 2
  117. #endif
  118. //------------------------------------------------------------------------------
  119. // BH1750
  120. // Enable support by passing BH1750_SUPPORT=1 build flag
  121. // http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf
  122. //------------------------------------------------------------------------------
  123. #ifndef BH1750_SUPPORT
  124. #define BH1750_SUPPORT 0
  125. #endif
  126. #ifndef BH1750_ADDRESS
  127. #define BH1750_ADDRESS 0x00 // 0x00 means auto
  128. #endif
  129. #define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE
  130. //------------------------------------------------------------------------------
  131. // BMP085/BMP180
  132. // Enable support by passing BMP180_SUPPORT=1 build flag
  133. //------------------------------------------------------------------------------
  134. #ifndef BMP180_SUPPORT
  135. #define BMP180_SUPPORT 0
  136. #endif
  137. #ifndef BMP180_ADDRESS
  138. #define BMP180_ADDRESS 0x00 // 0x00 means auto
  139. #endif
  140. #define BMP180_MODE 3 // 0 for ultra-low power, 1 for standard, 2 for high resolution and 3 for ultrahigh resolution
  141. //------------------------------------------------------------------------------
  142. // BME280/BMP280
  143. // Enable support by passing BMX280_SUPPORT=1 build flag
  144. //------------------------------------------------------------------------------
  145. #ifndef BMX280_SUPPORT
  146. #define BMX280_SUPPORT 0
  147. #endif
  148. #ifndef BMX280_NUMBER
  149. #define BMX280_NUMBER 1 // Number of sensors present. Either 1 or 2 allowed
  150. #endif
  151. #ifndef BMX280_ADDRESS
  152. #define BMX280_ADDRESS 0x00 // 0x00 means auto (0x76 or 0x77 allowed) for sensor #0
  153. #endif // If (BMX280_NUMBER == 2) and
  154. // (BMX280_ADDRESS == 0x00) then sensor #1 is auto-discovered
  155. // (BMX280_ADDRESS != 0x00) then sensor #1 is the unnamed address
  156. #ifndef BMX280_MODE
  157. #define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode
  158. #endif
  159. #ifndef BMX280_STANDBY
  160. #define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms
  161. // 3 for 250ms, 4 for 500ms, 5 for 1000ms
  162. // 6 for 10ms, 7 for 20ms
  163. #endif
  164. #ifndef BMX280_FILTER
  165. #define BMX280_FILTER 0 // 0 for OFF, 1 for 2 values, 2 for 4 values, 3 for 8 values and 4 for 16 values
  166. #endif
  167. #ifndef BMX280_TEMPERATURE
  168. #define BMX280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  169. // 0b000 = 0 = Skip measurement
  170. // 0b001 = 1 = 1x 16bit/0.0050C resolution
  171. // 0b010 = 2 = 2x 17bit/0.0025C
  172. // 0b011 = 3 = 4x 18bit/0.0012C
  173. // 0b100 = 4 = 8x 19bit/0.0006C
  174. // 0b101 = 5 = 16x 20bit/0.0003C
  175. #endif
  176. #ifndef BMX280_HUMIDITY
  177. #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
  178. // 0b000 = 0 = Skip measurement
  179. // 0b001 = 1 = 1x 0.07% resolution
  180. // 0b010 = 2 = 2x 0.05%
  181. // 0b011 = 3 = 4x 0.04%
  182. // 0b100 = 4 = 8x 0.03%
  183. // 0b101 = 5 = 16x 0.02%
  184. #endif
  185. #ifndef BMX280_PRESSURE
  186. #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  187. // 0b000 = 0 = Skipped
  188. // 0b001 = 1 = 1x 16bit/2.62 Pa resolution
  189. // 0b010 = 2 = 2x 17bit/1.31 Pa
  190. // 0b011 = 3 = 4x 18bit/0.66 Pa
  191. // 0b100 = 4 = 8x 19bit/0.33 Pa
  192. // 0b101 = 5 = 16x 20bit/0.16 Pa
  193. #endif
  194. //------------------------------------------------------------------------------
  195. // Dallas OneWire temperature sensors
  196. // Enable support by passing DALLAS_SUPPORT=1 build flag
  197. //------------------------------------------------------------------------------
  198. #ifndef DALLAS_SUPPORT
  199. #define DALLAS_SUPPORT 0
  200. #endif
  201. #ifndef DALLAS_PIN
  202. #define DALLAS_PIN 14
  203. #endif
  204. #define DALLAS_RESOLUTION 9 // Not used atm
  205. #define DALLAS_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds
  206. //------------------------------------------------------------------------------
  207. // DHTXX temperature/humidity sensor
  208. // Enable support by passing DHT_SUPPORT=1 build flag
  209. //------------------------------------------------------------------------------
  210. #ifndef DHT_SUPPORT
  211. #define DHT_SUPPORT 0
  212. #endif
  213. #ifndef DHT_PIN
  214. #define DHT_PIN 14
  215. #endif
  216. #ifndef DHT_TYPE
  217. #define DHT_TYPE DHT_CHIP_DHT22
  218. #endif
  219. //------------------------------------------------------------------------------
  220. // CSE7766 based power sensor
  221. // Enable support by passing CSE7766_SUPPORT=1 build flag
  222. //------------------------------------------------------------------------------
  223. #ifndef CSE7766_SUPPORT
  224. #define CSE7766_SUPPORT 0
  225. #endif
  226. #ifndef CSE7766_RX_PIN
  227. #define CSE7766_RX_PIN 3 // RX pin connected to the CSE7766
  228. // As we never transmit anything, this is the only pin used
  229. #endif
  230. #ifndef CSE7766_PIN_INVERSE
  231. #define CSE7766_PIN_INVERSE 0 // Signal is inverted
  232. #endif
  233. #define CSE7766_SYNC_INTERVAL 300 // Safe time between transmissions (ms)
  234. #define CSE7766_BAUDRATE 4800 // UART baudrate
  235. #define CSE7766_V1R 1.0 // 1mR current resistor
  236. #define CSE7766_V2R 1.0 // 1M voltage resistor
  237. //------------------------------------------------------------------------------
  238. // Digital sensor
  239. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  240. //------------------------------------------------------------------------------
  241. #ifndef DIGITAL_SUPPORT
  242. #define DIGITAL_SUPPORT 0
  243. #endif
  244. #ifndef DIGITAL1_PIN
  245. #define DIGITAL1_PIN 2
  246. #endif
  247. #ifndef DIGITAL1_PIN_MODE
  248. #define DIGITAL1_PIN_MODE INPUT_PULLUP
  249. #endif
  250. #ifndef DIGITAL1_DEFAULT_STATE
  251. #define DIGITAL1_DEFAULT_STATE 1
  252. #endif
  253. #ifndef DIGITAL2_PIN
  254. #define DIGITAL2_PIN 2
  255. #endif
  256. #ifndef DIGITAL2_PIN_MODE
  257. #define DIGITAL2_PIN_MODE INPUT_PULLUP
  258. #endif
  259. #ifndef DIGITAL2_DEFAULT_STATE
  260. #define DIGITAL2_DEFAULT_STATE 1
  261. #endif
  262. #ifndef DIGITAL3_PIN
  263. #define DIGITAL3_PIN 2
  264. #endif
  265. #ifndef DIGITAL3_PIN_MODE
  266. #define DIGITAL3_PIN_MODE INPUT_PULLUP
  267. #endif
  268. #ifndef DIGITAL3_DEFAULT_STATE
  269. #define DIGITAL3_DEFAULT_STATE 1
  270. #endif
  271. #ifndef DIGITAL4_PIN
  272. #define DIGITAL4_PIN 2
  273. #endif
  274. #ifndef DIGITAL4_PIN_MODE
  275. #define DIGITAL4_PIN_MODE INPUT_PULLUP
  276. #endif
  277. #ifndef DIGITAL4_DEFAULT_STATE
  278. #define DIGITAL4_DEFAULT_STATE 1
  279. #endif
  280. #ifndef DIGITAL5_PIN
  281. #define DIGITAL5_PIN 2
  282. #endif
  283. #ifndef DIGITAL5_PIN_MODE
  284. #define DIGITAL5_PIN_MODE INPUT_PULLUP
  285. #endif
  286. #ifndef DIGITAL5_DEFAULT_STATE
  287. #define DIGITAL5_DEFAULT_STATE 1
  288. #endif
  289. #ifndef DIGITAL6_PIN
  290. #define DIGITAL6_PIN 2
  291. #endif
  292. #ifndef DIGITAL6_PIN_MODE
  293. #define DIGITAL6_PIN_MODE INPUT_PULLUP
  294. #endif
  295. #ifndef DIGITAL6_DEFAULT_STATE
  296. #define DIGITAL6_DEFAULT_STATE 1
  297. #endif
  298. #ifndef DIGITAL7_PIN
  299. #define DIGITAL7_PIN 2
  300. #endif
  301. #ifndef DIGITAL7_PIN_MODE
  302. #define DIGITAL7_PIN_MODE INPUT_PULLUP
  303. #endif
  304. #ifndef DIGITAL7_DEFAULT_STATE
  305. #define DIGITAL7_DEFAULT_STATE 1
  306. #endif
  307. #ifndef DIGITAL8_PIN
  308. #define DIGITAL8_PIN 2
  309. #endif
  310. #ifndef DIGITAL8_PIN_MODE
  311. #define DIGITAL8_PIN_MODE INPUT_PULLUP
  312. #endif
  313. #ifndef DIGITAL8_DEFAULT_STATE
  314. #define DIGITAL8_DEFAULT_STATE 1
  315. #endif
  316. //------------------------------------------------------------------------------
  317. // ECH1560 based power sensor
  318. // Enable support by passing ECH1560_SUPPORT=1 build flag
  319. //------------------------------------------------------------------------------
  320. #ifndef ECH1560_SUPPORT
  321. #define ECH1560_SUPPORT 0
  322. #endif
  323. #ifndef ECH1560_CLK_PIN
  324. #define ECH1560_CLK_PIN 4 // CLK pin for the ECH1560
  325. #endif
  326. #ifndef ECH1560_MISO_PIN
  327. #define ECH1560_MISO_PIN 5 // MISO pin for the ECH1560
  328. #endif
  329. #ifndef ECH1560_INVERTED
  330. #define ECH1560_INVERTED 0 // Signal is inverted
  331. #endif
  332. //------------------------------------------------------------------------------
  333. // Energy Monitor general settings
  334. //------------------------------------------------------------------------------
  335. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  336. #define EMON_MAX_TIME 250 // Max time in ms to sample
  337. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  338. #define EMON_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  339. #ifndef EMON_MAINS_VOLTAGE
  340. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  341. #endif
  342. #ifndef EMON_CURRENT_RATIO
  343. #define EMON_CURRENT_RATIO 30.0 // Current ratio in the clamp (30A/1V)
  344. #endif
  345. #ifndef EMON_REPORT_CURRENT
  346. #define EMON_REPORT_CURRENT 0 // Report current
  347. #endif
  348. #ifndef EMON_REPORT_POWER
  349. #define EMON_REPORT_POWER 1 // Report power
  350. #endif
  351. #ifndef EMON_REPORT_ENERGY
  352. #define EMON_REPORT_ENERGY 1 // Report energy
  353. #endif
  354. //------------------------------------------------------------------------------
  355. // Energy Monitor based on ADC121
  356. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  357. //------------------------------------------------------------------------------
  358. #ifndef EMON_ADC121_SUPPORT
  359. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  360. #endif
  361. #ifndef EMON_ADC121_I2C_ADDRESS
  362. #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
  363. #endif
  364. //------------------------------------------------------------------------------
  365. // Energy Monitor based on ADS1X15
  366. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  367. //------------------------------------------------------------------------------
  368. #ifndef EMON_ADS1X15_SUPPORT
  369. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  370. #endif
  371. #ifndef EMON_ADS1X15_I2C_ADDRESS
  372. #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
  373. #endif
  374. #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
  375. #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
  376. #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
  377. //------------------------------------------------------------------------------
  378. // Energy Monitor based on interval analog GPIO
  379. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  380. //------------------------------------------------------------------------------
  381. #ifndef EMON_ANALOG_SUPPORT
  382. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  383. #endif
  384. //------------------------------------------------------------------------------
  385. // Counter sensor
  386. // Enable support by passing EVENTS_SUPPORT=1 build flag
  387. //------------------------------------------------------------------------------
  388. #ifndef EVENTS_SUPPORT
  389. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  390. #endif
  391. #ifndef EVENTS1_TRIGGER
  392. #define EVENTS1_TRIGGER 1 // 1 to trigger callback on events,
  393. // 0 to only count them and report periodically
  394. #endif
  395. #ifndef EVENTS1_PIN
  396. #define EVENTS1_PIN 2 // GPIO to monitor
  397. #endif
  398. #ifndef EVENTS1_PIN_MODE
  399. #define EVENTS1_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  400. #endif
  401. #ifndef EVENTS1_INTERRUPT_MODE
  402. #define EVENTS1_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  403. #endif
  404. #ifndef EVENTS1_DEBOUNCE
  405. #define EVENTS1_DEBOUNCE 50 // Do not register events within less than 50 millis
  406. #endif
  407. #ifndef EVENTS2_TRIGGER
  408. #define EVENTS2_TRIGGER 1 // 1 to trigger callback on events,
  409. // 0 to only count them and report periodically
  410. #endif
  411. #ifndef EVENTS2_PIN
  412. #define EVENTS2_PIN 2 // GPIO to monitor
  413. #endif
  414. #ifndef EVENTS2_PIN_MODE
  415. #define EVENTS2_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  416. #endif
  417. #ifndef EVENTS2_INTERRUPT_MODE
  418. #define EVENTS2_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  419. #endif
  420. #ifndef EVENTS2_DEBOUNCE
  421. #define EVENTS2_DEBOUNCE 50 // Do not register events within less than 50 millis
  422. #endif
  423. #ifndef EVENTS3_TRIGGER
  424. #define EVENTS3_TRIGGER 1 // 1 to trigger callback on events,
  425. // 0 to only count them and report periodically
  426. #endif
  427. #ifndef EVENTS3_PIN
  428. #define EVENTS3_PIN 2 // GPIO to monitor
  429. #endif
  430. #ifndef EVENTS3_PIN_MODE
  431. #define EVENTS3_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  432. #endif
  433. #ifndef EVENTS3_INTERRUPT_MODE
  434. #define EVENTS3_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  435. #endif
  436. #ifndef EVENTS3_DEBOUNCE
  437. #define EVENTS3_DEBOUNCE 50 // Do not register events within less than 50 millis
  438. #endif
  439. #ifndef EVENTS4_TRIGGER
  440. #define EVENTS4_TRIGGER 1 // 1 to trigger callback on events,
  441. // 0 to only count them and report periodically
  442. #endif
  443. #ifndef EVENTS4_PIN
  444. #define EVENTS4_PIN 2 // GPIO to monitor
  445. #endif
  446. #ifndef EVENTS4_PIN_MODE
  447. #define EVENTS4_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  448. #endif
  449. #ifndef EVENTS4_INTERRUPT_MODE
  450. #define EVENTS4_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  451. #endif
  452. #ifndef EVENTS4_DEBOUNCE
  453. #define EVENTS4_DEBOUNCE 50 // Do not register events within less than 50 millis
  454. #endif
  455. #ifndef EVENTS5_TRIGGER
  456. #define EVENTS5_TRIGGER 1 // 1 to trigger callback on events,
  457. // 0 to only count them and report periodically
  458. #endif
  459. #ifndef EVENTS5_PIN
  460. #define EVENTS5_PIN 2 // GPIO to monitor
  461. #endif
  462. #ifndef EVENTS5_PIN_MODE
  463. #define EVENTS5_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  464. #endif
  465. #ifndef EVENTS5_INTERRUPT_MODE
  466. #define EVENTS5_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  467. #endif
  468. #ifndef EVENTS5_DEBOUNCE
  469. #define EVENTS5_DEBOUNCE 50 // Do not register events within less than 50 millis
  470. #endif
  471. #ifndef EVENTS6_TRIGGER
  472. #define EVENTS6_TRIGGER 1 // 1 to trigger callback on events,
  473. // 0 to only count them and report periodically
  474. #endif
  475. #ifndef EVENTS6_PIN
  476. #define EVENTS6_PIN 2 // GPIO to monitor
  477. #endif
  478. #ifndef EVENTS6_PIN_MODE
  479. #define EVENTS6_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  480. #endif
  481. #ifndef EVENTS6_INTERRUPT_MODE
  482. #define EVENTS6_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  483. #endif
  484. #ifndef EVENTS6_DEBOUNCE
  485. #define EVENTS6_DEBOUNCE 50 // Do not register events within less than 50 millis
  486. #endif
  487. #ifndef EVENTS7_TRIGGER
  488. #define EVENTS7_TRIGGER 1 // 1 to trigger callback on events,
  489. // 0 to only count them and report periodically
  490. #endif
  491. #ifndef EVENTS7_PIN
  492. #define EVENTS7_PIN 2 // GPIO to monitor
  493. #endif
  494. #ifndef EVENTS7_PIN_MODE
  495. #define EVENTS7_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  496. #endif
  497. #ifndef EVENTS7_INTERRUPT_MODE
  498. #define EVENTS7_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  499. #endif
  500. #ifndef EVENTS7_DEBOUNCE
  501. #define EVENTS7_DEBOUNCE 50 // Do not register events within less than 50 millis
  502. #endif
  503. #ifndef EVENTS8_TRIGGER
  504. #define EVENTS8_TRIGGER 1 // 1 to trigger callback on events,
  505. // 0 to only count them and report periodically
  506. #endif
  507. #ifndef EVENTS8_PIN
  508. #define EVENTS8_PIN 2 // GPIO to monitor
  509. #endif
  510. #ifndef EVENTS8_PIN_MODE
  511. #define EVENTS8_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  512. #endif
  513. #ifndef EVENTS8_INTERRUPT_MODE
  514. #define EVENTS8_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  515. #endif
  516. #ifndef EVENTS8_DEBOUNCE
  517. #define EVENTS8_DEBOUNCE 50 // Do not register events within less than 50 millis
  518. #endif
  519. //------------------------------------------------------------------------------
  520. // Geiger sensor
  521. // Enable support by passing GEIGER_SUPPORT=1 build flag
  522. //------------------------------------------------------------------------------
  523. #ifndef GEIGER_SUPPORT
  524. #define GEIGER_SUPPORT 0 // Do not build with geiger support by default
  525. #endif
  526. #ifndef GEIGER_PIN
  527. #define GEIGER_PIN D1 // GPIO to monitor "D1" => "GPIO5"
  528. #endif
  529. #ifndef GEIGER_PIN_MODE
  530. #define GEIGER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  531. #endif
  532. #ifndef GEIGER_INTERRUPT_MODE
  533. #define GEIGER_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  534. #endif
  535. #define GEIGER_DEBOUNCE 25 // Do not register events within less than 25 millis.
  536. // Value derived here: Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter
  537. #define GEIGER_CPM2SIEVERT 240 // CPM to µSievert per hour conversion factor
  538. // Typically the literature uses the invers, but I find an integer type more convienient.
  539. #define GEIGER_REPORT_SIEVERTS 1 // Enabler for local dose rate reports in µSv/h
  540. #define GEIGER_REPORT_CPM 1 // Enabler for local dose rate reports in counts per minute
  541. //------------------------------------------------------------------------------
  542. // GUVAS12SD UV Sensor (analog)
  543. // Enable support by passing GUVAS12SD_SUPPORT=1 build flag
  544. //------------------------------------------------------------------------------
  545. #ifndef GUVAS12SD_SUPPORT
  546. #define GUVAS12SD_SUPPORT 0
  547. #endif
  548. #ifndef GUVAS12SD_PIN
  549. #define GUVAS12SD_PIN 14
  550. #endif
  551. //------------------------------------------------------------------------------
  552. // HLW8012 Energy monitor IC
  553. // Enable support by passing HLW8012_SUPPORT=1 build flag
  554. //------------------------------------------------------------------------------
  555. #ifndef HLW8012_SUPPORT
  556. #define HLW8012_SUPPORT 0
  557. #endif
  558. #ifndef HLW8012_SEL_PIN
  559. #define HLW8012_SEL_PIN 5
  560. #endif
  561. #ifndef HLW8012_CF1_PIN
  562. #define HLW8012_CF1_PIN 13
  563. #endif
  564. #ifndef HLW8012_CF_PIN
  565. #define HLW8012_CF_PIN 14
  566. #endif
  567. #ifndef HLW8012_SEL_CURRENT
  568. #define HLW8012_SEL_CURRENT HIGH // SEL pin to HIGH to measure current
  569. #endif
  570. #ifndef HLW8012_CURRENT_R
  571. #define HLW8012_CURRENT_R 0.001 // Current resistor
  572. #endif
  573. #ifndef HLW8012_VOLTAGE_R_UP
  574. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Upstream voltage resistor
  575. #endif
  576. #ifndef HLW8012_VOLTAGE_R_DOWN
  577. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Downstream voltage resistor
  578. #endif
  579. #ifndef HLW8012_CURRENT_RATIO
  580. #define HLW8012_CURRENT_RATIO 0.0 // Set to 0.0 to use factory defaults
  581. #endif
  582. #ifndef HLW8012_VOLTAGE_RATIO
  583. #define HLW8012_VOLTAGE_RATIO 0.0 // Set to 0.0 to use factory defaults
  584. #endif
  585. #ifndef HLW8012_POWER_RATIO
  586. #define HLW8012_POWER_RATIO 0.0 // Set to 0.0 to use factory defaults
  587. #endif
  588. #ifndef HLW8012_USE_INTERRUPTS
  589. #define HLW8012_USE_INTERRUPTS 1 // Use interrupts to trap HLW8012 signals
  590. #endif
  591. #ifndef HLW8012_WAIT_FOR_WIFI
  592. #define HLW8012_WAIT_FOR_WIFI 0 // Weather to enable interrupts only after
  593. // wifi connection has been stablished
  594. #endif
  595. #ifndef HLW8012_INTERRUPT_ON
  596. #define HLW8012_INTERRUPT_ON CHANGE // When to trigger the interrupt
  597. // Use CHANGE for HLW8012
  598. // Use FALLING for BL0937 / HJL0
  599. #endif
  600. //------------------------------------------------------------------------------
  601. // LDR sensor
  602. // Enable support by passing LDR_SUPPORT=1 build flag
  603. //------------------------------------------------------------------------------
  604. #ifndef LDR_SUPPORT
  605. #define LDR_SUPPORT 0
  606. #endif
  607. #ifndef LDR_SAMPLES
  608. #define LDR_SAMPLES 10 // Number of samples
  609. #endif
  610. #ifndef LDR_DELAY
  611. #define LDR_DELAY 0 // Delay between samples in micros
  612. #endif
  613. #ifndef LDR_TYPE
  614. #define LDR_TYPE LDR_GL5528
  615. #endif
  616. #ifndef LDR_ON_GROUND
  617. #define LDR_ON_GROUND true
  618. #endif
  619. #ifndef LDR_RESISTOR
  620. #define LDR_RESISTOR 10000 // Resistance
  621. #endif
  622. #ifndef LDR_MULTIPLICATION
  623. #define LDR_MULTIPLICATION 32017200
  624. #endif
  625. #ifndef LDR_POWER
  626. #define LDR_POWER 1.5832
  627. #endif
  628. //------------------------------------------------------------------------------
  629. // MHZ19 CO2 sensor
  630. // Enable support by passing MHZ19_SUPPORT=1 build flag
  631. //------------------------------------------------------------------------------
  632. #ifndef MHZ19_SUPPORT
  633. #define MHZ19_SUPPORT 0
  634. #endif
  635. #ifndef MHZ19_RX_PIN
  636. #define MHZ19_RX_PIN 13
  637. #endif
  638. #ifndef MHZ19_TX_PIN
  639. #define MHZ19_TX_PIN 15
  640. #endif
  641. //------------------------------------------------------------------------------
  642. // MICS-2710 (and MICS-4514) NO2 sensor
  643. // Enable support by passing MICS2710_SUPPORT=1 build flag
  644. //------------------------------------------------------------------------------
  645. #ifndef MICS2710_SUPPORT
  646. #define MICS2710_SUPPORT 0
  647. #endif
  648. #ifndef MICS2710_NOX_PIN
  649. #define MICS2710_NOX_PIN 0
  650. #endif
  651. #ifndef MICS2710_PRE_PIN
  652. #define MICS2710_PRE_PIN 4
  653. #endif
  654. #define MICS2710_PREHEAT_TIME 10000 // 10s preheat for NOX read
  655. #define MICS2710_RL 820 // RL, load resistor
  656. #define MICS2710_R0 2200 // R0 calibration value for NO2 sensor,
  657. // Typical value as per datasheet
  658. //------------------------------------------------------------------------------
  659. // MICS-5525 (and MICS-4514) CO sensor
  660. // Enable support by passing MICS5525_SUPPORT=1 build flag
  661. //------------------------------------------------------------------------------
  662. #ifndef MICS5525_SUPPORT
  663. #define MICS5525_SUPPORT 0
  664. #endif
  665. #ifndef MICS5525_RED_PIN
  666. #define MICS5525_RED_PIN 0
  667. #endif
  668. #define MICS5525_RL 820 // RL, load resistor
  669. #define MICS5525_R0 750000 // R0 calibration value for NO2 sensor,
  670. // Typical value as per datasheet
  671. //------------------------------------------------------------------------------
  672. // NTC sensor
  673. // Enable support by passing NTC_SUPPORT=1 build flag
  674. //--------------------------------------------------------------------------------
  675. #ifndef NTC_SUPPORT
  676. #define NTC_SUPPORT 0
  677. #endif
  678. #ifndef NTC_SAMPLES
  679. #define NTC_SAMPLES 10 // Number of samples
  680. #endif
  681. #ifndef NTC_DELAY
  682. #define NTC_DELAY 0 // Delay between samples in micros
  683. #endif
  684. #ifndef NTC_R_UP
  685. #define NTC_R_UP 0 // Resistor upstream, set to 0 if none
  686. #endif
  687. #ifndef NTC_R_DOWN
  688. #define NTC_R_DOWN 10000 // Resistor downstream, set to 0 if none
  689. #endif
  690. #ifndef NTC_T0
  691. #define NTC_T0 298.15 // 25 Celsius
  692. #endif
  693. #ifndef NTC_R0
  694. #define NTC_R0 10000 // Resistance at T0
  695. #endif
  696. #ifndef NTC_BETA
  697. #define NTC_BETA 3977 // Beta coeficient
  698. #endif
  699. //------------------------------------------------------------------------------
  700. // Particle Monitor based on Plantower PMS
  701. // Enable support by passing PMSX003_SUPPORT=1 build flag
  702. //------------------------------------------------------------------------------
  703. #ifndef PMSX003_SUPPORT
  704. #define PMSX003_SUPPORT 0
  705. #endif
  706. #ifndef PMS_TYPE
  707. #define PMS_TYPE PMS_TYPE_X003
  708. #endif
  709. // You can enable smart sleep (read 6-times then sleep on 24-reading-cycles) to extend PMS sensor's life.
  710. // Otherwise the default lifetime of PMS sensor is about 8000-hours/1-years.
  711. // The PMS's fan will stop working on sleeping cycle, and will wake up on reading cycle.
  712. #ifndef PMS_SMART_SLEEP
  713. #define PMS_SMART_SLEEP 0
  714. #endif
  715. #ifndef PMS_USE_SOFT
  716. #define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0
  717. #endif
  718. #ifndef PMS_RX_PIN
  719. #define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1)
  720. #endif
  721. #ifndef PMS_TX_PIN
  722. #define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1)
  723. #endif
  724. #ifndef PMS_HW_PORT
  725. #define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0)
  726. #endif
  727. //------------------------------------------------------------------------------
  728. // Pulse Meter Energy monitor
  729. // Enable support by passing PULSEMETER_SUPPORT=1 build flag
  730. //------------------------------------------------------------------------------
  731. #ifndef PULSEMETER_SUPPORT
  732. #define PULSEMETER_SUPPORT 0
  733. #endif
  734. #ifndef PULSEMETER_PIN
  735. #define PULSEMETER_PIN 5
  736. #endif
  737. #ifndef PULSEMETER_ENERGY_RATIO
  738. #define PULSEMETER_ENERGY_RATIO 4000 // In pulses/kWh
  739. #endif
  740. #ifndef PULSEMETER_INTERRUPT_ON
  741. #define PULSEMETER_INTERRUPT_ON FALLING
  742. #endif
  743. #ifndef PULSEMETER_DEBOUNCE
  744. #define PULSEMETER_DEBOUNCE 50 // Do not register pulses within less than 50 millis
  745. #endif
  746. //------------------------------------------------------------------------------
  747. // PZEM004T based power monitor
  748. // Enable support by passing PZEM004T_SUPPORT=1 build flag
  749. //------------------------------------------------------------------------------
  750. #ifndef PZEM004T_SUPPORT
  751. #define PZEM004T_SUPPORT 0
  752. #endif
  753. #ifndef PZEM004T_USE_SOFT
  754. #define PZEM004T_USE_SOFT 0 // By default, use Hardware serial with GPIO15 (TX) and GPIO13 (RX)
  755. #endif
  756. #ifndef PZEM004T_RX_PIN
  757. #define PZEM004T_RX_PIN 13 // Serial RX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  758. #endif
  759. #ifndef PZEM004T_TX_PIN
  760. #define PZEM004T_TX_PIN 15 // Serial TX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  761. #endif
  762. #ifndef PZEM004T_HW_PORT
  763. #define PZEM004T_HW_PORT Serial // Hardware serial port (if PZEM004T_USE_SOFT == 0)
  764. // ESP8266: Serial1 does not allow receiving data, no point in changing this setting
  765. #endif
  766. #ifndef PZEM004T_ADDRESSES
  767. #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"
  768. #endif
  769. #ifndef PZEM004T_READ_INTERVAL
  770. #define PZEM004T_READ_INTERVAL 1500 // Read interval between same device
  771. #endif
  772. #ifndef PZEM004T_MAX_DEVICES
  773. #define PZEM004T_MAX_DEVICES 3
  774. #endif
  775. //------------------------------------------------------------------------------
  776. // PZEM004T **V3.0** based power monitor
  777. // Enable support by passing PZEM004TV30_SUPPORT=1 build flag
  778. //------------------------------------------------------------------------------
  779. #ifndef PZEM004TV30_SUPPORT
  780. #define PZEM004TV30_SUPPORT 0
  781. #endif
  782. #ifndef PZEM004TV30_ADDRESS
  783. #define PZEM004TV30_ADDRESS 0xF8 // Default: factory value
  784. #endif
  785. #ifndef PZEM004TV30_USE_SOFT
  786. #define PZEM004TV30_USE_SOFT 0 // By default, use Hardware serial with GPIO15 (TX) and GPIO13 (RX)
  787. // (but, make sure that DEBUG_SERIAL_SUPPORT is set to 0)
  788. #endif
  789. #ifndef PZEM004TV30_RX_PIN
  790. #define PZEM004TV30_RX_PIN 13 // Serial RX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  791. #endif
  792. #ifndef PZEM004TV30_TX_PIN
  793. #define PZEM004TV30_TX_PIN 15 // Serial TX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  794. #endif
  795. #ifndef PZEM004TV30_DEBUG
  796. #define PZEM004TV30_DEBUG 0
  797. #endif
  798. //------------------------------------------------------------------------------
  799. // SDS011 particulates sensor
  800. // Enable support by passing SDS011_SUPPORT=1 build flag
  801. //------------------------------------------------------------------------------
  802. #ifndef SDS011_SUPPORT
  803. #define SDS011_SUPPORT 0
  804. #endif
  805. #ifndef SDS011_RX_PIN
  806. #define SDS011_RX_PIN 14
  807. #endif
  808. #ifndef SDS011_TX_PIN
  809. #define SDS011_TX_PIN 12
  810. #endif
  811. //------------------------------------------------------------------------------
  812. // SenseAir CO2 sensor
  813. // Enable support by passing SENSEAIR_SUPPORT=1 build flag
  814. //------------------------------------------------------------------------------
  815. #ifndef SENSEAIR_SUPPORT
  816. #define SENSEAIR_SUPPORT 0
  817. #endif
  818. #ifndef SENSEAIR_RX_PIN
  819. #define SENSEAIR_RX_PIN 0
  820. #endif
  821. #ifndef SENSEAIR_TX_PIN
  822. #define SENSEAIR_TX_PIN 2
  823. #endif
  824. //------------------------------------------------------------------------------
  825. // SHT3X I2C (Wemos) temperature & humidity sensor
  826. // Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
  827. //------------------------------------------------------------------------------
  828. #ifndef SHT3X_I2C_SUPPORT
  829. #define SHT3X_I2C_SUPPORT 0
  830. #endif
  831. #ifndef SHT3X_I2C_ADDRESS
  832. #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto
  833. #endif
  834. //------------------------------------------------------------------------------
  835. // SI7021 temperature & humidity sensor
  836. // Enable support by passing SI7021_SUPPORT=1 build flag
  837. //------------------------------------------------------------------------------
  838. #ifndef SI7021_SUPPORT
  839. #define SI7021_SUPPORT 0
  840. #endif
  841. #ifndef SI7021_ADDRESS
  842. #define SI7021_ADDRESS 0x00 // 0x00 means auto
  843. #endif
  844. //------------------------------------------------------------------------------
  845. // HDC1080 / 831R temperature & humidity sensor
  846. // Enable support by passing HDC1080_SUPPORT=1 build flag
  847. //------------------------------------------------------------------------------
  848. #ifndef HDC1080_SUPPORT
  849. #define HDC1080_SUPPORT 0
  850. #endif
  851. #ifndef HDC1080_ADDRESS
  852. #define HDC1080_ADDRESS 0x00 // 0x00 means auto
  853. #endif
  854. //------------------------------------------------------------------------------
  855. // Sonar
  856. // Enable support by passing SONAR_SUPPORT=1 build flag
  857. //------------------------------------------------------------------------------
  858. #ifndef SONAR_SUPPORT
  859. #define SONAR_SUPPORT 0
  860. #endif
  861. #ifndef SONAR_TRIGGER
  862. #define SONAR_TRIGGER 12 // GPIO for the trigger pin (output)
  863. #endif
  864. #ifndef SONAR_ECHO
  865. #define SONAR_ECHO 14 // GPIO for the echo pin (input)
  866. #endif
  867. #ifndef SONAR_MAX_DISTANCE
  868. #define SONAR_MAX_DISTANCE MAX_SENSOR_DISTANCE // Max sensor distance in cm
  869. #endif
  870. #ifndef SONAR_ITERATIONS
  871. #define SONAR_ITERATIONS 5 // Number of iterations to ping for
  872. #endif // error correction.
  873. //------------------------------------------------------------------------------
  874. // T6613 CO2 sensor
  875. // Enable support by passing T6613_SUPPORT=1 build flag
  876. //------------------------------------------------------------------------------
  877. #ifndef T6613_SUPPORT
  878. #define T6613_SUPPORT 0
  879. #endif
  880. #ifndef T6613_RX_PIN
  881. #define T6613_RX_PIN 4
  882. #endif
  883. #ifndef T6613_TX_PIN
  884. #define T6613_TX_PIN 5
  885. #endif
  886. //------------------------------------------------------------------------------
  887. // TMP3X analog temperature sensor
  888. // Enable support by passing TMP3X_SUPPORT=1 build flag
  889. //------------------------------------------------------------------------------
  890. #ifndef TMP3X_SUPPORT
  891. #define TMP3X_SUPPORT 0
  892. #endif
  893. #ifndef TMP3X_TYPE
  894. #define TMP3X_TYPE TMP3X_TMP35
  895. #endif
  896. //------------------------------------------------------------------------------
  897. // V9261F based power sensor
  898. // Enable support by passing SI7021_SUPPORT=1 build flag
  899. //------------------------------------------------------------------------------
  900. #ifndef V9261F_SUPPORT
  901. #define V9261F_SUPPORT 0
  902. #endif
  903. #ifndef V9261F_PIN
  904. #define V9261F_PIN 2 // TX pin from the V9261F
  905. #endif
  906. #ifndef V9261F_PIN_INVERSE
  907. #define V9261F_PIN_INVERSE 1 // Signal is inverted
  908. #endif
  909. #define V9261F_SYNC_INTERVAL 600 // Sync signal length (ms)
  910. #define V9261F_BAUDRATE 4800 // UART baudrate
  911. // Default ratios
  912. #define V9261F_CURRENT_FACTOR 79371434.0
  913. #define V9261F_VOLTAGE_FACTOR 4160651.0
  914. #define V9261F_POWER_FACTOR 153699.0
  915. #define V9261F_RPOWER_FACTOR V9261F_CURRENT_FACTOR
  916. //------------------------------------------------------------------------------
  917. // VEML6075 based power sensor
  918. // Enable support by passing VEML6075_SUPPORT=1 build flag
  919. //------------------------------------------------------------------------------
  920. #ifndef VEML6075_SUPPORT
  921. #define VEML6075_SUPPORT 0
  922. #endif
  923. #ifndef VEML6075_INTEGRATION_TIME
  924. #define VEML6075_INTEGRATION_TIME VEML6075::IT_100MS // The time, in milliseconds, allocated for a single
  925. #endif // measurement. A longer timing budget allows for more
  926. // accurate results at the cost of power.
  927. #ifndef VEML6075_DYNAMIC_MODE
  928. #define VEML6075_DYNAMIC_MODE VEML6075::DYNAMIC_NORMAL // The dynamic mode can either be normal or high. In high
  929. #endif // dynamic mode, the resolution increases by about two
  930. // times.
  931. //------------------------------------------------------------------------------
  932. // VL53L1X
  933. // Enable support by passing VL53L1X_SUPPORT=1 build flag
  934. //------------------------------------------------------------------------------
  935. #ifndef VL53L1X_SUPPORT
  936. #define VL53L1X_SUPPORT 0
  937. #endif
  938. #ifndef VL53L1X_I2C_ADDRESS
  939. #define VL53L1X_I2C_ADDRESS 0x00 // 0x00 means auto
  940. #endif
  941. #ifndef VL53L1X_DISTANCE_MODE
  942. #define VL53L1X_DISTANCE_MODE VL53L1X::Long // The distance mode of the sensor. Can be one of
  943. #endif // `VL53L1X::Short`, `VL53L1X::Medium`, or `VL53L1X::Long.
  944. // Shorter distance modes are less affected by ambient light
  945. // but have lower maximum ranges, especially in the dark.
  946. #ifndef VL53L1X_MEASUREMENT_TIMING_BUDGET
  947. #define VL53L1X_MEASUREMENT_TIMING_BUDGET 140000 // The time, in microseconds, allocated for a single
  948. // measurement. A longer timing budget allows for more
  949. // accurate at the cost of power. The minimum budget is
  950. // 20 ms (20000 us) in short distance mode and 33 ms for
  951. // medium and long distance modes.
  952. #endif
  953. #ifndef VL53L1X_INTER_MEASUREMENT_PERIOD
  954. #define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how
  955. #endif // often the sensor takes a measurement.
  956. //------------------------------------------------------------------------------
  957. // MAX6675
  958. // Enable support by passing MAX6675_SUPPORT=1 build flag
  959. //------------------------------------------------------------------------------
  960. #ifndef MAX6675_CS_PIN
  961. #define MAX6675_CS_PIN 13
  962. #endif
  963. #ifndef MAX6675_SO_PIN
  964. #define MAX6675_SO_PIN 12
  965. #endif
  966. #ifndef MAX6675_SCK_PIN
  967. #define MAX6675_SCK_PIN 14
  968. #endif
  969. //------------------------------------------------------------------------------
  970. // EZOPH pH meter
  971. // Enable support by passing EZOPH_SUPPORT=1 build flag
  972. //------------------------------------------------------------------------------
  973. #ifndef EZOPH_SUPPORT
  974. #define EZOPH_SUPPORT 0
  975. #endif
  976. #ifndef EZOPH_RX_PIN
  977. #define EZOPH_RX_PIN 13 // Software serial RX GPIO
  978. #endif
  979. #ifndef EZOPH_TX_PIN
  980. #define EZOPH_TX_PIN 15 // Software serial TX GPIO
  981. #endif
  982. #ifndef EZOPH_SYNC_INTERVAL
  983. #define EZOPH_SYNC_INTERVAL 1000 // Amount of time (in ms) sync new readings.
  984. #endif
  985. // -----------------------------------------------------------------------------
  986. // ADE7953 Shelly Sensor
  987. // Enable support by passing ADE7953_SUPPORT=1 build flag
  988. // -----------------------------------------------------------------------------
  989. #ifndef ADE7953_SUPPORT
  990. #define ADE7953_SUPPORT 0
  991. #endif
  992. #ifndef ADE7953_ADDRESS
  993. #define ADE7953_ADDRESS 0x38
  994. #endif
  995. // -----------------------------------------------------------------------------
  996. // SI1145 UV Sensor over I2C
  997. // Enable support by passing SI1145_SUPPORT=1 build flag
  998. // -----------------------------------------------------------------------------
  999. #ifndef SI1145_SUPPORT
  1000. #define SI1145_SUPPORT 0
  1001. #endif
  1002. #ifndef SI1145_ADDRESS
  1003. #define SI1145_ADDRESS 0x60
  1004. #endif
  1005. // -----------------------------------------------------------------------------
  1006. // ADC
  1007. // -----------------------------------------------------------------------------
  1008. // Default ADC mode is to monitor internal power supply
  1009. #ifndef ADC_MODE_VALUE
  1010. #define ADC_MODE_VALUE ADC_VCC
  1011. #endif
  1012. // -----------------------------------------------------------------------------
  1013. // I2C
  1014. // -----------------------------------------------------------------------------
  1015. #ifndef I2C_SUPPORT
  1016. #define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
  1017. #endif
  1018. #define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
  1019. #ifndef I2C_SDA_PIN
  1020. #define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4, using Arduino Core variant definition as default)
  1021. #endif
  1022. #ifndef I2C_SCL_PIN
  1023. #define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14, using Arduino Core variant definition as default)
  1024. #endif
  1025. #ifndef I2C_CLOCK_STRETCH_TIME
  1026. #define I2C_CLOCK_STRETCH_TIME 200UL // BRZO clock stretch time
  1027. #endif
  1028. #ifndef I2C_SCL_FREQUENCY
  1029. #define I2C_SCL_FREQUENCY 1000UL // BRZO SCL frequency
  1030. #endif
  1031. #ifndef I2C_CLEAR_BUS
  1032. #define I2C_CLEAR_BUS 0 // Clear I2C bus on boot
  1033. #endif
  1034. #ifndef I2C_PERFORM_SCAN
  1035. #define I2C_PERFORM_SCAN 1 // Perform a bus scan on boot
  1036. #endif
  1037. // =============================================================================
  1038. // Configuration helpers
  1039. // =============================================================================
  1040. // I2C support when sensor needs it
  1041. #if ( ADE7953_SUPPORT || \
  1042. AM2320_SUPPORT || \
  1043. BH1750_SUPPORT || \
  1044. BMP180_SUPPORT || \
  1045. BMX280_SUPPORT || \
  1046. EMON_ADC121_SUPPORT || \
  1047. EMON_ADS1X15_SUPPORT || \
  1048. SHT3X_I2C_SUPPORT || \
  1049. SI1145_SUPPORT || \
  1050. SI7021_SUPPORT || \
  1051. VEML6075_SUPPORT || \
  1052. VL53L1X_SUPPORT || \
  1053. HDC1080_SUPPORT \
  1054. )
  1055. #undef I2C_SUPPORT
  1056. #define I2C_SUPPORT 1
  1057. #endif
  1058. // Can't have ADC reading something else
  1059. #if ( ANALOG_SUPPORT || \
  1060. EMON_ANALOG_SUPPORT || \
  1061. GUVAS12SD_SUPPORT || \
  1062. LDR_SUPPORT || \
  1063. MICS2710_SUPPORT || \
  1064. MICS5525_SUPPORT || \
  1065. NTC_SUPPORT || \
  1066. TMP3X_SUPPORT \
  1067. )
  1068. #undef ADC_MODE_VALUE
  1069. #define ADC_MODE_VALUE ADC_TOUT
  1070. #endif
  1071. // Provide generic way to detect sensor presence
  1072. #ifndef SENSOR_SUPPORT
  1073. #define SENSOR_SUPPORT ( \
  1074. ADE7953_SUPPORT || \
  1075. AM2320_SUPPORT || \
  1076. ANALOG_SUPPORT || \
  1077. BH1750_SUPPORT || \
  1078. BMP180_SUPPORT || \
  1079. BMX280_SUPPORT || \
  1080. CSE7766_SUPPORT || \
  1081. DALLAS_SUPPORT || \
  1082. DHT_SUPPORT || \
  1083. DIGITAL_SUPPORT || \
  1084. ECH1560_SUPPORT || \
  1085. EMON_ADC121_SUPPORT || \
  1086. EMON_ADS1X15_SUPPORT || \
  1087. EMON_ANALOG_SUPPORT || \
  1088. EVENTS_SUPPORT || \
  1089. EZOPH_SUPPORT || \
  1090. GEIGER_SUPPORT || \
  1091. GUVAS12SD_SUPPORT || \
  1092. HLW8012_SUPPORT || \
  1093. LDR_SUPPORT || \
  1094. MAX6675_SUPPORT || \
  1095. MHZ19_SUPPORT || \
  1096. MICS2710_SUPPORT || \
  1097. MICS5525_SUPPORT || \
  1098. NTC_SUPPORT || \
  1099. PMSX003_SUPPORT || \
  1100. PULSEMETER_SUPPORT || \
  1101. PZEM004T_SUPPORT || \
  1102. SDS011_SUPPORT || \
  1103. SENSEAIR_SUPPORT || \
  1104. SHT3X_I2C_SUPPORT || \
  1105. SI1145_SUPPORT || \
  1106. SI7021_SUPPORT || \
  1107. SONAR_SUPPORT || \
  1108. T6613_SUPPORT || \
  1109. THERMOSTAT_SUPPORT || \
  1110. TMP3X_SUPPORT || \
  1111. V9261F_SUPPORT || \
  1112. VEML6075_SUPPORT || \
  1113. VL53L1X_SUPPORT || \
  1114. HDC1080_SUPPORT || \
  1115. PZEM004TV30_SUPPORT \
  1116. )
  1117. #endif