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.

153 lines
5.2 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_OFFSET 0.25
  71. #if EMON_SUPPORT
  72. #undef ADC_VCC_ENABLED
  73. #define ADC_VCC_ENABLED 0
  74. #endif
  75. #endif
  76. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  77. #define EMON_ADC121_ADDRESS 0x50
  78. #define EMON_ADC_BITS 12
  79. #define EMON_REFERENCE_VOLTAGE 3.3
  80. #define EMON_CURRENT_OFFSET 0.10
  81. #endif
  82. #define EMON_CURRENT_RATIO 30
  83. #define EMON_SAMPLES 1000
  84. #define EMON_INTERVAL 10000
  85. #define EMON_MEASUREMENTS 6
  86. #define EMON_MAINS_VOLTAGE 230
  87. #define EMON_APOWER_TOPIC "apower"
  88. #define EMON_ENERGY_TOPIC "energy"
  89. #define EMON_CURRENT_TOPIC "current"
  90. //--------------------------------------------------------------------------------
  91. // HLW8012 power sensor (Sonoff POW, Espurna H)
  92. // Enable support by passing HLW8012_SUPPORT=1 build flag
  93. //--------------------------------------------------------------------------------
  94. #ifndef HLW8012_SUPPORT
  95. #define HLW8012_SUPPORT 0
  96. #endif
  97. // GPIOs defined in the hardware.h file
  98. #define HLW8012_USE_INTERRUPTS 1
  99. #define HLW8012_SEL_CURRENT HIGH
  100. #define HLW8012_CURRENT_R 0.001
  101. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  102. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  103. #define HLW8012_POWER_TOPIC "power"
  104. #define HLW8012_CURRENT_TOPIC "current"
  105. #define HLW8012_VOLTAGE_TOPIC "voltage"
  106. #define HLW8012_APOWER_TOPIC "apower"
  107. #define HLW8012_RPOWER_TOPIC "rpower"
  108. #define HLW8012_PFACTOR_TOPIC "pfactor"
  109. #define HLW8012_ENERGY_TOPIC "energy"
  110. #define HLW8012_UPDATE_INTERVAL 5000
  111. #define HLW8012_REPORT_EVERY 12
  112. #define HLW8012_MIN_POWER 5
  113. #define HLW8012_MAX_POWER 2500
  114. #define HLW8012_MIN_CURRENT 0.05
  115. #define HLW8012_MAX_CURRENT 10
  116. //--------------------------------------------------------------------------------
  117. // Internal power montior
  118. // Enable support by passing ADC_VCC_ENABLED=1 build flag
  119. // Do not enable this if using the analog GPIO for any other thing
  120. //--------------------------------------------------------------------------------
  121. #ifndef ADC_VCC_ENABLED
  122. #define ADC_VCC_ENABLED 1
  123. #endif
  124. #if ADC_VCC_ENABLED
  125. ADC_MODE(ADC_VCC);
  126. #endif