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.

212 lines
7.1 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. //--------------------------------------------------------------------------------
  2. // General
  3. //--------------------------------------------------------------------------------
  4. #ifndef TEMPERATURE_MIN_CHANGE
  5. #define TEMPERATURE_MIN_CHANGE 0.0 // Minimum temperature change to report
  6. #endif
  7. #ifndef HUMIDITY_MIN_CHANGE
  8. #define HUMIDITY_MIN_CHANGE 0 // Minimum humidity change to report
  9. #endif
  10. #define TEMPERATURE_DECIMALS 1 // Decimals for temperature values
  11. //--------------------------------------------------------------------------------
  12. // DHTXX temperature/humidity sensor
  13. // Enable support by passing DHT_SUPPORT=1 build flag
  14. //--------------------------------------------------------------------------------
  15. #ifndef DHT_SUPPORT
  16. #define DHT_SUPPORT 0
  17. #endif
  18. #ifndef DHT_PIN
  19. #define DHT_PIN 14
  20. #endif
  21. #ifndef DHT_TYPE
  22. #define DHT_TYPE DHT22
  23. #endif
  24. #ifndef DHT_PULLUP
  25. #define DHT_PULLUP 0
  26. #endif
  27. #ifndef DHT_UPDATE_INTERVAL
  28. #define DHT_UPDATE_INTERVAL 60000
  29. #endif
  30. #define DHT_TEMPERATURE_TOPIC "temperature"
  31. #define DHT_HUMIDITY_TOPIC "humidity"
  32. #define HUMIDITY_NORMAL 0
  33. #define HUMIDITY_COMFORTABLE 1
  34. #define HUMIDITY_DRY 2
  35. #define HUMIDITY_WET 3
  36. //--------------------------------------------------------------------------------
  37. // SI7021 temperature & humidity sensor
  38. // Enable support by passing SI7021_SUPPORT=1 build flag
  39. //--------------------------------------------------------------------------------
  40. #ifndef SI7021_SUPPORT
  41. #define SI7021_SUPPORT 0
  42. #endif
  43. #ifndef SI7021_ADDRESS
  44. #define SI7021_ADDRESS 0x40
  45. #endif
  46. //--------------------------------------------------------------------------------
  47. // DS18B20 temperature sensor
  48. // Enable support by passing DS18B20_SUPPORT=1 build flag
  49. //--------------------------------------------------------------------------------
  50. #ifndef DS18B20_SUPPORT
  51. #define DS18B20_SUPPORT 0
  52. #endif
  53. #ifndef DS18B20_PIN
  54. #define DS18B20_PIN 13
  55. #endif
  56. #ifndef DS18B20_PULLUP
  57. #define DS18B20_PULLUP 1
  58. #endif
  59. #ifndef DS18B20_UPDATE_INTERVAL
  60. #define DS18B20_UPDATE_INTERVAL 60000
  61. #endif
  62. #ifndef DS18B20_TEMPERATURE_TOPIC
  63. #define DS18B20_TEMPERATURE_TOPIC "temperature"
  64. #endif
  65. #define DS18B20_RESOLUTION 9
  66. //--------------------------------------------------------------------------------
  67. // Analog sensor
  68. // Enable support by passing ANALOG_SUPPORT=1 build flag
  69. //--------------------------------------------------------------------------------
  70. #ifndef ANALOG_SUPPORT
  71. #define ANALOG_SUPPORT 0
  72. #endif
  73. #ifndef ANALOG_PIN
  74. #define ANALOG_PIN 0
  75. #endif
  76. #ifndef ANALOG_UPDATE_INTERVAL
  77. #define ANALOG_UPDATE_INTERVAL 60000
  78. #endif
  79. #define ANALOG_TOPIC "analog"
  80. #if ANALOG_SUPPORT
  81. #undef ADC_VCC_ENABLED
  82. #define ADC_VCC_ENABLED 0
  83. #endif
  84. //--------------------------------------------------------------------------------
  85. // Counter sensor
  86. // Enable support by passing COUNTER_SUPPORT=1 build flag
  87. //--------------------------------------------------------------------------------
  88. #ifndef COUNTER_SUPPORT
  89. #define COUNTER_SUPPORT 0 // Do not build with counter support by default
  90. #endif
  91. #ifndef COUNTER_PIN
  92. #define COUNTER_PIN 2 // GPIO to monitor
  93. #endif
  94. #ifndef COUNTER_PIN_MODE
  95. #define COUNTER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  96. #endif
  97. #ifndef COUNTER_INTERRUPT_MODE
  98. #define COUNTER_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  99. #endif
  100. #ifndef COUNTER_UPDATE_INTERVAL
  101. #define COUNTER_UPDATE_INTERVAL 5000 // Update counter every this millis
  102. #endif
  103. #define COUNTER_REPORT_EVERY 12 // Report counter every this updates (1 minute)
  104. #define COUNTER_DEBOUNCE 10 // Do not register events within less than 10 millis
  105. #define COUNTER_TOPIC "counter" // Default topic for MQTT, API and InfluxDB
  106. //--------------------------------------------------------------------------------
  107. // Energy Monitor
  108. //--------------------------------------------------------------------------------
  109. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  110. #define EMON_MAX_TIME 500 // Max time in ms to sample
  111. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  112. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  113. //--------------------------------------------------------------------------------
  114. // Energy Monitor based on interval analog GPIO
  115. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  116. //--------------------------------------------------------------------------------
  117. #ifndef EMON_ANALOG_SUPPORT
  118. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  119. #endif
  120. #define EMON_ANALOG_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  121. #define EMON_ANALOG_ADC_BITS 10 // ADC depth
  122. #define EMON_ANALOG_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  123. #if EMON_ANALOG_SUPPORT
  124. #undef ADC_VCC_ENABLED
  125. #define ADC_VCC_ENABLED 0
  126. #endif
  127. //--------------------------------------------------------------------------------
  128. // Energy Monitor based on ADC121
  129. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  130. //--------------------------------------------------------------------------------
  131. #ifndef EMON_ADC121_SUPPORT
  132. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  133. #endif
  134. #define EMON_ADC121_I2C_ADDRESS 0x50 // I2C address of the ADC121
  135. #define EMON_ADC121_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  136. #define EMON_ADC121_ADC_BITS 12 // ADC depth
  137. #define EMON_ADC121_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  138. //--------------------------------------------------------------------------------
  139. // Energy Monitor based on ADS1115
  140. // Enable support by passing EMON_ADS1115_SUPPORT=1 build flag
  141. //--------------------------------------------------------------------------------
  142. #ifndef EMON_ADS1115_SUPPORT
  143. #define EMON_ADS1115_SUPPORT 1 // Do not build support by default
  144. #endif
  145. #define EMON_ADS1115_PORT_MASK 0x08 // A0=1 A1=2 A2=4 A4=8
  146. #define EMON_ADS1115_I2C_ADDRESS 0x48 // I2C address of the ADS1115
  147. #define EMON_ADS1115_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  148. #define EMON_ADS1115_ADC_BITS 16 // ADC depth
  149. #define EMON_ADS1115_GAIN ADS1115_PGA_4P096
  150. #define EMON_ADS1115_REFERENCE_VOLTAGE 8.192 // Double the gain for peak-to-peak
  151. //--------------------------------------------------------------------------------
  152. // Internal power montior
  153. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  154. // Do not enable this if using the analog GPIO for any other thing
  155. //--------------------------------------------------------------------------------
  156. #ifndef ADC_VCC_ENABLED
  157. #define ADC_VCC_ENABLED 1
  158. #endif
  159. #if ADC_VCC_ENABLED
  160. ADC_MODE(ADC_VCC);
  161. #endif