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.

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