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.

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