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.

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