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.

302 lines
11 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
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
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. // -----------------------------------------------------------------------------
  2. // SENSORS
  3. // -----------------------------------------------------------------------------
  4. #define SENSOR_READ_INTERVAL 6000 // Read data from sensors every 6 seconds
  5. #define SENSOR_REPORT_EVERY 10 // Report every this many readings
  6. #define SENSOR_USE_INDEX 0 // Use the index in topic (i.e. temperature/0)
  7. // even if just one sensor (0 for backwards compatibility)
  8. #ifndef SENSOR_TEMPERATURE_UNITS
  9. #define SENSOR_TEMPERATURE_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  10. #endif
  11. #ifndef SENSOR_TEMPERATURE_CORRECTION
  12. #define SENSOR_TEMPERATURE_CORRECTION 0.0 // Offset correction
  13. #endif
  14. #ifndef TEMPERATURE_MIN_CHANGE
  15. #define TEMPERATURE_MIN_CHANGE 0.0 // Minimum temperature change to report
  16. #endif
  17. #ifndef HUMIDITY_MIN_CHANGE
  18. #define HUMIDITY_MIN_CHANGE 0 // Minimum humidity change to report
  19. #endif
  20. #define SENSOR_TEMPERATURE_DECIMALS 1
  21. #define SENSOR_HUMIDITY_DECIMALS 0
  22. #define SENSOR_PRESSURE_DECIMALS 2
  23. #define SENSOR_ANALOG_DECIMALS 0
  24. #define SENSOR_EVENTS_DECIMALS 0
  25. #define SENSOR_CURRENT_DECIMALS 3
  26. #define SENSOR_VOLTAGE_DECIMALS 0
  27. #define SENSOR_POWER_DECIMALS 0
  28. #define SENSOR_POWER_FACTOR_DECIMALS 0
  29. #define SENSOR_ENERGY_DECIMALS 0
  30. #define SENSOR_PM1dot0_DECIMALS 0
  31. #define SENSOR_PM2dot5_DECIMALS 0
  32. #define SENSOR_PM10_DECIMALS 0
  33. #define SENSOR_CO2_DECIMALS 0
  34. #define SENSOR_UNKNOWN_TOPIC "unknown"
  35. #define SENSOR_TEMPERATURE_TOPIC "temperature"
  36. #define SENSOR_HUMIDITY_TOPIC "humidity"
  37. #define SENSOR_PRESSURE_TOPIC "pressure"
  38. #define SENSOR_CURRENT_TOPIC "current"
  39. #define SENSOR_VOLTAGE_TOPIC "voltage"
  40. #define SENSOR_ACTIVE_POWER_TOPIC "power"
  41. #define SENSOR_APPARENT_POWER_TOPIC "apparent"
  42. #define SENSOR_REACTIVE_POWER_TOPIC "reactive"
  43. #define SENSOR_POWER_FACTOR_TOPIC "factor"
  44. #define SENSOR_ENERGY_TOPIC "energy"
  45. #define SENSOR_ENERGY_DELTA_TOPIC "energy_delta"
  46. #define SENSOR_PM1dot0_TOPIC "pm1dot0"
  47. #define SENSOR_PM2dot5_TOPIC "pm2dot5"
  48. #define SENSOR_PM10_TOPIC "pm10"
  49. #define SENSOR_ANALOG_TOPIC "analog"
  50. #define SENSOR_DIGITAL_TOPIC "digital"
  51. #define SENSOR_EVENTS_TOPIC "events"
  52. #define SENSOR_CO2_TOPIC "co2"
  53. //--------------------------------------------------------------------------------
  54. // DHTXX temperature/humidity sensor
  55. // Enable support by passing DHT_SUPPORT=1 build flag
  56. //--------------------------------------------------------------------------------
  57. #ifndef DHT_SUPPORT
  58. #define DHT_SUPPORT 0
  59. #endif
  60. #ifndef DHT_PIN
  61. #define DHT_PIN 14
  62. #endif
  63. #ifndef DHT_TYPE
  64. #define DHT_TYPE DHT22
  65. #endif
  66. #ifndef DHT_PULLUP
  67. #define DHT_PULLUP 0
  68. #endif
  69. #define HUMIDITY_NORMAL 0
  70. #define HUMIDITY_COMFORTABLE 1
  71. #define HUMIDITY_DRY 2
  72. #define HUMIDITY_WET 3
  73. //--------------------------------------------------------------------------------
  74. // SI7021 temperature & humidity sensor
  75. // Enable support by passing SI7021_SUPPORT=1 build flag
  76. //--------------------------------------------------------------------------------
  77. #ifndef SI7021_SUPPORT
  78. #define SI7021_SUPPORT 0
  79. #endif
  80. #ifndef SI7021_ADDRESS
  81. #define SI7021_ADDRESS 0x40
  82. #endif
  83. //--------------------------------------------------------------------------------
  84. // BMX280
  85. // Enable support by passing BMX280_SUPPORT=1 build flag
  86. //--------------------------------------------------------------------------------
  87. #ifndef BMX280_SUPPORT
  88. #define BMX280_SUPPORT 0
  89. #endif
  90. #ifndef BMX280_ADDRESS
  91. #define BMX280_ADDRESS 0x76
  92. #endif
  93. #define BMX280_MODE 1 // 1 for forced mode, 3 for normal mode
  94. #define BMX280_TEMPERATURE 1 // Oversampling for temperature (set to 0 to disable magnitude)
  95. #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280)
  96. #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude)
  97. //--------------------------------------------------------------------------------
  98. // DS18B20 temperature sensor
  99. // Enable support by passing DALLAS_SUPPORT=1 build flag
  100. //--------------------------------------------------------------------------------
  101. #ifndef DALLAS_SUPPORT
  102. #define DALLAS_SUPPORT 0
  103. #endif
  104. #ifndef DALLAS_PIN
  105. #define DALLAS_PIN 13
  106. #endif
  107. #ifndef DALLAS_PULLUP
  108. #define DALLAS_PULLUP 1
  109. #endif
  110. #define DALLAS_RESOLUTION 9 // Not used atm
  111. //--------------------------------------------------------------------------------
  112. // Digital sensor
  113. // Enable support by passing DIGITAL_SUPPORT=1 build flag
  114. //--------------------------------------------------------------------------------
  115. #ifndef DIGITAL_SUPPORT
  116. #define DIGITAL_SUPPORT 0
  117. #endif
  118. #ifndef DIGITAL_PIN
  119. #define DIGITAL_PIN 2
  120. #endif
  121. #ifndef DIGITAL_PIN_MODE
  122. #define DIGITAL_PIN_MODE INPUT_PULLUP
  123. #endif
  124. #ifndef DIGITAL_DEFAULT_STATE
  125. #define DIGITAL_DEFAULT_STATE 1
  126. #endif
  127. //--------------------------------------------------------------------------------
  128. // Analog sensor
  129. // Enable support by passing ANALOG_SUPPORT=1 build flag
  130. //--------------------------------------------------------------------------------
  131. #ifndef ANALOG_SUPPORT
  132. #define ANALOG_SUPPORT 0
  133. #endif
  134. #ifndef ANALOG_PIN
  135. #define ANALOG_PIN 0
  136. #endif
  137. #ifndef ANALOG_PIN_MODE
  138. #define ANALOG_PIN_MODE INPUT
  139. #endif
  140. #if ANALOG_SUPPORT
  141. #undef ADC_VCC_ENABLED
  142. #define ADC_VCC_ENABLED 0
  143. #endif
  144. //--------------------------------------------------------------------------------
  145. // Counter sensor
  146. // Enable support by passing EVENTS_SUPPORT=1 build flag
  147. //--------------------------------------------------------------------------------
  148. #ifndef EVENTS_SUPPORT
  149. #define EVENTS_SUPPORT 0 // Do not build with counter support by default
  150. #endif
  151. #ifndef EVENTS_PIN
  152. #define EVENTS_PIN 2 // GPIO to monitor
  153. #endif
  154. #ifndef EVENTS_PIN_MODE
  155. #define EVENTS_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  156. #endif
  157. #ifndef EVENTS_INTERRUPT_MODE
  158. #define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  159. #endif
  160. #define EVENTS_DEBOUNCE 50 // Do not register events within less than 10 millis
  161. //--------------------------------------------------------------------------------
  162. // Energy Monitor general settings
  163. //--------------------------------------------------------------------------------
  164. #define EMON_MAX_SAMPLES 1000 // Max number of samples to get
  165. #define EMON_MAX_TIME 250 // Max time in ms to sample
  166. #define EMON_FILTER_SPEED 512 // Mobile average filter speed
  167. #define EMON_MAINS_VOLTAGE 230 // Mains voltage
  168. #define EMON_REPORT_CURRENT 0 // Report current
  169. #define EMON_REPORT_POWER 1 // Report power
  170. #define EMON_REPORT_ENERGY 1 // Report energy
  171. //--------------------------------------------------------------------------------
  172. // Energy Monitor based on interval analog GPIO
  173. // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag
  174. //--------------------------------------------------------------------------------
  175. #ifndef EMON_ANALOG_SUPPORT
  176. #define EMON_ANALOG_SUPPORT 0 // Do not build support by default
  177. #endif
  178. #define EMON_ANALOG_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  179. #define EMON_ANALOG_ADC_BITS 10 // ADC depth
  180. #define EMON_ANALOG_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  181. #if EMON_ANALOG_SUPPORT
  182. #undef ADC_VCC_ENABLED
  183. #define ADC_VCC_ENABLED 0
  184. #endif
  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 0x50 // I2C address of the ADC121
  193. #define EMON_ADC121_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  194. #define EMON_ADC121_ADC_BITS 12 // ADC depth
  195. #define EMON_ADC121_REFERENCE_VOLTAGE 3.3 // Reference voltage of the ADC
  196. //--------------------------------------------------------------------------------
  197. // Energy Monitor based on ADS1X15
  198. // Enable support by passing EMON_ADS1X15_SUPPORT=1 build flag
  199. //--------------------------------------------------------------------------------
  200. #ifndef EMON_ADS1X15_SUPPORT
  201. #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
  202. #endif
  203. #define EMON_ADS1X15_ADS1115 1 // 0 for ADS10115, 1 for ADS1115
  204. #define EMON_ADS1X15_PORT_MASK 0x08 // A0=1 A1=2 A2=4 A4=8
  205. #define EMON_ADS1X15_I2C_ADDRESS 0x48 // I2C address of the ADS1115
  206. #define EMON_ADS1X15_CURRENT_RATIO 30 // Current ratio in the clamp (30V/1A)
  207. #define EMON_ADS1X15_ADC_BITS 16 // ADC depth
  208. #define EMON_ADS1X15_REFERENCE_VOLTAGE 8.192 // Double the gain for peak-to-peak
  209. //--------------------------------------------------------------------------------
  210. // Particle Monitor based on Plantower PMSX003
  211. // Enable support by passing PMSX003_SUPPORT=1 build flag
  212. //--------------------------------------------------------------------------------
  213. #ifndef PMSX003_SUPPORT
  214. #define PMSX003_SUPPORT 0
  215. #endif
  216. #define PMS_RX_PIN 13
  217. #define PMS_TX_PIN 15
  218. //--------------------------------------------------------------------------------
  219. // MHZ19 CO2 sensor
  220. // Enable support by passing MHZ19_SUPPORT=1 build flag
  221. //--------------------------------------------------------------------------------
  222. #ifndef MHZ19_SUPPORT
  223. #define MHZ19_SUPPORT 0
  224. #endif
  225. #define MHZ19_RX_PIN 13
  226. #define MHZ19_TX_PIN 15
  227. //--------------------------------------------------------------------------------
  228. // Internal power montior
  229. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  230. // Do not enable this if using the analog GPIO for any other thing
  231. //--------------------------------------------------------------------------------
  232. #ifndef ADC_VCC_ENABLED
  233. #define ADC_VCC_ENABLED 1
  234. #endif
  235. #if ADC_VCC_ENABLED
  236. ADC_MODE(ADC_VCC);
  237. #endif