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.

106 lines
4.0 KiB

7 years ago
  1. //--------------------------------------------------------------------------------
  2. // Internal popwer montior
  3. // Enable support by passing ENABLE_VCC_REPORT=1 build flag
  4. //--------------------------------------------------------------------------------
  5. #if (MQTT_REPORTS | MQTT_VCC_REPORT)
  6. ADC_MODE(ADC_VCC);
  7. #endif
  8. //--------------------------------------------------------------------------------
  9. // Custom RF module
  10. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  11. // Enable support by passing ENABLE_RF=1 build flag
  12. //--------------------------------------------------------------------------------
  13. #define RF_PIN 14
  14. #define RF_CHANNEL 31
  15. #define RF_DEVICE 1
  16. //--------------------------------------------------------------------------------
  17. // DHTXX temperature/humidity sensor
  18. // Enable support by passing ENABLE_DHT=1 build flag
  19. //--------------------------------------------------------------------------------
  20. #define DHT_PIN 14
  21. #define DHT_UPDATE_INTERVAL 60000
  22. #define DHT_TYPE DHT22
  23. #define DHT_TIMING 11
  24. #define DHT_TEMPERATURE_TOPIC "/temperature"
  25. #define DHT_HUMIDITY_TOPIC "/humidity"
  26. #define HUMIDITY_NORMAL 0
  27. #define HUMIDITY_COMFORTABLE 1
  28. #define HUMIDITY_DRY 2
  29. #define HUMIDITY_WET 3
  30. //--------------------------------------------------------------------------------
  31. // DS18B20 temperature sensor
  32. // Enable support by passing ENABLE_DS18B20=1 build flag
  33. //--------------------------------------------------------------------------------
  34. #define DS_PIN 14
  35. #define DS_UPDATE_INTERVAL 60000
  36. #define DS_TEMPERATURE_TOPIC "/temperature"
  37. //--------------------------------------------------------------------------------
  38. // Custom current sensor
  39. // Check http://tinkerman.cat/your-laundry-is-done/
  40. // Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/
  41. // Enable support by passing ENABLE_EMON=1 build flag
  42. //--------------------------------------------------------------------------------
  43. #define EMON_ANALOG_PROVIDER 0
  44. #define EMON_ADC121_PROVIDER 1
  45. // If you select EMON_ADC121_PROVIDER you need to enable and configure I2C in general.h
  46. #define EMON_PROVIDER EMON_ANALOG_PROVIDER
  47. #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
  48. #define EMON_CURRENT_PIN 0
  49. #define EMON_ADC_BITS 10
  50. #define EMON_REFERENCE_VOLTAGE 1.0
  51. #define EMON_CURRENT_PRECISION 1
  52. #define EMON_CURRENT_OFFSET 0.25
  53. #endif
  54. #if EMON_PROVIDER == EMON_ADC121_PROVIDER
  55. #define EMON_ADC121_ADDRESS 0x50
  56. #define EMON_ADC_BITS 12
  57. #define EMON_REFERENCE_VOLTAGE 3.3
  58. #define EMON_CURRENT_PRECISION 2
  59. #define EMON_CURRENT_OFFSET 0.10
  60. #endif
  61. #define EMON_CURRENT_RATIO 30
  62. #define EMON_SAMPLES 1000
  63. #define EMON_INTERVAL 10000
  64. #define EMON_MEASUREMENTS 6
  65. #define EMON_MAINS_VOLTAGE 230
  66. #define EMON_APOWER_TOPIC "/apower"
  67. #define EMON_ENERGY_TOPIC "/energy"
  68. #define EMON_CURRENT_TOPIC "/current"
  69. //--------------------------------------------------------------------------------
  70. // HLW8012 power sensor (Sonoff POW)
  71. // Enable support by passing ENABLE_POW=1 build flag
  72. // Enabled by default when selecting SONOFF_POW hardware
  73. //--------------------------------------------------------------------------------
  74. #define POW_SEL_PIN 5
  75. #define POW_CF1_PIN 13
  76. #define POW_CF_PIN 14
  77. #define POW_USE_INTERRUPTS 1
  78. #define POW_SEL_CURRENT HIGH
  79. #define POW_CURRENT_R 0.001
  80. #define POW_VOLTAGE_R_UP ( 5 * 470000 ) // Real: 2280k
  81. #define POW_VOLTAGE_R_DOWN ( 1000 ) // Real 1.009k
  82. #define POW_POWER_TOPIC "/power"
  83. #define POW_CURRENT_TOPIC "/current"
  84. #define POW_VOLTAGE_TOPIC "/voltage"
  85. #define POW_APOWER_TOPIC "/apower"
  86. #define POW_RPOWER_TOPIC "/rpower"
  87. #define POW_PFACTOR_TOPIC "/pfactor"
  88. #define POW_ENERGY_TOPIC "/energy"
  89. #define POW_UPDATE_INTERVAL 5000
  90. #define POW_REPORT_EVERY 12