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.

1432 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_PIN
  227. #define CSE7766_PIN 1 // TX pin from the CSE7766
  228. #endif
  229. #ifndef CSE7766_PIN_INVERSE
  230. #define CSE7766_PIN_INVERSE 0 // Signal is inverted
  231. #endif
  232. #define CSE7766_SYNC_INTERVAL 300 // Safe time between transmissions (ms)
  233. #define CSE7766_BAUDRATE 4800 // UART baudrate
  234. #define CSE7766_V1R 1.0 // 1mR current resistor
  235. #define CSE7766_V2R 1.0 // 1M voltage resistor
  236. //------------------------------------------------------------------------------
  237. // Digital sensor
  238. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  239. //------------------------------------------------------------------------------
  240. #ifndef DIGITAL_SUPPORT
  241. #define DIGITAL_SUPPORT 0
  242. #endif
  243. #ifndef DIGITAL1_PIN
  244. #define DIGITAL1_PIN 2
  245. #endif
  246. #ifndef DIGITAL1_PIN_MODE
  247. #define DIGITAL1_PIN_MODE INPUT_PULLUP
  248. #endif
  249. #ifndef DIGITAL1_DEFAULT_STATE
  250. #define DIGITAL1_DEFAULT_STATE 1
  251. #endif
  252. #ifndef DIGITAL2_PIN
  253. #define DIGITAL2_PIN 2
  254. #endif
  255. #ifndef DIGITAL2_PIN_MODE
  256. #define DIGITAL2_PIN_MODE INPUT_PULLUP
  257. #endif
  258. #ifndef DIGITAL2_DEFAULT_STATE
  259. #define DIGITAL2_DEFAULT_STATE 1
  260. #endif
  261. #ifndef DIGITAL3_PIN
  262. #define DIGITAL3_PIN 2
  263. #endif
  264. #ifndef DIGITAL3_PIN_MODE
  265. #define DIGITAL3_PIN_MODE INPUT_PULLUP
  266. #endif
  267. #ifndef DIGITAL3_DEFAULT_STATE
  268. #define DIGITAL3_DEFAULT_STATE 1
  269. #endif
  270. #ifndef DIGITAL4_PIN
  271. #define DIGITAL4_PIN 2
  272. #endif
  273. #ifndef DIGITAL4_PIN_MODE
  274. #define DIGITAL4_PIN_MODE INPUT_PULLUP
  275. #endif
  276. #ifndef DIGITAL4_DEFAULT_STATE
  277. #define DIGITAL4_DEFAULT_STATE 1
  278. #endif
  279. #ifndef DIGITAL5_PIN
  280. #define DIGITAL5_PIN 2
  281. #endif
  282. #ifndef DIGITAL5_PIN_MODE
  283. #define DIGITAL5_PIN_MODE INPUT_PULLUP
  284. #endif
  285. #ifndef DIGITAL5_DEFAULT_STATE
  286. #define DIGITAL5_DEFAULT_STATE 1
  287. #endif
  288. #ifndef DIGITAL6_PIN
  289. #define DIGITAL6_PIN 2
  290. #endif
  291. #ifndef DIGITAL6_PIN_MODE
  292. #define DIGITAL6_PIN_MODE INPUT_PULLUP
  293. #endif
  294. #ifndef DIGITAL6_DEFAULT_STATE
  295. #define DIGITAL6_DEFAULT_STATE 1
  296. #endif
  297. #ifndef DIGITAL7_PIN
  298. #define DIGITAL7_PIN 2
  299. #endif
  300. #ifndef DIGITAL7_PIN_MODE
  301. #define DIGITAL7_PIN_MODE INPUT_PULLUP
  302. #endif
  303. #ifndef DIGITAL7_DEFAULT_STATE
  304. #define DIGITAL7_DEFAULT_STATE 1
  305. #endif
  306. #ifndef DIGITAL8_PIN
  307. #define DIGITAL8_PIN 2
  308. #endif
  309. #ifndef DIGITAL8_PIN_MODE
  310. #define DIGITAL8_PIN_MODE INPUT_PULLUP
  311. #endif
  312. #ifndef DIGITAL8_DEFAULT_STATE
  313. #define DIGITAL8_DEFAULT_STATE 1
  314. #endif
  315. //------------------------------------------------------------------------------
  316. // ECH1560 based power sensor
  317. // Enable support by passing ECH1560_SUPPORT=1 build flag
  318. //------------------------------------------------------------------------------
  319. #ifndef ECH1560_SUPPORT
  320. #define ECH1560_SUPPORT 0
  321. #endif
  322. #ifndef ECH1560_CLK_PIN
  323. #define ECH1560_CLK_PIN 4 // CLK pin for the ECH1560
  324. #endif
  325. #ifndef ECH1560_MISO_PIN
  326. #define ECH1560_MISO_PIN 5 // MISO pin for the ECH1560
  327. #endif
  328. #ifndef ECH1560_INVERTED
  329. #define ECH1560_INVERTED 0 // Signal is inverted
  330. #endif
  331. //------------------------------------------------------------------------------
  332. // Energy Monitor general settings
  333. //------------------------------------------------------------------------------
  334. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  335. #define EMON_MAX_TIME 250 // Max time in ms to sample
  336. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  337. #define EMON_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  338. #ifndef EMON_MAINS_VOLTAGE
  339. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  340. #endif
  341. #ifndef EMON_CURRENT_RATIO
  342. #define EMON_CURRENT_RATIO 30.0 // Current ratio in the clamp (30A/1V)
  343. #endif
  344. #ifndef EMON_REPORT_CURRENT
  345. #define EMON_REPORT_CURRENT 0 // Report current
  346. #endif
  347. #ifndef EMON_REPORT_POWER
  348. #define EMON_REPORT_POWER 1 // Report power
  349. #endif
  350. #ifndef EMON_REPORT_ENERGY
  351. #define EMON_REPORT_ENERGY 1 // Report energy
  352. #endif
  353. //------------------------------------------------------------------------------
  354. // Energy Monitor based on ADC121
  355. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  356. //------------------------------------------------------------------------------
  357. #ifndef EMON_ADC121_SUPPORT
  358. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  359. #endif
  360. #ifndef EMON_ADC121_I2C_ADDRESS
  361. #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
  362. #endif
  363. //------------------------------------------------------------------------------
  364. // Energy Monitor based on ADS1X15
  365. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  366. //------------------------------------------------------------------------------
  367. #ifndef EMON_ADS1X15_SUPPORT
  368. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  369. #endif
  370. #ifndef EMON_ADS1X15_I2C_ADDRESS
  371. #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
  372. #endif
  373. #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
  374. #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
  375. #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
  376. //------------------------------------------------------------------------------
  377. // Energy Monitor based on interval analog GPIO
  378. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  379. //------------------------------------------------------------------------------
  380. #ifndef EMON_ANALOG_SUPPORT
  381. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  382. #endif
  383. //------------------------------------------------------------------------------
  384. // Counter sensor
  385. // Enable support by passing EVENTS_SUPPORT=1 build flag
  386. //------------------------------------------------------------------------------
  387. #ifndef EVENTS_SUPPORT
  388. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  389. #endif
  390. #ifndef EVENTS1_TRIGGER
  391. #define EVENTS1_TRIGGER 1 // 1 to trigger callback on events,
  392. // 0 to only count them and report periodically
  393. #endif
  394. #ifndef EVENTS1_PIN
  395. #define EVENTS1_PIN 2 // GPIO to monitor
  396. #endif
  397. #ifndef EVENTS1_PIN_MODE
  398. #define EVENTS1_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  399. #endif
  400. #ifndef EVENTS1_INTERRUPT_MODE
  401. #define EVENTS1_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  402. #endif
  403. #ifndef EVENTS1_DEBOUNCE
  404. #define EVENTS1_DEBOUNCE 50 // Do not register events within less than 50 millis
  405. #endif
  406. #ifndef EVENTS2_TRIGGER
  407. #define EVENTS2_TRIGGER 1 // 1 to trigger callback on events,
  408. // 0 to only count them and report periodically
  409. #endif
  410. #ifndef EVENTS2_PIN
  411. #define EVENTS2_PIN 2 // GPIO to monitor
  412. #endif
  413. #ifndef EVENTS2_PIN_MODE
  414. #define EVENTS2_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  415. #endif
  416. #ifndef EVENTS2_INTERRUPT_MODE
  417. #define EVENTS2_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  418. #endif
  419. #ifndef EVENTS2_DEBOUNCE
  420. #define EVENTS2_DEBOUNCE 50 // Do not register events within less than 50 millis
  421. #endif
  422. #ifndef EVENTS3_TRIGGER
  423. #define EVENTS3_TRIGGER 1 // 1 to trigger callback on events,
  424. // 0 to only count them and report periodically
  425. #endif
  426. #ifndef EVENTS3_PIN
  427. #define EVENTS3_PIN 2 // GPIO to monitor
  428. #endif
  429. #ifndef EVENTS3_PIN_MODE
  430. #define EVENTS3_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  431. #endif
  432. #ifndef EVENTS3_INTERRUPT_MODE
  433. #define EVENTS3_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  434. #endif
  435. #ifndef EVENTS3_DEBOUNCE
  436. #define EVENTS3_DEBOUNCE 50 // Do not register events within less than 50 millis
  437. #endif
  438. #ifndef EVENTS4_TRIGGER
  439. #define EVENTS4_TRIGGER 1 // 1 to trigger callback on events,
  440. // 0 to only count them and report periodically
  441. #endif
  442. #ifndef EVENTS4_PIN
  443. #define EVENTS4_PIN 2 // GPIO to monitor
  444. #endif
  445. #ifndef EVENTS4_PIN_MODE
  446. #define EVENTS4_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  447. #endif
  448. #ifndef EVENTS4_INTERRUPT_MODE
  449. #define EVENTS4_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  450. #endif
  451. #ifndef EVENTS4_DEBOUNCE
  452. #define EVENTS4_DEBOUNCE 50 // Do not register events within less than 50 millis
  453. #endif
  454. #ifndef EVENTS5_TRIGGER
  455. #define EVENTS5_TRIGGER 1 // 1 to trigger callback on events,
  456. // 0 to only count them and report periodically
  457. #endif
  458. #ifndef EVENTS5_PIN
  459. #define EVENTS5_PIN 2 // GPIO to monitor
  460. #endif
  461. #ifndef EVENTS5_PIN_MODE
  462. #define EVENTS5_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  463. #endif
  464. #ifndef EVENTS5_INTERRUPT_MODE
  465. #define EVENTS5_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  466. #endif
  467. #ifndef EVENTS5_DEBOUNCE
  468. #define EVENTS5_DEBOUNCE 50 // Do not register events within less than 50 millis
  469. #endif
  470. #ifndef EVENTS6_TRIGGER
  471. #define EVENTS6_TRIGGER 1 // 1 to trigger callback on events,
  472. // 0 to only count them and report periodically
  473. #endif
  474. #ifndef EVENTS6_PIN
  475. #define EVENTS6_PIN 2 // GPIO to monitor
  476. #endif
  477. #ifndef EVENTS6_PIN_MODE
  478. #define EVENTS6_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  479. #endif
  480. #ifndef EVENTS6_INTERRUPT_MODE
  481. #define EVENTS6_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  482. #endif
  483. #ifndef EVENTS6_DEBOUNCE
  484. #define EVENTS6_DEBOUNCE 50 // Do not register events within less than 50 millis
  485. #endif
  486. #ifndef EVENTS7_TRIGGER
  487. #define EVENTS7_TRIGGER 1 // 1 to trigger callback on events,
  488. // 0 to only count them and report periodically
  489. #endif
  490. #ifndef EVENTS7_PIN
  491. #define EVENTS7_PIN 2 // GPIO to monitor
  492. #endif
  493. #ifndef EVENTS7_PIN_MODE
  494. #define EVENTS7_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  495. #endif
  496. #ifndef EVENTS7_INTERRUPT_MODE
  497. #define EVENTS7_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  498. #endif
  499. #ifndef EVENTS7_DEBOUNCE
  500. #define EVENTS7_DEBOUNCE 50 // Do not register events within less than 50 millis
  501. #endif
  502. #ifndef EVENTS8_TRIGGER
  503. #define EVENTS8_TRIGGER 1 // 1 to trigger callback on events,
  504. // 0 to only count them and report periodically
  505. #endif
  506. #ifndef EVENTS8_PIN
  507. #define EVENTS8_PIN 2 // GPIO to monitor
  508. #endif
  509. #ifndef EVENTS8_PIN_MODE
  510. #define EVENTS8_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  511. #endif
  512. #ifndef EVENTS8_INTERRUPT_MODE
  513. #define EVENTS8_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  514. #endif
  515. #ifndef EVENTS8_DEBOUNCE
  516. #define EVENTS8_DEBOUNCE 50 // Do not register events within less than 50 millis
  517. #endif
  518. //------------------------------------------------------------------------------
  519. // Geiger sensor
  520. // Enable support by passing GEIGER_SUPPORT=1 build flag
  521. //------------------------------------------------------------------------------
  522. #ifndef GEIGER_SUPPORT
  523. #define GEIGER_SUPPORT 0 // Do not build with geiger support by default
  524. #endif
  525. #ifndef GEIGER_PIN
  526. #define GEIGER_PIN D1 // GPIO to monitor "D1" => "GPIO5"
  527. #endif
  528. #ifndef GEIGER_PIN_MODE
  529. #define GEIGER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  530. #endif
  531. #ifndef GEIGER_INTERRUPT_MODE
  532. #define GEIGER_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE
  533. #endif
  534. #define GEIGER_DEBOUNCE 25 // Do not register events within less than 25 millis.
  535. // Value derived here: Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter
  536. #define GEIGER_CPM2SIEVERT 240 // CPM to µSievert per hour conversion factor
  537. // Typically the literature uses the invers, but I find an integer type more convienient.
  538. #define GEIGER_REPORT_SIEVERTS 1 // Enabler for local dose rate reports in µSv/h
  539. #define GEIGER_REPORT_CPM 1 // Enabler for local dose rate reports in counts per minute
  540. //------------------------------------------------------------------------------
  541. // GUVAS12SD UV Sensor (analog)
  542. // Enable support by passing GUVAS12SD_SUPPORT=1 build flag
  543. //------------------------------------------------------------------------------
  544. #ifndef GUVAS12SD_SUPPORT
  545. #define GUVAS12SD_SUPPORT 0
  546. #endif
  547. #ifndef GUVAS12SD_PIN
  548. #define GUVAS12SD_PIN 14
  549. #endif
  550. //------------------------------------------------------------------------------
  551. // HLW8012 Energy monitor IC
  552. // Enable support by passing HLW8012_SUPPORT=1 build flag
  553. //------------------------------------------------------------------------------
  554. #ifndef HLW8012_SUPPORT
  555. #define HLW8012_SUPPORT 0
  556. #endif
  557. #ifndef HLW8012_SEL_PIN
  558. #define HLW8012_SEL_PIN 5
  559. #endif
  560. #ifndef HLW8012_CF1_PIN
  561. #define HLW8012_CF1_PIN 13
  562. #endif
  563. #ifndef HLW8012_CF_PIN
  564. #define HLW8012_CF_PIN 14
  565. #endif
  566. #ifndef HLW8012_SEL_CURRENT
  567. #define HLW8012_SEL_CURRENT HIGH // SEL pin to HIGH to measure current
  568. #endif
  569. #ifndef HLW8012_CURRENT_R
  570. #define HLW8012_CURRENT_R 0.001 // Current resistor
  571. #endif
  572. #ifndef HLW8012_VOLTAGE_R_UP
  573. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Upstream voltage resistor
  574. #endif
  575. #ifndef HLW8012_VOLTAGE_R_DOWN
  576. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Downstream voltage resistor
  577. #endif
  578. #ifndef HLW8012_CURRENT_RATIO
  579. #define HLW8012_CURRENT_RATIO 0.0 // Set to 0.0 to use factory defaults
  580. #endif
  581. #ifndef HLW8012_VOLTAGE_RATIO
  582. #define HLW8012_VOLTAGE_RATIO 0.0 // Set to 0.0 to use factory defaults
  583. #endif
  584. #ifndef HLW8012_POWER_RATIO
  585. #define HLW8012_POWER_RATIO 0.0 // Set to 0.0 to use factory defaults
  586. #endif
  587. #ifndef HLW8012_USE_INTERRUPTS
  588. #define HLW8012_USE_INTERRUPTS 1 // Use interrupts to trap HLW8012 signals
  589. #endif
  590. #ifndef HLW8012_WAIT_FOR_WIFI
  591. #define HLW8012_WAIT_FOR_WIFI 0 // Weather to enable interrupts only after
  592. // wifi connection has been stablished
  593. #endif
  594. #ifndef HLW8012_INTERRUPT_ON
  595. #define HLW8012_INTERRUPT_ON CHANGE // When to trigger the interrupt
  596. // Use CHANGE for HLW8012
  597. // Use FALLING for BL0937 / HJL0
  598. #endif
  599. //------------------------------------------------------------------------------
  600. // LDR sensor
  601. // Enable support by passing LDR_SUPPORT=1 build flag
  602. //------------------------------------------------------------------------------
  603. #ifndef LDR_SUPPORT
  604. #define LDR_SUPPORT 0
  605. #endif
  606. #ifndef LDR_SAMPLES
  607. #define LDR_SAMPLES 10 // Number of samples
  608. #endif
  609. #ifndef LDR_DELAY
  610. #define LDR_DELAY 0 // Delay between samples in micros
  611. #endif
  612. #ifndef LDR_TYPE
  613. #define LDR_TYPE LDR_GL5528
  614. #endif
  615. #ifndef LDR_ON_GROUND
  616. #define LDR_ON_GROUND true
  617. #endif
  618. #ifndef LDR_RESISTOR
  619. #define LDR_RESISTOR 10000 // Resistance
  620. #endif
  621. #ifndef LDR_MULTIPLICATION
  622. #define LDR_MULTIPLICATION 32017200
  623. #endif
  624. #ifndef LDR_POWER
  625. #define LDR_POWER 1.5832
  626. #endif
  627. //------------------------------------------------------------------------------
  628. // MHZ19 CO2 sensor
  629. // Enable support by passing MHZ19_SUPPORT=1 build flag
  630. //------------------------------------------------------------------------------
  631. #ifndef MHZ19_SUPPORT
  632. #define MHZ19_SUPPORT 0
  633. #endif
  634. #ifndef MHZ19_RX_PIN
  635. #define MHZ19_RX_PIN 13
  636. #endif
  637. #ifndef MHZ19_TX_PIN
  638. #define MHZ19_TX_PIN 15
  639. #endif
  640. //------------------------------------------------------------------------------
  641. // MICS-2710 (and MICS-4514) NO2 sensor
  642. // Enable support by passing MICS2710_SUPPORT=1 build flag
  643. //------------------------------------------------------------------------------
  644. #ifndef MICS2710_SUPPORT
  645. #define MICS2710_SUPPORT 0
  646. #endif
  647. #ifndef MICS2710_NOX_PIN
  648. #define MICS2710_NOX_PIN 0
  649. #endif
  650. #ifndef MICS2710_PRE_PIN
  651. #define MICS2710_PRE_PIN 4
  652. #endif
  653. #define MICS2710_PREHEAT_TIME 10000 // 10s preheat for NOX read
  654. #define MICS2710_RL 820 // RL, load resistor
  655. #define MICS2710_R0 2200 // R0 calibration value for NO2 sensor,
  656. // Typical value as per datasheet
  657. //------------------------------------------------------------------------------
  658. // MICS-5525 (and MICS-4514) CO sensor
  659. // Enable support by passing MICS5525_SUPPORT=1 build flag
  660. //------------------------------------------------------------------------------
  661. #ifndef MICS5525_SUPPORT
  662. #define MICS5525_SUPPORT 0
  663. #endif
  664. #ifndef MICS5525_RED_PIN
  665. #define MICS5525_RED_PIN 0
  666. #endif
  667. #define MICS5525_RL 820 // RL, load resistor
  668. #define MICS5525_R0 750000 // R0 calibration value for NO2 sensor,
  669. // Typical value as per datasheet
  670. //------------------------------------------------------------------------------
  671. // NTC sensor
  672. // Enable support by passing NTC_SUPPORT=1 build flag
  673. //--------------------------------------------------------------------------------
  674. #ifndef NTC_SUPPORT
  675. #define NTC_SUPPORT 0
  676. #endif
  677. #ifndef NTC_SAMPLES
  678. #define NTC_SAMPLES 10 // Number of samples
  679. #endif
  680. #ifndef NTC_DELAY
  681. #define NTC_DELAY 0 // Delay between samples in micros
  682. #endif
  683. #ifndef NTC_R_UP
  684. #define NTC_R_UP 0 // Resistor upstream, set to 0 if none
  685. #endif
  686. #ifndef NTC_R_DOWN
  687. #define NTC_R_DOWN 10000 // Resistor downstream, set to 0 if none
  688. #endif
  689. #ifndef NTC_T0
  690. #define NTC_T0 298.15 // 25 Celsius
  691. #endif
  692. #ifndef NTC_R0
  693. #define NTC_R0 10000 // Resistance at T0
  694. #endif
  695. #ifndef NTC_BETA
  696. #define NTC_BETA 3977 // Beta coeficient
  697. #endif
  698. //------------------------------------------------------------------------------
  699. // Particle Monitor based on Plantower PMS
  700. // Enable support by passing PMSX003_SUPPORT=1 build flag
  701. //------------------------------------------------------------------------------
  702. #ifndef PMSX003_SUPPORT
  703. #define PMSX003_SUPPORT 0
  704. #endif
  705. #ifndef PMS_TYPE
  706. #define PMS_TYPE PMS_TYPE_X003
  707. #endif
  708. // You can enable smart sleep (read 6-times then sleep on 24-reading-cycles) to extend PMS sensor's life.
  709. // Otherwise the default lifetime of PMS sensor is about 8000-hours/1-years.
  710. // The PMS's fan will stop working on sleeping cycle, and will wake up on reading cycle.
  711. #ifndef PMS_SMART_SLEEP
  712. #define PMS_SMART_SLEEP 0
  713. #endif
  714. #ifndef PMS_USE_SOFT
  715. #define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0
  716. #endif
  717. #ifndef PMS_RX_PIN
  718. #define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1)
  719. #endif
  720. #ifndef PMS_TX_PIN
  721. #define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1)
  722. #endif
  723. #ifndef PMS_HW_PORT
  724. #define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0)
  725. #endif
  726. //------------------------------------------------------------------------------
  727. // Pulse Meter Energy monitor
  728. // Enable support by passing PULSEMETER_SUPPORT=1 build flag
  729. //------------------------------------------------------------------------------
  730. #ifndef PULSEMETER_SUPPORT
  731. #define PULSEMETER_SUPPORT 0
  732. #endif
  733. #ifndef PULSEMETER_PIN
  734. #define PULSEMETER_PIN 5
  735. #endif
  736. #ifndef PULSEMETER_ENERGY_RATIO
  737. #define PULSEMETER_ENERGY_RATIO 4000 // In pulses/kWh
  738. #endif
  739. #ifndef PULSEMETER_INTERRUPT_ON
  740. #define PULSEMETER_INTERRUPT_ON FALLING
  741. #endif
  742. #ifndef PULSEMETER_DEBOUNCE
  743. #define PULSEMETER_DEBOUNCE 50 // Do not register pulses within less than 50 millis
  744. #endif
  745. //------------------------------------------------------------------------------
  746. // PZEM004T based power monitor
  747. // Enable support by passing PZEM004T_SUPPORT=1 build flag
  748. //------------------------------------------------------------------------------
  749. #ifndef PZEM004T_SUPPORT
  750. #define PZEM004T_SUPPORT 0
  751. #endif
  752. #ifndef PZEM004T_USE_SOFT
  753. #define PZEM004T_USE_SOFT 0 // By default, use Hardware serial with GPIO15 (TX) and GPIO13 (RX)
  754. #endif
  755. #ifndef PZEM004T_RX_PIN
  756. #define PZEM004T_RX_PIN 13 // Serial RX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  757. #endif
  758. #ifndef PZEM004T_TX_PIN
  759. #define PZEM004T_TX_PIN 15 // Serial TX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  760. #endif
  761. #ifndef PZEM004T_HW_PORT
  762. #define PZEM004T_HW_PORT Serial // Hardware serial port (if PZEM004T_USE_SOFT == 0)
  763. // ESP8266: Serial1 does not allow receiving data, no point in changing this setting
  764. #endif
  765. #ifndef PZEM004T_ADDRESSES
  766. #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"
  767. #endif
  768. #ifndef PZEM004T_READ_INTERVAL
  769. #define PZEM004T_READ_INTERVAL 1500 // Read interval between same device
  770. #endif
  771. #ifndef PZEM004T_MAX_DEVICES
  772. #define PZEM004T_MAX_DEVICES 3
  773. #endif
  774. //------------------------------------------------------------------------------
  775. // PZEM004T **V3.0** based power monitor
  776. // Enable support by passing PZEM004TV30_SUPPORT=1 build flag
  777. //------------------------------------------------------------------------------
  778. #ifndef PZEM004TV30_SUPPORT
  779. #define PZEM004TV30_SUPPORT 0
  780. #endif
  781. #ifndef PZEM004TV30_ADDRESS
  782. #define PZEM004TV30_ADDRESS 0xF8 // Default: factory value
  783. #endif
  784. #ifndef PZEM004TV30_USE_SOFT
  785. #define PZEM004TV30_USE_SOFT 0 // By default, use Hardware serial with GPIO15 (TX) and GPIO13 (RX)
  786. // (but, make sure that DEBUG_SERIAL_SUPPORT is set to 0)
  787. #endif
  788. #ifndef PZEM004TV30_RX_PIN
  789. #define PZEM004TV30_RX_PIN 13 // Serial RX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  790. #endif
  791. #ifndef PZEM004TV30_TX_PIN
  792. #define PZEM004TV30_TX_PIN 15 // Serial TX GPIO (if PZEM004T_USE_SOFT == 1, creates a SoftwareSerial object)
  793. #endif
  794. #ifndef PZEM004TV30_DEBUG
  795. #define PZEM004TV30_DEBUG 0
  796. #endif
  797. //------------------------------------------------------------------------------
  798. // SDS011 particulates sensor
  799. // Enable support by passing SDS011_SUPPORT=1 build flag
  800. //------------------------------------------------------------------------------
  801. #ifndef SDS011_SUPPORT
  802. #define SDS011_SUPPORT 0
  803. #endif
  804. #ifndef SDS011_RX_PIN
  805. #define SDS011_RX_PIN 14
  806. #endif
  807. #ifndef SDS011_TX_PIN
  808. #define SDS011_TX_PIN 12
  809. #endif
  810. //------------------------------------------------------------------------------
  811. // SenseAir CO2 sensor
  812. // Enable support by passing SENSEAIR_SUPPORT=1 build flag
  813. //------------------------------------------------------------------------------
  814. #ifndef SENSEAIR_SUPPORT
  815. #define SENSEAIR_SUPPORT 0
  816. #endif
  817. #ifndef SENSEAIR_RX_PIN
  818. #define SENSEAIR_RX_PIN 0
  819. #endif
  820. #ifndef SENSEAIR_TX_PIN
  821. #define SENSEAIR_TX_PIN 2
  822. #endif
  823. //------------------------------------------------------------------------------
  824. // SHT3X I2C (Wemos) temperature & humidity sensor
  825. // Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
  826. //------------------------------------------------------------------------------
  827. #ifndef SHT3X_I2C_SUPPORT
  828. #define SHT3X_I2C_SUPPORT 0
  829. #endif
  830. #ifndef SHT3X_I2C_ADDRESS
  831. #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto
  832. #endif
  833. //------------------------------------------------------------------------------
  834. // SI7021 temperature & humidity sensor
  835. // Enable support by passing SI7021_SUPPORT=1 build flag
  836. //------------------------------------------------------------------------------
  837. #ifndef SI7021_SUPPORT
  838. #define SI7021_SUPPORT 0
  839. #endif
  840. #ifndef SI7021_ADDRESS
  841. #define SI7021_ADDRESS 0x00 // 0x00 means auto
  842. #endif
  843. //------------------------------------------------------------------------------
  844. // HDC1080 / 831R temperature & humidity sensor
  845. // Enable support by passing HDC1080_SUPPORT=1 build flag
  846. //------------------------------------------------------------------------------
  847. #ifndef HDC1080_SUPPORT
  848. #define HDC1080_SUPPORT 0
  849. #endif
  850. #ifndef HDC1080_ADDRESS
  851. #define HDC1080_ADDRESS 0x00 // 0x00 means auto
  852. #endif
  853. //------------------------------------------------------------------------------
  854. // Sonar
  855. // Enable support by passing SONAR_SUPPORT=1 build flag
  856. //------------------------------------------------------------------------------
  857. #ifndef SONAR_SUPPORT
  858. #define SONAR_SUPPORT 0
  859. #endif
  860. #ifndef SONAR_TRIGGER
  861. #define SONAR_TRIGGER 12 // GPIO for the trigger pin (output)
  862. #endif
  863. #ifndef SONAR_ECHO
  864. #define SONAR_ECHO 14 // GPIO for the echo pin (input)
  865. #endif
  866. #ifndef SONAR_MAX_DISTANCE
  867. #define SONAR_MAX_DISTANCE MAX_SENSOR_DISTANCE // Max sensor distance in cm
  868. #endif
  869. #ifndef SONAR_ITERATIONS
  870. #define SONAR_ITERATIONS 5 // Number of iterations to ping for
  871. #endif // error correction.
  872. //------------------------------------------------------------------------------
  873. // T6613 CO2 sensor
  874. // Enable support by passing T6613_SUPPORT=1 build flag
  875. //------------------------------------------------------------------------------
  876. #ifndef T6613_SUPPORT
  877. #define T6613_SUPPORT 0
  878. #endif
  879. #ifndef T6613_RX_PIN
  880. #define T6613_RX_PIN 4
  881. #endif
  882. #ifndef T6613_TX_PIN
  883. #define T6613_TX_PIN 5
  884. #endif
  885. //------------------------------------------------------------------------------
  886. // TMP3X analog temperature sensor
  887. // Enable support by passing TMP3X_SUPPORT=1 build flag
  888. //------------------------------------------------------------------------------
  889. #ifndef TMP3X_SUPPORT
  890. #define TMP3X_SUPPORT 0
  891. #endif
  892. #ifndef TMP3X_TYPE
  893. #define TMP3X_TYPE TMP3X_TMP35
  894. #endif
  895. //------------------------------------------------------------------------------
  896. // V9261F based power sensor
  897. // Enable support by passing SI7021_SUPPORT=1 build flag
  898. //------------------------------------------------------------------------------
  899. #ifndef V9261F_SUPPORT
  900. #define V9261F_SUPPORT 0
  901. #endif
  902. #ifndef V9261F_PIN
  903. #define V9261F_PIN 2 // TX pin from the V9261F
  904. #endif
  905. #ifndef V9261F_PIN_INVERSE
  906. #define V9261F_PIN_INVERSE 1 // Signal is inverted
  907. #endif
  908. #define V9261F_SYNC_INTERVAL 600 // Sync signal length (ms)
  909. #define V9261F_BAUDRATE 4800 // UART baudrate
  910. // Default ratios
  911. #define V9261F_CURRENT_FACTOR 79371434.0
  912. #define V9261F_VOLTAGE_FACTOR 4160651.0
  913. #define V9261F_POWER_FACTOR 153699.0
  914. #define V9261F_RPOWER_FACTOR V9261F_CURRENT_FACTOR
  915. //------------------------------------------------------------------------------
  916. // VEML6075 based power sensor
  917. // Enable support by passing VEML6075_SUPPORT=1 build flag
  918. //------------------------------------------------------------------------------
  919. #ifndef VEML6075_SUPPORT
  920. #define VEML6075_SUPPORT 0
  921. #endif
  922. #ifndef VEML6075_INTEGRATION_TIME
  923. #define VEML6075_INTEGRATION_TIME VEML6075::IT_100MS // The time, in milliseconds, allocated for a single
  924. #endif // measurement. A longer timing budget allows for more
  925. // accurate results at the cost of power.
  926. #ifndef VEML6075_DYNAMIC_MODE
  927. #define VEML6075_DYNAMIC_MODE VEML6075::DYNAMIC_NORMAL // The dynamic mode can either be normal or high. In high
  928. #endif // dynamic mode, the resolution increases by about two
  929. // times.
  930. //------------------------------------------------------------------------------
  931. // VL53L1X
  932. // Enable support by passing VL53L1X_SUPPORT=1 build flag
  933. //------------------------------------------------------------------------------
  934. #ifndef VL53L1X_SUPPORT
  935. #define VL53L1X_SUPPORT 0
  936. #endif
  937. #ifndef VL53L1X_I2C_ADDRESS
  938. #define VL53L1X_I2C_ADDRESS 0x00 // 0x00 means auto
  939. #endif
  940. #ifndef VL53L1X_DISTANCE_MODE
  941. #define VL53L1X_DISTANCE_MODE VL53L1X::Long // The distance mode of the sensor. Can be one of
  942. #endif // `VL53L1X::Short`, `VL53L1X::Medium`, or `VL53L1X::Long.
  943. // Shorter distance modes are less affected by ambient light
  944. // but have lower maximum ranges, especially in the dark.
  945. #ifndef VL53L1X_MEASUREMENT_TIMING_BUDGET
  946. #define VL53L1X_MEASUREMENT_TIMING_BUDGET 140000 // The time, in microseconds, allocated for a single
  947. // measurement. A longer timing budget allows for more
  948. // accurate at the cost of power. The minimum budget is
  949. // 20 ms (20000 us) in short distance mode and 33 ms for
  950. // medium and long distance modes.
  951. #endif
  952. #ifndef VL53L1X_INTER_MEASUREMENT_PERIOD
  953. #define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how
  954. #endif // often the sensor takes a measurement.
  955. //------------------------------------------------------------------------------
  956. // MAX6675
  957. // Enable support by passing MAX6675_SUPPORT=1 build flag
  958. //------------------------------------------------------------------------------
  959. #ifndef MAX6675_CS_PIN
  960. #define MAX6675_CS_PIN 13
  961. #endif
  962. #ifndef MAX6675_SO_PIN
  963. #define MAX6675_SO_PIN 12
  964. #endif
  965. #ifndef MAX6675_SCK_PIN
  966. #define MAX6675_SCK_PIN 14
  967. #endif
  968. //------------------------------------------------------------------------------
  969. // EZOPH pH meter
  970. // Enable support by passing EZOPH_SUPPORT=1 build flag
  971. //------------------------------------------------------------------------------
  972. #ifndef EZOPH_SUPPORT
  973. #define EZOPH_SUPPORT 0
  974. #endif
  975. #ifndef EZOPH_RX_PIN
  976. #define EZOPH_RX_PIN 13 // Software serial RX GPIO
  977. #endif
  978. #ifndef EZOPH_TX_PIN
  979. #define EZOPH_TX_PIN 15 // Software serial TX GPIO
  980. #endif
  981. #ifndef EZOPH_SYNC_INTERVAL
  982. #define EZOPH_SYNC_INTERVAL 1000 // Amount of time (in ms) sync new readings.
  983. #endif
  984. // -----------------------------------------------------------------------------
  985. // ADE7953 Shelly Sensor
  986. // Enable support by passing ADE7953_SUPPORT=1 build flag
  987. // -----------------------------------------------------------------------------
  988. #ifndef ADE7953_SUPPORT
  989. #define ADE7953_SUPPORT 0
  990. #endif
  991. #ifndef ADE7953_ADDRESS
  992. #define ADE7953_ADDRESS 0x38
  993. #endif
  994. // -----------------------------------------------------------------------------
  995. // SI1145 UV Sensor over I2C
  996. // Enable support by passing SI1145_SUPPORT=1 build flag
  997. // -----------------------------------------------------------------------------
  998. #ifndef SI1145_SUPPORT
  999. #define SI1145_SUPPORT 0
  1000. #endif
  1001. #ifndef SI1145_ADDRESS
  1002. #define SI1145_ADDRESS 0x60
  1003. #endif
  1004. // -----------------------------------------------------------------------------
  1005. // ADC
  1006. // -----------------------------------------------------------------------------
  1007. // Default ADC mode is to monitor internal power supply
  1008. #ifndef ADC_MODE_VALUE
  1009. #define ADC_MODE_VALUE ADC_VCC
  1010. #endif
  1011. // -----------------------------------------------------------------------------
  1012. // I2C
  1013. // -----------------------------------------------------------------------------
  1014. #ifndef I2C_SUPPORT
  1015. #define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
  1016. #endif
  1017. #define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
  1018. #ifndef I2C_SDA_PIN
  1019. #define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4, using Arduino Core variant definition as default)
  1020. #endif
  1021. #ifndef I2C_SCL_PIN
  1022. #define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14, using Arduino Core variant definition as default)
  1023. #endif
  1024. #ifndef I2C_CLOCK_STRETCH_TIME
  1025. #define I2C_CLOCK_STRETCH_TIME 200UL // BRZO clock stretch time
  1026. #endif
  1027. #ifndef I2C_SCL_FREQUENCY
  1028. #define I2C_SCL_FREQUENCY 1000UL // BRZO SCL frequency
  1029. #endif
  1030. #ifndef I2C_CLEAR_BUS
  1031. #define I2C_CLEAR_BUS 0 // Clear I2C bus on boot
  1032. #endif
  1033. #ifndef I2C_PERFORM_SCAN
  1034. #define I2C_PERFORM_SCAN 1 // Perform a bus scan on boot
  1035. #endif
  1036. // =============================================================================
  1037. // Configuration helpers
  1038. // =============================================================================
  1039. // I2C support when sensor needs it
  1040. #if ( ADE7953_SUPPORT || \
  1041. AM2320_SUPPORT || \
  1042. BH1750_SUPPORT || \
  1043. BMP180_SUPPORT || \
  1044. BMX280_SUPPORT || \
  1045. EMON_ADC121_SUPPORT || \
  1046. EMON_ADS1X15_SUPPORT || \
  1047. SHT3X_I2C_SUPPORT || \
  1048. SI1145_SUPPORT || \
  1049. SI7021_SUPPORT || \
  1050. VEML6075_SUPPORT || \
  1051. VL53L1X_SUPPORT || \
  1052. HDC1080_SUPPORT \
  1053. )
  1054. #undef I2C_SUPPORT
  1055. #define I2C_SUPPORT 1
  1056. #endif
  1057. // Can't have ADC reading something else
  1058. #if ( ANALOG_SUPPORT || \
  1059. EMON_ANALOG_SUPPORT || \
  1060. GUVAS12SD_SUPPORT || \
  1061. LDR_SUPPORT || \
  1062. MICS2710_SUPPORT || \
  1063. MICS5525_SUPPORT || \
  1064. NTC_SUPPORT || \
  1065. TMP3X_SUPPORT \
  1066. )
  1067. #undef ADC_MODE_VALUE
  1068. #define ADC_MODE_VALUE ADC_TOUT
  1069. #endif
  1070. // Provide generic way to detect sensor presence
  1071. #ifndef SENSOR_SUPPORT
  1072. #define SENSOR_SUPPORT ( \
  1073. ADE7953_SUPPORT || \
  1074. AM2320_SUPPORT || \
  1075. ANALOG_SUPPORT || \
  1076. BH1750_SUPPORT || \
  1077. BMP180_SUPPORT || \
  1078. BMX280_SUPPORT || \
  1079. CSE7766_SUPPORT || \
  1080. DALLAS_SUPPORT || \
  1081. DHT_SUPPORT || \
  1082. DIGITAL_SUPPORT || \
  1083. ECH1560_SUPPORT || \
  1084. EMON_ADC121_SUPPORT || \
  1085. EMON_ADS1X15_SUPPORT || \
  1086. EMON_ANALOG_SUPPORT || \
  1087. EVENTS_SUPPORT || \
  1088. EZOPH_SUPPORT || \
  1089. GEIGER_SUPPORT || \
  1090. GUVAS12SD_SUPPORT || \
  1091. HLW8012_SUPPORT || \
  1092. LDR_SUPPORT || \
  1093. MAX6675_SUPPORT || \
  1094. MHZ19_SUPPORT || \
  1095. MICS2710_SUPPORT || \
  1096. MICS5525_SUPPORT || \
  1097. NTC_SUPPORT || \
  1098. PMSX003_SUPPORT || \
  1099. PULSEMETER_SUPPORT || \
  1100. PZEM004T_SUPPORT || \
  1101. SDS011_SUPPORT || \
  1102. SENSEAIR_SUPPORT || \
  1103. SHT3X_I2C_SUPPORT || \
  1104. SI1145_SUPPORT || \
  1105. SI7021_SUPPORT || \
  1106. SONAR_SUPPORT || \
  1107. T6613_SUPPORT || \
  1108. THERMOSTAT_SUPPORT || \
  1109. TMP3X_SUPPORT || \
  1110. V9261F_SUPPORT || \
  1111. VEML6075_SUPPORT || \
  1112. VL53L1X_SUPPORT || \
  1113. HDC1080_SUPPORT || \
  1114. PZEM004TV30_SUPPORT \
  1115. )
  1116. #endif