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.

155 lines
5.3 KiB

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. // DS18B20 temperature sensor
  45. // Enable support by passing DS18B20_SUPPORT=1 build flag
  46. //--------------------------------------------------------------------------------
  47. #ifndef DS18B20_SUPPORT
  48. #define DS18B20_SUPPORT 0
  49. #endif
  50. #define DS18B20_PIN 14
  51. #define DS18B20_UPDATE_INTERVAL 60000
  52. #define DS18B20_TEMPERATURE_TOPIC "temperature"
  53. //--------------------------------------------------------------------------------
  54. // Custom current sensor
  55. // Check http://tinkerman.cat/your-laundry-is-done/
  56. // Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/
  57. // Enable support by passing EMON_SUPPORT=1 build flag
  58. //--------------------------------------------------------------------------------
  59. #ifndef EMON_SUPPORT
  60. #define EMON_SUPPORT 0
  61. #endif
  62. #define EMON_ANALOG_PROVIDER 0
  63. #define EMON_ADC121_PROVIDER 1
  64. // If you select EMON_ADC121_PROVIDER you need to enable and configure I2C in general.h
  65. #define EMON_PROVIDER EMON_ANALOG_PROVIDER
  66. #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
  67. #define EMON_CURRENT_PIN 0
  68. #define EMON_ADC_BITS 10
  69. #define EMON_REFERENCE_VOLTAGE 1.0
  70. #define EMON_CURRENT_PRECISION 1
  71. #define EMON_CURRENT_OFFSET 0.25
  72. #if EMON_SUPPORT
  73. #undef ADC_VCC_ENABLED
  74. #define ADC_VCC_ENABLED 0
  75. #endif
  76. #endif
  77. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  78. #define EMON_ADC121_ADDRESS 0x50
  79. #define EMON_ADC_BITS 12
  80. #define EMON_REFERENCE_VOLTAGE 3.3
  81. #define EMON_CURRENT_PRECISION 2
  82. #define EMON_CURRENT_OFFSET 0.10
  83. #endif
  84. #define EMON_CURRENT_RATIO 30
  85. #define EMON_SAMPLES 1000
  86. #define EMON_INTERVAL 10000
  87. #define EMON_MEASUREMENTS 6
  88. #define EMON_MAINS_VOLTAGE 230
  89. #define EMON_APOWER_TOPIC "apower"
  90. #define EMON_ENERGY_TOPIC "energy"
  91. #define EMON_CURRENT_TOPIC "current"
  92. //--------------------------------------------------------------------------------
  93. // HLW8012 power sensor (Sonoff POW, Espurna H)
  94. // Enable support by passing HLW8012_SUPPORT=1 build flag
  95. //--------------------------------------------------------------------------------
  96. #ifndef HLW8012_SUPPORT
  97. #define HLW8012_SUPPORT 0
  98. #endif
  99. // GPIOs defined in the hardware.h file
  100. #define HLW8012_USE_INTERRUPTS 1
  101. #define HLW8012_SEL_CURRENT HIGH
  102. #define HLW8012_CURRENT_R 0.001
  103. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  104. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  105. #define HLW8012_POWER_TOPIC "power"
  106. #define HLW8012_CURRENT_TOPIC "current"
  107. #define HLW8012_VOLTAGE_TOPIC "voltage"
  108. #define HLW8012_APOWER_TOPIC "apower"
  109. #define HLW8012_RPOWER_TOPIC "rpower"
  110. #define HLW8012_PFACTOR_TOPIC "pfactor"
  111. #define HLW8012_ENERGY_TOPIC "energy"
  112. #define HLW8012_UPDATE_INTERVAL 5000
  113. #define HLW8012_REPORT_EVERY 12
  114. #define HLW8012_MIN_POWER 5
  115. #define HLW8012_MAX_POWER 2500
  116. #define HLW8012_MIN_CURRENT 0.05
  117. #define HLW8012_MAX_CURRENT 10
  118. //--------------------------------------------------------------------------------
  119. // Internal power montior
  120. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  121. // Do not enable this if using the analog GPIO for any other thing
  122. //--------------------------------------------------------------------------------
  123. #ifndef ADC_VCC_ENABLED
  124. #define ADC_VCC_ENABLED 1
  125. #endif
  126. #if ADC_VCC_ENABLED
  127. ADC_MODE(ADC_VCC);
  128. #endif