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.

822 lines
27 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
7 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 6 // 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 12 // 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. #define SENSOR_PUBLISH_ADDRESSES 0 // Publish sensor addresses
  30. #define SENSOR_ADDRESS_TOPIC "address" // Topic to publish sensor addresses
  31. #ifndef SENSOR_TEMPERATURE_UNITS
  32. #define SENSOR_TEMPERATURE_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  33. #endif
  34. #ifndef SENSOR_ENERGY_UNITS
  35. #define SENSOR_ENERGY_UNITS ENERGY_JOULES // Energy units (ENERGY_JOULES | ENERGY_KWH)
  36. #endif
  37. #ifndef SENSOR_POWER_UNITS
  38. #define SENSOR_POWER_UNITS POWER_WATTS // Power units (POWER_WATTS | POWER_KILOWATTS)
  39. #endif
  40. // =============================================================================
  41. // Specific data for each sensor
  42. // =============================================================================
  43. //------------------------------------------------------------------------------
  44. // AM2320 Humidity & Temperature sensor over I2C
  45. // Enable support by passing AM2320_SUPPORT=1 build flag
  46. //------------------------------------------------------------------------------
  47. #ifndef AM2320_SUPPORT
  48. #define AM2320_SUPPORT 0
  49. #endif
  50. #ifndef AM2320_ADDRESS
  51. #define AM2320_ADDRESS 0x00 // 0x00 means auto
  52. #endif
  53. //------------------------------------------------------------------------------
  54. // Analog sensor
  55. // Enable support by passing ANALOG_SUPPORT=1 build flag
  56. //--------------------------------------------------------------------------------
  57. #ifndef ANALOG_SUPPORT
  58. #define ANALOG_SUPPORT 0
  59. #endif
  60. #ifndef ANALOG_SAMPLES
  61. #define ANALOG_SAMPLES 10 // Number of samples
  62. #endif
  63. #ifndef ANALOG_DELAY
  64. #define ANALOG_DELAY 0 // Delay between samples in micros
  65. #endif
  66. //------------------------------------------------------------------------------
  67. // BH1750
  68. // Enable support by passing BH1750_SUPPORT=1 build flag
  69. // http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf
  70. //------------------------------------------------------------------------------
  71. #ifndef BH1750_SUPPORT
  72. #define BH1750_SUPPORT 0
  73. #endif
  74. #ifndef BH1750_ADDRESS
  75. #define BH1750_ADDRESS 0x00 // 0x00 means auto
  76. #endif
  77. #define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE
  78. //------------------------------------------------------------------------------
  79. // BME280/BMP280
  80. // Enable support by passing BMX280_SUPPORT=1 build flag
  81. //------------------------------------------------------------------------------
  82. #ifndef BMX280_SUPPORT
  83. #define BMX280_SUPPORT 0
  84. #endif
  85. #ifndef BMX280_ADDRESS
  86. #define BMX280_ADDRESS 0x00 // 0x00 means auto
  87. #endif
  88. #define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode
  89. #define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms
  90. // 3 for 250ms, 4 for 500ms, 5 for 1000ms
  91. // 6 for 10ms, 7 for 20ms
  92. #define BMX280_FILTER 0 // 0 for OFF, 1 for 2 values, 2 for 4 values, 3 for 8 values and 4 for 16 values
  93. #define BMX280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  94. #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
  95. #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  96. //------------------------------------------------------------------------------
  97. // Dallas OneWire temperature sensors
  98. // Enable support by passing DALLAS_SUPPORT=1 build flag
  99. //------------------------------------------------------------------------------
  100. #ifndef DALLAS_SUPPORT
  101. #define DALLAS_SUPPORT 0
  102. #endif
  103. #ifndef DALLAS_PIN
  104. #define DALLAS_PIN 14
  105. #endif
  106. #define DALLAS_RESOLUTION 9 // Not used atm
  107. #define DALLAS_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds
  108. //------------------------------------------------------------------------------
  109. // DHTXX temperature/humidity sensor
  110. // Enable support by passing DHT_SUPPORT=1 build flag
  111. //------------------------------------------------------------------------------
  112. #ifndef DHT_SUPPORT
  113. #define DHT_SUPPORT 0
  114. #endif
  115. #ifndef DHT_PIN
  116. #define DHT_PIN 14
  117. #endif
  118. #ifndef DHT_TYPE
  119. #define DHT_TYPE DHT_CHIP_DHT22
  120. #endif
  121. //------------------------------------------------------------------------------
  122. // CSE7766 based power sensor
  123. // Enable support by passing CSE7766_SUPPORT=1 build flag
  124. //------------------------------------------------------------------------------
  125. #ifndef CSE7766_SUPPORT
  126. #define CSE7766_SUPPORT 0
  127. #endif
  128. #ifndef CSE7766_PIN
  129. #define CSE7766_PIN 1 // TX pin from the CSE7766
  130. #endif
  131. #ifndef CSE7766_PIN_INVERSE
  132. #define CSE7766_PIN_INVERSE 0 // Signal is inverted
  133. #endif
  134. #define CSE7766_SYNC_INTERVAL 300 // Safe time between transmissions (ms)
  135. #define CSE7766_BAUDRATE 4800 // UART baudrate
  136. #define CSE7766_V1R 1.0 // 1mR current resistor
  137. #define CSE7766_V2R 1.0 // 1M voltage resistor
  138. //------------------------------------------------------------------------------
  139. // Digital sensor
  140. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  141. //------------------------------------------------------------------------------
  142. #ifndef DIGITAL_SUPPORT
  143. #define DIGITAL_SUPPORT 0
  144. #endif
  145. #ifndef DIGITAL_PIN
  146. #define DIGITAL_PIN 2
  147. #endif
  148. #ifndef DIGITAL_PIN_MODE
  149. #define DIGITAL_PIN_MODE INPUT_PULLUP
  150. #endif
  151. #ifndef DIGITAL_DEFAULT_STATE
  152. #define DIGITAL_DEFAULT_STATE 1
  153. #endif
  154. //------------------------------------------------------------------------------
  155. // ECH1560 based power sensor
  156. // Enable support by passing ECH1560_SUPPORT=1 build flag
  157. //------------------------------------------------------------------------------
  158. #ifndef ECH1560_SUPPORT
  159. #define ECH1560_SUPPORT 0
  160. #endif
  161. #ifndef ECH1560_CLK_PIN
  162. #define ECH1560_CLK_PIN 4 // CLK pin for the ECH1560
  163. #endif
  164. #ifndef ECH1560_MISO_PIN
  165. #define ECH1560_MISO_PIN 5 // MISO pin for the ECH1560
  166. #endif
  167. #ifndef ECH1560_INVERTED
  168. #define ECH1560_INVERTED 0 // Signal is inverted
  169. #endif
  170. //------------------------------------------------------------------------------
  171. // Energy Monitor general settings
  172. //------------------------------------------------------------------------------
  173. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  174. #define EMON_MAX_TIME 250 // Max time in ms to sample
  175. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  176. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  177. #define EMON_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  178. #define EMON_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  179. #define EMON_REPORT_CURRENT 0 // Report current
  180. #define EMON_REPORT_POWER 1 // Report power
  181. #define EMON_REPORT_ENERGY 1 // Report energy
  182. #define EMON_PROVIDER_ANALOG 1
  183. #define EMON_PROVIDER_ADC121 2
  184. #define EMON_PROVIDER_ADS1X15 3
  185. //------------------------------------------------------------------------------
  186. // Energy Monitor based on ADC121
  187. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  188. //------------------------------------------------------------------------------
  189. #ifndef EMON_ADC121_SUPPORT
  190. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  191. #endif
  192. #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
  193. //------------------------------------------------------------------------------
  194. // Energy Monitor based on ADS1X15
  195. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  196. //------------------------------------------------------------------------------
  197. #ifndef EMON_ADS1X15_SUPPORT
  198. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  199. #endif
  200. #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
  201. #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
  202. #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
  203. #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
  204. //------------------------------------------------------------------------------
  205. // Energy Monitor based on interval analog GPIO
  206. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  207. //------------------------------------------------------------------------------
  208. #ifndef EMON_ANALOG_SUPPORT
  209. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  210. #endif
  211. //------------------------------------------------------------------------------
  212. // Counter sensor
  213. // Enable support by passing EVENTS_SUPPORT=1 build flag
  214. //------------------------------------------------------------------------------
  215. #ifndef EVENTS_SUPPORT
  216. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  217. #endif
  218. #ifndef EVENTS_TRIGGER
  219. #define EVENTS_TRIGGER 1 // 1 to trigger callback on events,
  220. // 0 to only count them and report periodically
  221. #endif
  222. #ifndef EVENTS_PIN
  223. #define EVENTS_PIN 2 // GPIO to monitor
  224. #endif
  225. #ifndef EVENTS_PIN_MODE
  226. #define EVENTS_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  227. #endif
  228. #ifndef EVENTS_INTERRUPT_MODE
  229. #define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  230. #endif
  231. #define EVENTS_DEBOUNCE 50 // Do not register events within less than 50 millis
  232. //------------------------------------------------------------------------------
  233. // Geiger sensor
  234. // Enable support by passing GEIGER_SUPPORT=1 build flag
  235. //------------------------------------------------------------------------------
  236. #ifndef GEIGER_SUPPORT
  237. #define GEIGER_SUPPORT 0 // Do not build with geiger support by default
  238. #endif
  239. #ifndef GEIGER_PIN
  240. #define GEIGER_PIN 5 // GPIO to monitor "D1" => "GPIO5"
  241. #endif
  242. #ifndef GEIGER_PIN_MODE
  243. #define GEIGER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  244. #endif
  245. #ifndef GEIGER_INTERRUPT_MODE
  246. #define GEIGER_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  247. #endif
  248. #define GEIGER_DEBOUNCE 25 // Do not register events within less than 25 millis.
  249. // Value derived here: Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter
  250. #define GEIGER_CPM2SIEVERT 240 // CPM to µSievert per hour conversion factor
  251. // Typically the literature uses the invers, but I find an integer type more convienient.
  252. #define GEIGER_REPORT_SIEVERTS 1 // Enabler for local dose rate reports in µSv/h
  253. #define GEIGER_REPORT_CPM 1 // Enabler for local dose rate reports in counts per minute
  254. //------------------------------------------------------------------------------
  255. // GUVAS12SD UV Sensor (analog)
  256. // Enable support by passing GUVAS12SD_SUPPORT=1 build flag
  257. //------------------------------------------------------------------------------
  258. #ifndef GUVAS12SD_SUPPORT
  259. #define GUVAS12SD_SUPPORT 0
  260. #endif
  261. #ifndef GUVAS12SD_PIN
  262. #define GUVAS12SD_PIN 14
  263. #endif
  264. //------------------------------------------------------------------------------
  265. // HLW8012 Energy monitor IC
  266. // Enable support by passing HLW8012_SUPPORT=1 build flag
  267. //------------------------------------------------------------------------------
  268. #ifndef HLW8012_SUPPORT
  269. #define HLW8012_SUPPORT 0
  270. #endif
  271. #ifndef HLW8012_SEL_PIN
  272. #define HLW8012_SEL_PIN 5
  273. #endif
  274. #ifndef HLW8012_CF1_PIN
  275. #define HLW8012_CF1_PIN 13
  276. #endif
  277. #ifndef HLW8012_CF_PIN
  278. #define HLW8012_CF_PIN 14
  279. #endif
  280. #ifndef HLW8012_SEL_CURRENT
  281. #define HLW8012_SEL_CURRENT HIGH // SEL pin to HIGH to measure current
  282. #endif
  283. #ifndef HLW8012_CURRENT_R
  284. #define HLW8012_CURRENT_R 0.001 // Current resistor
  285. #endif
  286. #ifndef HLW8012_VOLTAGE_R_UP
  287. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Upstream voltage resistor
  288. #endif
  289. #ifndef HLW8012_VOLTAGE_R_DOWN
  290. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Downstream voltage resistor
  291. #endif
  292. #ifndef HLW8012_CURRENT_RATIO
  293. #define HLW8012_CURRENT_RATIO 0 // Set to 0 to use factory defaults
  294. #endif
  295. #ifndef HLW8012_VOLTAGE_RATIO
  296. #define HLW8012_VOLTAGE_RATIO 0 // Set to 0 to use factory defaults
  297. #endif
  298. #ifndef HLW8012_POWER_RATIO
  299. #define HLW8012_POWER_RATIO 0 // Set to 0 to use factory defaults
  300. #endif
  301. #ifndef HLW8012_USE_INTERRUPTS
  302. #define HLW8012_USE_INTERRUPTS 1 // Use interrupts to trap HLW8012 signals
  303. #endif
  304. #ifndef HLW8012_INTERRUPT_ON
  305. #define HLW8012_INTERRUPT_ON CHANGE // When to trigger the interrupt
  306. // Use CHANGE for HLW8012
  307. // Use FALLING for BL0937 / HJL0
  308. #endif
  309. //------------------------------------------------------------------------------
  310. // MHZ19 CO2 sensor
  311. // Enable support by passing MHZ19_SUPPORT=1 build flag
  312. //------------------------------------------------------------------------------
  313. #ifndef MHZ19_SUPPORT
  314. #define MHZ19_SUPPORT 0
  315. #endif
  316. #ifndef MHZ19_RX_PIN
  317. #define MHZ19_RX_PIN 13
  318. #endif
  319. #ifndef MHZ19_TX_PIN
  320. #define MHZ19_TX_PIN 15
  321. #endif
  322. //------------------------------------------------------------------------------
  323. // NTC sensor
  324. // Enable support by passing NTC_SUPPORT=1 build flag
  325. //--------------------------------------------------------------------------------
  326. #ifndef NTC_SUPPORT
  327. #define NTC_SUPPORT 0
  328. #endif
  329. #ifndef NTC_SAMPLES
  330. #define NTC_SAMPLES 10 // Number of samples
  331. #endif
  332. #ifndef NTC_DELAY
  333. #define NTC_DELAY 0 // Delay between samples in micros
  334. #endif
  335. #ifndef NTC_R_UP
  336. #define NTC_R_UP 0 // Resistor upstream, set to 0 if none
  337. #endif
  338. #ifndef NTC_R_DOWN
  339. #define NTC_R_DOWN 10000 // Resistor downstream, set to 0 if none
  340. #endif
  341. #ifndef NTC_T0
  342. #define NTC_T0 298.15 // 25 Celsius
  343. #endif
  344. #ifndef NTC_R0
  345. #define NTC_R0 10000 // Resistance at T0
  346. #endif
  347. #ifndef NTC_BETA
  348. #define NTC_BETA 3977 // Beta coeficient
  349. #endif
  350. //------------------------------------------------------------------------------
  351. // SenseAir CO2 sensor
  352. // Enable support by passing SENSEAIR_SUPPORT=1 build flag
  353. //------------------------------------------------------------------------------
  354. #ifndef SENSEAIR_SUPPORT
  355. #define SENSEAIR_SUPPORT 0
  356. #endif
  357. #ifndef SENSEAIR_RX_PIN
  358. #define SENSEAIR_RX_PIN 0
  359. #endif
  360. #ifndef SENSEAIR_TX_PIN
  361. #define SENSEAIR_TX_PIN 2
  362. #endif
  363. //------------------------------------------------------------------------------
  364. // Particle Monitor based on Plantower PMS
  365. // Enable support by passing PMSX003_SUPPORT=1 build flag
  366. //------------------------------------------------------------------------------
  367. #ifndef PMSX003_SUPPORT
  368. #define PMSX003_SUPPORT 0
  369. #endif
  370. #ifndef PMS_TYPE
  371. #define PMS_TYPE PMS_TYPE_X003
  372. #endif
  373. // You can enable smart sleep (read 6-times then sleep on 24-reading-cycles) to extend PMS sensor's life.
  374. // Otherwise the default lifetime of PMS sensor is about 8000-hours/1-years.
  375. // The PMS's fan will stop working on sleeping cycle, and will wake up on reading cycle.
  376. #ifndef PMS_SMART_SLEEP
  377. #define PMS_SMART_SLEEP 0
  378. #endif
  379. #ifndef PMS_USE_SOFT
  380. #define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0
  381. #endif
  382. #ifndef PMS_RX_PIN
  383. #define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1)
  384. #endif
  385. #ifndef PMS_TX_PIN
  386. #define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1)
  387. #endif
  388. #ifndef PMS_HW_PORT
  389. #define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0)
  390. #endif
  391. //------------------------------------------------------------------------------
  392. // PZEM004T based power monitor
  393. // Enable support by passing PZEM004T_SUPPORT=1 build flag
  394. //------------------------------------------------------------------------------
  395. #ifndef PZEM004T_SUPPORT
  396. #define PZEM004T_SUPPORT 0
  397. #endif
  398. #ifndef PZEM004T_USE_SOFT
  399. #define PZEM004T_USE_SOFT 0 // Software serial is not working atm, use hardware serial
  400. #endif
  401. #ifndef PZEM004T_RX_PIN
  402. #define PZEM004T_RX_PIN 13 // Software serial RX GPIO (if PZEM004T_USE_SOFT == 1)
  403. #endif
  404. #ifndef PZEM004T_TX_PIN
  405. #define PZEM004T_TX_PIN 15 // Software serial TX GPIO (if PZEM004T_USE_SOFT == 1)
  406. #endif
  407. #ifndef PZEM004T_HW_PORT
  408. #define PZEM004T_HW_PORT Serial // Hardware serial port (if PZEM004T_USE_SOFT == 0)
  409. #endif
  410. //------------------------------------------------------------------------------
  411. // SHT3X I2C (Wemos) temperature & humidity sensor
  412. // Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
  413. //------------------------------------------------------------------------------
  414. #ifndef SHT3X_I2C_SUPPORT
  415. #define SHT3X_I2C_SUPPORT 0
  416. #endif
  417. #ifndef SHT3X_I2C_ADDRESS
  418. #define SHT3X_I2C_ADDRESS 0x00 // 0x00 means auto
  419. #endif
  420. //------------------------------------------------------------------------------
  421. // SI7021 temperature & humidity sensor
  422. // Enable support by passing SI7021_SUPPORT=1 build flag
  423. //------------------------------------------------------------------------------
  424. #ifndef SI7021_SUPPORT
  425. #define SI7021_SUPPORT 0
  426. #endif
  427. #ifndef SI7021_ADDRESS
  428. #define SI7021_ADDRESS 0x00 // 0x00 means auto
  429. #endif
  430. //------------------------------------------------------------------------------
  431. // Sonar
  432. // Enable support by passing SONAR_SUPPORT=1 build flag
  433. //------------------------------------------------------------------------------
  434. #ifndef SONAR_SUPPORT
  435. #define SONAR_SUPPORT 0
  436. #endif
  437. #ifndef SONAR_TRIGGER
  438. #define SONAR_TRIGGER 12 // GPIO for the trigger pin (output)
  439. #endif
  440. #ifndef SONAR_ECHO
  441. #define SONAR_ECHO 14 // GPIO for the echo pin (input)
  442. #endif
  443. #ifndef SONAR_MAX_DISTANCE
  444. #define SONAR_MAX_DISTANCE MAX_SENSOR_DISTANCE // Max sensor distance in cm
  445. #endif
  446. #ifndef SONAR_ITERATIONS
  447. #define SONAR_ITERATIONS 5 // Number of iterations to ping for
  448. #endif // error correction.
  449. //------------------------------------------------------------------------------
  450. // TMP3X analog temperature sensor
  451. // Enable support by passing TMP3X_SUPPORT=1 build flag
  452. //------------------------------------------------------------------------------
  453. #ifndef TMP3X_SUPPORT
  454. #define TMP3X_SUPPORT 0
  455. #endif
  456. #ifndef TMP3X_TYPE
  457. #define TMP3X_TYPE TMP3X_TMP35
  458. #endif
  459. //------------------------------------------------------------------------------
  460. // V9261F based power sensor
  461. // Enable support by passing SI7021_SUPPORT=1 build flag
  462. //------------------------------------------------------------------------------
  463. #ifndef V9261F_SUPPORT
  464. #define V9261F_SUPPORT 0
  465. #endif
  466. #ifndef V9261F_PIN
  467. #define V9261F_PIN 2 // TX pin from the V9261F
  468. #endif
  469. #ifndef V9261F_PIN_INVERSE
  470. #define V9261F_PIN_INVERSE 1 // Signal is inverted
  471. #endif
  472. #define V9261F_SYNC_INTERVAL 600 // Sync signal length (ms)
  473. #define V9261F_BAUDRATE 4800 // UART baudrate
  474. // Default ratios
  475. #define V9261F_CURRENT_FACTOR 79371434.0
  476. #define V9261F_VOLTAGE_FACTOR 4160651.0
  477. #define V9261F_POWER_FACTOR 153699.0
  478. #define V9261F_RPOWER_FACTOR V9261F_CURRENT_FACTOR
  479. // =============================================================================
  480. // Sensor helpers configuration - can't move to dependencies.h
  481. // =============================================================================
  482. #ifndef SENSOR_SUPPORT
  483. #define SENSOR_SUPPORT ( \
  484. AM2320_SUPPORT || \
  485. ANALOG_SUPPORT || \
  486. BH1750_SUPPORT || \
  487. BMX280_SUPPORT || \
  488. CSE7766_SUPPORT || \
  489. DALLAS_SUPPORT || \
  490. DHT_SUPPORT || \
  491. DIGITAL_SUPPORT || \
  492. ECH1560_SUPPORT || \
  493. EMON_ADC121_SUPPORT || \
  494. EMON_ADS1X15_SUPPORT || \
  495. EMON_ANALOG_SUPPORT || \
  496. EVENTS_SUPPORT || \
  497. GEIGER_SUPPORT || \
  498. GUVAS12SD_SUPPORT || \
  499. HLW8012_SUPPORT || \
  500. MHZ19_SUPPORT || \
  501. NTC_SUPPORT || \
  502. SENSEAIR_SUPPORT || \
  503. PMSX003_SUPPORT || \
  504. PZEM004T_SUPPORT || \
  505. SHT3X_I2C_SUPPORT || \
  506. SI7021_SUPPORT || \
  507. SONAR_SUPPORT || \
  508. TMP3X_SUPPORT || \
  509. V9261F_SUPPORT \
  510. )
  511. #endif
  512. // -----------------------------------------------------------------------------
  513. // ADC
  514. // -----------------------------------------------------------------------------
  515. // Default ADC mode is to monitor internal power supply
  516. #ifndef ADC_MODE_VALUE
  517. #define ADC_MODE_VALUE ADC_VCC
  518. #endif
  519. // -----------------------------------------------------------------------------
  520. // I2C
  521. // -----------------------------------------------------------------------------
  522. #ifndef I2C_SUPPORT
  523. #define I2C_SUPPORT 0 // I2C enabled (1.98Kb)
  524. #endif
  525. #define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire
  526. #ifndef I2C_SDA_PIN
  527. #define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4)
  528. #endif
  529. #ifndef I2C_SCL_PIN
  530. #define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14)
  531. #endif
  532. #define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
  533. #define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
  534. #define I2C_CLEAR_BUS 0 // Clear I2C bus on boot
  535. #define I2C_PERFORM_SCAN 1 // Perform a bus scan on boot
  536. //--------------------------------------------------------------------------------
  537. // Class loading
  538. //--------------------------------------------------------------------------------
  539. #if SENSOR_SUPPORT
  540. #if SENSOR_DEBUG
  541. #include "../config/debug.h"
  542. #endif
  543. #include "../sensors/BaseSensor.h"
  544. #if AM2320_SUPPORT
  545. #include "../sensors/AM2320Sensor.h"
  546. #endif
  547. #if ANALOG_SUPPORT
  548. #include "../sensors/AnalogSensor.h"
  549. #endif
  550. #if BH1750_SUPPORT
  551. #include "../sensors/BH1750Sensor.h"
  552. #endif
  553. #if BMX280_SUPPORT
  554. #include "../sensors/BMX280Sensor.h"
  555. #endif
  556. #if CSE7766_SUPPORT
  557. #include <SoftwareSerial.h>
  558. #include "../sensors/CSE7766Sensor.h"
  559. #endif
  560. #if DALLAS_SUPPORT
  561. #include <OneWire.h>
  562. #include "../sensors/DallasSensor.h"
  563. #endif
  564. #if DHT_SUPPORT
  565. #include "../sensors/DHTSensor.h"
  566. #endif
  567. #if DIGITAL_SUPPORT
  568. #include "../sensors/DigitalSensor.h"
  569. #endif
  570. #if ECH1560_SUPPORT
  571. #include "../sensors/ECH1560Sensor.h"
  572. #endif
  573. #if EMON_ADC121_SUPPORT
  574. #include "../sensors/EmonADC121Sensor.h"
  575. #endif
  576. #if EMON_ADS1X15_SUPPORT
  577. #include "../sensors/EmonADS1X15Sensor.h"
  578. #endif
  579. #if EMON_ANALOG_SUPPORT
  580. #include "../sensors/EmonAnalogSensor.h"
  581. #endif
  582. #if EVENTS_SUPPORT
  583. #include "../sensors/EventSensor.h"
  584. #endif
  585. #if GEIGER_SUPPORT
  586. #include "../sensors/GeigerSensor.h" // The main file for geiger counting module
  587. #endif
  588. #if GUVAS12SD_SUPPORT
  589. #include "../sensors/GUVAS12SDSensor.h"
  590. #endif
  591. #if HLW8012_SUPPORT
  592. #include <HLW8012.h>
  593. #include "../sensors/HLW8012Sensor.h"
  594. #endif
  595. #if MHZ19_SUPPORT
  596. #include <SoftwareSerial.h>
  597. #include "../sensors/MHZ19Sensor.h"
  598. #endif
  599. #if NTC_SUPPORT
  600. #include "../sensors/AnalogSensor.h"
  601. #include "../sensors/NTCSensor.h"
  602. #endif
  603. #if SENSEAIR_SUPPORT
  604. #include <SoftwareSerial.h>
  605. #include "../sensors/SenseAirSensor.h"
  606. #endif
  607. #if PMSX003_SUPPORT
  608. #include <SoftwareSerial.h>
  609. #include "../sensors/PMSX003Sensor.h"
  610. #endif
  611. #if PZEM004T_SUPPORT
  612. #include <SoftwareSerial.h>
  613. #include "../sensors/PZEM004TSensor.h"
  614. #endif
  615. #if SI7021_SUPPORT
  616. #include "../sensors/SI7021Sensor.h"
  617. #endif
  618. #if SHT3X_I2C_SUPPORT
  619. #include "../sensors/SHT3XI2CSensor.h"
  620. #endif
  621. #if SONAR_SUPPORT
  622. #include "../sensors/SonarSensor.h"
  623. #endif
  624. #if TMP3X_SUPPORT
  625. #include "../sensors/TMP3XSensor.h"
  626. #endif
  627. #if V9261F_SUPPORT
  628. #include <SoftwareSerial.h>
  629. #include "../sensors/V9261FSensor.h"
  630. #endif
  631. #endif // SENSOR_SUPPORT