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.

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