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.

131 lines
4.7 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 ENABLE_RF=1 build flag
  5. //--------------------------------------------------------------------------------
  6. #define RF_PIN 14
  7. #define RF_CHANNEL 31
  8. #define RF_DEVICE 1
  9. //--------------------------------------------------------------------------------
  10. // DHTXX temperature/humidity sensor
  11. // Enable support by passing ENABLE_DHT=1 build flag
  12. //--------------------------------------------------------------------------------
  13. #define DHT_PIN 14
  14. #define DHT_UPDATE_INTERVAL 60000
  15. #define DHT_TYPE DHT22
  16. #define DHT_TIMING 11
  17. #define DHT_TEMPERATURE_TOPIC "temperature"
  18. #define DHT_HUMIDITY_TOPIC "humidity"
  19. #define HUMIDITY_NORMAL 0
  20. #define HUMIDITY_COMFORTABLE 1
  21. #define HUMIDITY_DRY 2
  22. #define HUMIDITY_WET 3
  23. //--------------------------------------------------------------------------------
  24. // Analog sensor
  25. // Enable support by passing ENABLE_ANALOG=1 build flag
  26. //--------------------------------------------------------------------------------
  27. #define ANALOG_PIN 0
  28. #define ANALOG_UPDATE_INTERVAL 60000
  29. #define ANALOG_TOPIC "analog"
  30. #if ENABLE_ANALOG
  31. #undef ENABLE_ADC_VCC
  32. #define ENABLE_ADC_VCC 0
  33. #endif
  34. //--------------------------------------------------------------------------------
  35. // DS18B20 temperature sensor
  36. // Enable support by passing ENABLE_DS18B20=1 build flag
  37. //--------------------------------------------------------------------------------
  38. #define DS_PIN 14
  39. #define DS_UPDATE_INTERVAL 60000
  40. #define DS_TEMPERATURE_TOPIC "temperature"
  41. //--------------------------------------------------------------------------------
  42. // Custom current sensor
  43. // Check http://tinkerman.cat/your-laundry-is-done/
  44. // Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/
  45. // Enable support by passing ENABLE_EMON=1 build flag
  46. //--------------------------------------------------------------------------------
  47. #define EMON_ANALOG_PROVIDER 0
  48. #define EMON_ADC121_PROVIDER 1
  49. // If you select EMON_ADC121_PROVIDER you need to enable and configure I2C in general.h
  50. #define EMON_PROVIDER EMON_ANALOG_PROVIDER
  51. #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
  52. #define EMON_CURRENT_PIN 0
  53. #define EMON_ADC_BITS 10
  54. #define EMON_REFERENCE_VOLTAGE 1.0
  55. #define EMON_CURRENT_PRECISION 1
  56. #define EMON_CURRENT_OFFSET 0.25
  57. #if ENABLE_EMON
  58. #undef ENABLE_ADC_VCC
  59. #define ENABLE_ADC_VCC 0
  60. #endif
  61. #endif
  62. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  63. #define EMON_ADC121_ADDRESS 0x50
  64. #define EMON_ADC_BITS 12
  65. #define EMON_REFERENCE_VOLTAGE 3.3
  66. #define EMON_CURRENT_PRECISION 2
  67. #define EMON_CURRENT_OFFSET 0.10
  68. #endif
  69. #define EMON_CURRENT_RATIO 30
  70. #define EMON_SAMPLES 1000
  71. #define EMON_INTERVAL 10000
  72. #define EMON_MEASUREMENTS 6
  73. #define EMON_MAINS_VOLTAGE 230
  74. #define EMON_APOWER_TOPIC "apower"
  75. #define EMON_ENERGY_TOPIC "energy"
  76. #define EMON_CURRENT_TOPIC "current"
  77. //--------------------------------------------------------------------------------
  78. // HLW8012 power sensor (Sonoff POW, Espurna H)
  79. // Enable support by passing ENABLE_HLW8012=1 build flag
  80. //--------------------------------------------------------------------------------
  81. // GPIOs defined in the hardware.h file
  82. #define HLW8012_USE_INTERRUPTS 1
  83. #define HLW8012_SEL_CURRENT HIGH
  84. #define HLW8012_CURRENT_R 0.001
  85. #define HLW8012_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  86. #define HLW8012_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  87. #define HLW8012_POWER_TOPIC "power"
  88. #define HLW8012_CURRENT_TOPIC "current"
  89. #define HLW8012_VOLTAGE_TOPIC "voltage"
  90. #define HLW8012_APOWER_TOPIC "apower"
  91. #define HLW8012_RPOWER_TOPIC "rpower"
  92. #define HLW8012_PFACTOR_TOPIC "pfactor"
  93. #define HLW8012_ENERGY_TOPIC "energy"
  94. #define HLW8012_UPDATE_INTERVAL 5000
  95. #define HLW8012_REPORT_EVERY 12
  96. #define HLW8012_MIN_POWER 5
  97. #define HLW8012_MAX_POWER 2500
  98. #define HLW8012_MIN_CURRENT 0.05
  99. #define HLW8012_MAX_CURRENT 10
  100. //--------------------------------------------------------------------------------
  101. // Internal power montior
  102. // Enable support by passing ENABLE_ADC_VCC=1 build flag
  103. // Do not enable this if using the analog GPIO for any other thing
  104. //--------------------------------------------------------------------------------
  105. #ifndef ENABLE_ADC_VCC
  106. #define ENABLE_ADC_VCC 1
  107. #endif
  108. #if ENABLE_ADC_VCC
  109. ADC_MODE(ADC_VCC);
  110. #endif