Mirror of espurna firmware for wireless switches and more
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.

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