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.

259 lines
8.7 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
  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. // BME280
  48. // Enable support by passing BME280_SUPPORT=1 build flag
  49. //--------------------------------------------------------------------------------
  50. #ifndef BME280_SUPPORT
  51. #define BME280_SUPPORT 0
  52. #endif
  53. #ifndef BME280_ADDRESS
  54. #define BME280_ADDRESS 0x76
  55. #endif
  56. #define BME280_MODE 1 // 1 for forced mode, 3 for normal mode
  57. #define BME280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  58. #define BME280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude)
  59. #define BME280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  60. //--------------------------------------------------------------------------------
  61. // DS18B20 temperature sensor
  62. // Enable support by passing DS18B20_SUPPORT=1 build flag
  63. //--------------------------------------------------------------------------------
  64. #ifndef DS18B20_SUPPORT
  65. #define DS18B20_SUPPORT 0
  66. #endif
  67. #ifndef DS18B20_PIN
  68. #define DS18B20_PIN 13
  69. #endif
  70. #ifndef DS18B20_PULLUP
  71. #define DS18B20_PULLUP 1
  72. #endif
  73. #ifndef DS18B20_UPDATE_INTERVAL
  74. #define DS18B20_UPDATE_INTERVAL 60000
  75. #endif
  76. #ifndef DS18B20_TEMPERATURE_TOPIC
  77. #define DS18B20_TEMPERATURE_TOPIC "temperature"
  78. #endif
  79. #define DS18B20_RESOLUTION 9
  80. //--------------------------------------------------------------------------------
  81. // Digital sensor
  82. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  83. //--------------------------------------------------------------------------------
  84. #ifndef DIGITAL_SUPPORT
  85. #define DIGITAL_SUPPORT 0
  86. #endif
  87. #ifndef DIGITAL_PIN
  88. #define DIGITAL_PIN 2
  89. #endif
  90. #ifndef DIGITAL_PIN_MODE
  91. #define DIGITAL_PIN_MODE INPUT_PULLUP
  92. #endif
  93. #ifndef DIGITAL_DEFAULT_STATE
  94. #define DIGITAL_DEFAULT_STATE 1
  95. #endif
  96. //--------------------------------------------------------------------------------
  97. // Analog sensor
  98. // Enable support by passing ANALOG_SUPPORT=1 build flag
  99. //--------------------------------------------------------------------------------
  100. #ifndef ANALOG_SUPPORT
  101. #define ANALOG_SUPPORT 0
  102. #endif
  103. #ifndef ANALOG_PIN
  104. #define ANALOG_PIN 0
  105. #endif
  106. #ifndef ANALOG_PIN_MODE
  107. #define ANALOG_PIN_MODE INPUT
  108. #endif
  109. #if ANALOG_SUPPORT
  110. #undef ADC_VCC_ENABLED
  111. #define ADC_VCC_ENABLED 0
  112. #endif
  113. //--------------------------------------------------------------------------------
  114. // Counter sensor
  115. // Enable support by passing COUNTER_SUPPORT=1 build flag
  116. //--------------------------------------------------------------------------------
  117. #ifndef COUNTER_SUPPORT
  118. #define COUNTER_SUPPORT 0 // Do not build with counter support by default
  119. #endif
  120. #ifndef COUNTER_PIN
  121. #define COUNTER_PIN 2 // GPIO to monitor
  122. #endif
  123. #ifndef COUNTER_PIN_MODE
  124. #define COUNTER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  125. #endif
  126. #ifndef COUNTER_INTERRUPT_MODE
  127. #define COUNTER_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  128. #endif
  129. #define COUNTER_DEBOUNCE 50 // Do not register events within less than 10 millis
  130. //--------------------------------------------------------------------------------
  131. // Energy Monitor
  132. //--------------------------------------------------------------------------------
  133. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  134. #define EMON_MAX_TIME 250 // Max time in ms to sample
  135. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  136. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  137. #define EMON_REPORT_CURRENT 0 // Calculate current
  138. #define EMON_REPORT_POWER 1 // Calculate power
  139. #define EMON_REPORT_ENERGY 1 // Calculate energy
  140. //--------------------------------------------------------------------------------
  141. // Energy Monitor based on interval analog GPIO
  142. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  143. //--------------------------------------------------------------------------------
  144. #ifndef EMON_ANALOG_SUPPORT
  145. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  146. #endif
  147. #define EMON_ANALOG_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  148. #define EMON_ANALOG_ADC_BITS 10 // ADC depth
  149. #define EMON_ANALOG_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  150. #if EMON_ANALOG_SUPPORT
  151. #undef ADC_VCC_ENABLED
  152. #define ADC_VCC_ENABLED 0
  153. #endif
  154. //--------------------------------------------------------------------------------
  155. // Energy Monitor based on ADC121
  156. // Enable support by passing EMON_ADC121_SUPPORT=1 build flag
  157. //--------------------------------------------------------------------------------
  158. #ifndef EMON_ADC121_SUPPORT
  159. #define EMON_ADC121_SUPPORT 0 // Do not build support by default
  160. #endif
  161. #define EMON_ADC121_I2C_ADDRESS 0x50 // I2C address of the ADC121
  162. #define EMON_ADC121_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  163. #define EMON_ADC121_ADC_BITS 12 // ADC depth
  164. #define EMON_ADC121_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  165. //--------------------------------------------------------------------------------
  166. // Energy Monitor based on ADS1X15
  167. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  168. //--------------------------------------------------------------------------------
  169. #ifndef EMON_ADS1X15_SUPPORT
  170. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  171. #endif
  172. #define EMON_ADS1X15_ADS1115 1 // 0 for ADS10115, 1 for ADS1115
  173. #define EMON_ADS1X15_PORT_MASK 0x08 // A0=1 A1=2 A2=4 A4=8
  174. #define EMON_ADS1X15_I2C_ADDRESS 0x48 // I2C address of the ADS1115
  175. #define EMON_ADS1X15_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  176. #define EMON_ADS1X15_ADC_BITS 16 // ADC depth
  177. #define EMON_ADS1X15_REFERENCE_VOLTAGE 8.192 // Double the gain for peak-to-peak
  178. //--------------------------------------------------------------------------------
  179. // Particle Monitor based on Plantower PMSX003
  180. // Enable support by passing PMSX003_SUPPORT=1 build flag
  181. //--------------------------------------------------------------------------------
  182. #ifndef PMSX003_SUPPORT
  183. #define PMSX003_SUPPORT 0
  184. #endif
  185. #define PMS_RX_PIN 13
  186. #define PMS_TX_PIN 15
  187. //--------------------------------------------------------------------------------
  188. // Internal power montior
  189. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  190. // Do not enable this if using the analog GPIO for any other thing
  191. //--------------------------------------------------------------------------------
  192. #ifndef ADC_VCC_ENABLED
  193. #define ADC_VCC_ENABLED 1
  194. #endif
  195. #if ADC_VCC_ENABLED
  196. ADC_MODE(ADC_VCC);
  197. #endif