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.

123 lines
4.5 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_UPDATE_INTERVAL 60000
  28. #define ANALOG_TOPIC "/analog"
  29. //--------------------------------------------------------------------------------
  30. // DS18B20 temperature sensor
  31. // Enable support by passing ENABLE_DS18B20=1 build flag
  32. //--------------------------------------------------------------------------------
  33. #define DS_PIN 14
  34. #define DS_UPDATE_INTERVAL 60000
  35. #define DS_TEMPERATURE_TOPIC "/temperature"
  36. //--------------------------------------------------------------------------------
  37. // Custom current sensor
  38. // Check http://tinkerman.cat/your-laundry-is-done/
  39. // Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/
  40. // Enable support by passing ENABLE_EMON=1 build flag
  41. //--------------------------------------------------------------------------------
  42. #define EMON_ANALOG_PROVIDER 0
  43. #define EMON_ADC121_PROVIDER 1
  44. // If you select EMON_ADC121_PROVIDER you need to enable and configure I2C in general.h
  45. #define EMON_PROVIDER EMON_ANALOG_PROVIDER
  46. #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
  47. #define EMON_CURRENT_PIN 0
  48. #define EMON_ADC_BITS 10
  49. #define EMON_REFERENCE_VOLTAGE 1.0
  50. #define EMON_CURRENT_PRECISION 1
  51. #define EMON_CURRENT_OFFSET 0.25
  52. #if ENABLE_EMON
  53. #undef ENABLE_ADC_VCC
  54. #define ENABLE_ADC_VCC 0
  55. #endif
  56. #endif
  57. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  58. #define EMON_ADC121_ADDRESS 0x50
  59. #define EMON_ADC_BITS 12
  60. #define EMON_REFERENCE_VOLTAGE 3.3
  61. #define EMON_CURRENT_PRECISION 2
  62. #define EMON_CURRENT_OFFSET 0.10
  63. #endif
  64. #define EMON_CURRENT_RATIO 30
  65. #define EMON_SAMPLES 1000
  66. #define EMON_INTERVAL 10000
  67. #define EMON_MEASUREMENTS 6
  68. #define EMON_MAINS_VOLTAGE 230
  69. #define EMON_APOWER_TOPIC "/apower"
  70. #define EMON_ENERGY_TOPIC "/energy"
  71. #define EMON_CURRENT_TOPIC "/current"
  72. //--------------------------------------------------------------------------------
  73. // HLW8012 power sensor (Sonoff POW)
  74. // Enable support by passing ENABLE_POW=1 build flag
  75. // Enabled by default when selecting SONOFF_POW hardware
  76. //--------------------------------------------------------------------------------
  77. #define POW_SEL_PIN 5
  78. #define POW_CF1_PIN 13
  79. #define POW_CF_PIN 14
  80. #define POW_USE_INTERRUPTS 1
  81. #define POW_SEL_CURRENT HIGH
  82. #define POW_CURRENT_R 0.001
  83. #define POW_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  84. #define POW_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  85. #define POW_POWER_TOPIC "/power"
  86. #define POW_CURRENT_TOPIC "/current"
  87. #define POW_VOLTAGE_TOPIC "/voltage"
  88. #define POW_APOWER_TOPIC "/apower"
  89. #define POW_RPOWER_TOPIC "/rpower"
  90. #define POW_PFACTOR_TOPIC "/pfactor"
  91. #define POW_ENERGY_TOPIC "/energy"
  92. #define POW_UPDATE_INTERVAL 5000
  93. #define POW_REPORT_EVERY 12
  94. //--------------------------------------------------------------------------------
  95. // Internal power montior
  96. // Enable support by passing ENABLE_ADC_VCC=1 build flag
  97. // Do not enable this if using the analog GPIO for any other thing
  98. //--------------------------------------------------------------------------------
  99. #ifndef ENABLE_ADC_VCC
  100. #define ENABLE_ADC_VCC 1
  101. #endif
  102. #if ENABLE_ADC_VCC
  103. ADC_MODE(ADC_VCC);
  104. #endif