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.

170 lines
6.1 KiB

7 years ago
7 years ago
  1. //--------------------------------------------------------------------------------
  2. // Custom RF module
  3. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  4. // Enable support by passing RF_SUPPORT=1 build flag
  5. //--------------------------------------------------------------------------------
  6. #ifndef RF_SUPPORT
  7. #define RF_SUPPORT 0
  8. #endif
  9. #define RF_PIN 14
  10. #define RF_CHANNEL 31
  11. #define RF_DEVICE 1
  12. //--------------------------------------------------------------------------------
  13. // DHTXX temperature/humidity sensor
  14. // Enable support by passing DHT_SUPPORT=1 build flag
  15. //--------------------------------------------------------------------------------
  16. #ifndef DHT_SUPPORT
  17. #define DHT_SUPPORT 0
  18. #endif
  19. #define DHT_PIN 14
  20. #define DHT_UPDATE_INTERVAL 60000
  21. #define DHT_TYPE DHT22
  22. #define DHT_TIMING 11
  23. #define DHT_TEMPERATURE_TOPIC "temperature"
  24. #define DHT_HUMIDITY_TOPIC "humidity"
  25. #define HUMIDITY_NORMAL 0
  26. #define HUMIDITY_COMFORTABLE 1
  27. #define HUMIDITY_DRY 2
  28. #define HUMIDITY_WET 3
  29. //--------------------------------------------------------------------------------
  30. // Analog sensor
  31. // Enable support by passing ANALOG_SUPPORT=1 build flag
  32. //--------------------------------------------------------------------------------
  33. #ifndef ANALOG_SUPPORT
  34. #define ANALOG_SUPPORT 0
  35. #endif
  36. #define ANALOG_PIN 0
  37. #define ANALOG_UPDATE_INTERVAL 60000
  38. #define ANALOG_TOPIC "analog"
  39. #if ANALOG_SUPPORT
  40. #undef ADC_VCC_ENABLED
  41. #define ADC_VCC_ENABLED 0
  42. #endif
  43. //--------------------------------------------------------------------------------
  44. // Counter sensor
  45. // Enable support by passing COUNTER_SUPPORT=1 build flag
  46. //--------------------------------------------------------------------------------
  47. #ifndef COUNTER_SUPPORT
  48. #define COUNTER_SUPPORT 0 // Do not build with counter support by default
  49. #endif
  50. #define COUNTER_PIN 2 // GPIO to monitor
  51. #define COUNTER_PIN_MODE INPUT // INPUT, INPUT_PULLUP
  52. #define COUNTER_INTERRUPT_MODE RISING // RISING, FALLING, BOTH
  53. #define COUNTER_UPDATE_INTERVAL 5000 // Update counter every this millis
  54. #define COUNTER_REPORT_EVERY 12 // Report counter every this updates (1 minute)
  55. #define COUNTER_DEBOUNCE 10 // Do not register events within less than 10 millis
  56. #define COUNTER_TOPIC "counter" // Default topic for MQTT, API and InfluxDB
  57. //--------------------------------------------------------------------------------
  58. // DS18B20 temperature sensor
  59. // Enable support by passing DS18B20_SUPPORT=1 build flag
  60. //--------------------------------------------------------------------------------
  61. #ifndef DS18B20_SUPPORT
  62. #define DS18B20_SUPPORT 0
  63. #endif
  64. #define DS18B20_PIN 14
  65. #define DS18B20_UPDATE_INTERVAL 60000
  66. #define DS18B20_TEMPERATURE_TOPIC "temperature"
  67. //--------------------------------------------------------------------------------
  68. // Custom current sensor
  69. // Check http://tinkerman.cat/your-laundry-is-done/
  70. // Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/
  71. // Enable support by passing EMON_SUPPORT=1 build flag
  72. //--------------------------------------------------------------------------------
  73. #ifndef EMON_SUPPORT
  74. #define EMON_SUPPORT 0
  75. #endif
  76. #define EMON_ANALOG_PROVIDER 0
  77. #define EMON_ADC121_PROVIDER 1
  78. // If you select EMON_ADC121_PROVIDER you need to enable and configure I2C in general.h
  79. #define EMON_PROVIDER EMON_ANALOG_PROVIDER
  80. #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
  81. #define EMON_CURRENT_PIN 0
  82. #define EMON_ADC_BITS 10
  83. #define EMON_REFERENCE_VOLTAGE 1.0
  84. #define EMON_CURRENT_OFFSET 0.25
  85. #if EMON_SUPPORT
  86. #undef ADC_VCC_ENABLED
  87. #define ADC_VCC_ENABLED 0
  88. #endif
  89. #endif
  90. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  91. #define EMON_ADC121_ADDRESS 0x50
  92. #define EMON_ADC_BITS 12
  93. #define EMON_REFERENCE_VOLTAGE 3.3
  94. #define EMON_CURRENT_OFFSET 0.10
  95. #endif
  96. #define EMON_CURRENT_RATIO 30
  97. #define EMON_SAMPLES 1000
  98. #define EMON_INTERVAL 10000
  99. #define EMON_MEASUREMENTS 6
  100. #define EMON_MAINS_VOLTAGE 230
  101. #define EMON_APOWER_TOPIC "apower"
  102. #define EMON_ENERGY_TOPIC "energy"
  103. #define EMON_CURRENT_TOPIC "current"
  104. //--------------------------------------------------------------------------------
  105. // HLW8012 power sensor (Sonoff POW, Espurna H)
  106. // Enable support by passing HLW8012_SUPPORT=1 build flag
  107. //--------------------------------------------------------------------------------
  108. #ifndef HLW8012_SUPPORT
  109. #define HLW8012_SUPPORT 0
  110. #endif
  111. // GPIOs defined in the hardware.h file
  112. #define HLW8012_USE_INTERRUPTS 1
  113. #define HLW8012_SEL_CURRENT HIGH
  114. #define HLW8012_CURRENT_R 0.001
  115. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  116. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  117. #define HLW8012_POWER_TOPIC "power"
  118. #define HLW8012_CURRENT_TOPIC "current"
  119. #define HLW8012_VOLTAGE_TOPIC "voltage"
  120. #define HLW8012_APOWER_TOPIC "apower"
  121. #define HLW8012_RPOWER_TOPIC "rpower"
  122. #define HLW8012_PFACTOR_TOPIC "pfactor"
  123. #define HLW8012_ENERGY_TOPIC "energy"
  124. #define HLW8012_UPDATE_INTERVAL 5000
  125. #define HLW8012_REPORT_EVERY 12
  126. #define HLW8012_MIN_POWER 5
  127. #define HLW8012_MAX_POWER 2500
  128. #define HLW8012_MIN_CURRENT 0.05
  129. #define HLW8012_MAX_CURRENT 10
  130. //--------------------------------------------------------------------------------
  131. // Internal power montior
  132. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  133. // Do not enable this if using the analog GPIO for any other thing
  134. //--------------------------------------------------------------------------------
  135. #ifndef ADC_VCC_ENABLED
  136. #define ADC_VCC_ENABLED 1
  137. #endif
  138. #if ADC_VCC_ENABLED
  139. ADC_MODE(ADC_VCC);
  140. #endif