settings.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. // PRE-COMPILE CONFIGURATION
  2. // DEBUG SETTINGS - ONLY FOR DEVELOPMENT!!!
  3. // WARNING !!
  4. // - possibly reveals stored passwords
  5. // - some functions use different timeouts intended for testing (iE in heat control variant)
  6. // - shows a "DEBUG" note in web interface
  7. // - DO NOT USE FOR PRODUCTION!!!
  8. //#define DEBUGMODE
  9. // some more debug output:
  10. //#define DEBUG_VERBOSE
  11. // if enabled LittleFS filesystem is formatted on every startup.
  12. // only applicable during development sometimes...
  13. //#define FORCE_FILESYSTEM_FORMAT
  14. // END OF DEBUG SETTINGS
  15. // define language - if no other language is defined, default (EN) is used
  16. #define LANG_DE
  17. // serial baudrate for startup debugging
  18. // will be overwritten by firmware configuration during start/setup
  19. #define SERIAL_BAUDRATE 57600
  20. // SELECT FIRMWARE VARIANT TO BUILD
  21. // can/should be set by compiler flag from PlatformIO
  22. // this enables all firmware features that are needed for the variant
  23. // but if more features are desired they can be enabled below
  24. // - setting a firmware variant will DISABLE features that are not compatible with it
  25. //#define FIRMWARE_VARIANT_THERMOSTAT
  26. //#define FIRMWARE_VARIANT_HEATCONTROL
  27. // ENABLE FEATURES
  28. #define ENABLE_FEATURE_SECRETS_ENCRYPTION
  29. // if disabled will be stored on LittleFS in file /confSecrets
  30. // encryption is also applied if ENABLE_FEATURE_SECRETS_ENCRYPTION is enabled and encryption is enabled in the firmware
  31. // but for a little extra security storing the data in EEPROM is recommended
  32. #define STORE_SECRETS_IN_EEPROM
  33. // enable NTP time server sync - currently only used for correct time in logger ;-)
  34. #define ENABLE_FEATURE_NTP_TIME
  35. // legacy (buffered) web console that does not use WebSockets
  36. // disable this to save >4k RAM and use new WSconsole instead
  37. #define ENABLE_FEATURE_WEB_CONSOLE
  38. // enable Web Console using WebSockets
  39. #define ENABLE_FEATURE_WSCONSOLE
  40. // enable OTA Updates via Web-Interface
  41. #define ENABLE_FEATURE_HTTP_UPDATER
  42. // enable Arduino-OTA (direct firmware upload from PlatformIO)
  43. // must be switched on in the device configuration afterwards
  44. #define ENABLE_FEATURE_ARDUINO_OTA
  45. // simple LittleFS browser - can only list, upload, download and delete files
  46. #define ENABLE_FEATURE_FILESYSTEM_BROWSER
  47. // I2C interface needed for some sensors, displays, etc.
  48. // is enabled by default when a firmware variant using it is selected
  49. //#define ENABLE_I2C_INTERFACE
  50. //#define ENABLE_SENSOR_DHT22
  51. //#define ENABLE_SENSORS_ONEWIRE
  52. //#define ENABLE_LCD_I2C
  53. //#define ENABLE_I2C_PORTEXPANDER
  54. //#define ENABLE_INPUT_BUTTONS
  55. //#define ENABLE_SENSOR_PIR
  56. //#define ENABLE_OUTSIDE_TEMP_MQTT
  57. // DEFINITIONS OF FIRMWARE VARIANTS
  58. // DO NOT EDIT BELOW!!!
  59. #define DISPLAY_USE_MINIMAL_LAYOUT
  60. #ifdef FIRMWARE_VARIANT_THERMOSTAT
  61. #undef FIRMWARE_VARIANT_HEATCONTROL
  62. #define ENABLE_I2C_INTERFACE
  63. #define ENABLE_SENSOR_DHT22
  64. #define ENABLE_LCD_I2C
  65. #define ENABLE_INPUT_BUTTONS
  66. #define ENABLE_SENSOR_PIR
  67. #define PIN_THERMOSTAT_OUTPUT 15 // 16
  68. #define PIN_DHTSENSOR 2
  69. #define DHTTYPE DHT22 // DHT sensor type
  70. #define PIN_BUTTON_PLUS 2
  71. #define PIN_BUTTON_MINUS 0
  72. #define PIN_BUTTON_MODE 14
  73. #define PIN_PIRSENSOR 12
  74. #define PIN_I2C_SDA 5
  75. #define PIN_I2C_SCL 4
  76. #define PCF8574_I2C_ADDRESS 0x20
  77. #define LCDADDR 0x27 // I2C address LCD
  78. #define LCDCOLS 16 // LCD cols
  79. #define LCDLINES 2 // LCD lines
  80. // default logic levels
  81. #define BUTTONONSTATE LOW
  82. #define THERMOSTAT_OUTPUT_ONSTATE HIGH
  83. #undef DISPLAY_USE_MINIMAL_LAYOUT
  84. #endif
  85. #ifdef FIRMWARE_VARIANT_HEATCONTROL
  86. #undef FIRMWARE_VARIANT_THERMOSTAT
  87. #undef DISPLAY_USE_MINIMAL_LAYOUT
  88. #define ENABLE_I2C_INTERFACE
  89. #define ENABLE_SENSOR_DHT22
  90. #define PIN_DHTSENSOR 2
  91. #define DHTTYPE DHT22 // DHT sensor type
  92. #define PIN_BUTTON_MODE 12
  93. #define PIN_I2C_SDA 5
  94. #define PIN_I2C_SCL 4
  95. #define PCF8574_I2C_ADDRESS 0x20
  96. #define LCDADDR 0x27 // I2C address LCD
  97. #define LCDCOLS 16 // LCD cols
  98. #define LCDLINES 2 // LCD lines
  99. // default logic levels
  100. #define BUTTONONSTATE LOW
  101. #define ENABLE_SENSORS_ONEWIRE
  102. #define ONE_WIRE_BUS 13
  103. #define ONEWIRE_SENSORS_COUNT 3
  104. #define ONEWIRE_SENSOR_INDEX_FEED 0
  105. #define ONEWIRE_SENSOR_INDEX_RETURN 1
  106. #define ONEWIRE_SENSOR_INDEX_OUT 2
  107. #define ENABLE_LCD_I2C
  108. #define ENABLE_INPUT_BUTTONS
  109. #define ENABLE_I2C_PORTEXPANDER
  110. #ifdef DEBUGMODE
  111. #define HEATCONTROL_TESTMODE_MINUTES 2
  112. #define HEATCONTROL_PUMP_BACKLASH 1
  113. #else
  114. #define HEATCONTROL_TESTMODE_MINUTES 15
  115. #define HEATCONTROL_PUMP_BACKLASH 5
  116. #endif
  117. #endif
  118. #ifdef ENABLE_SENSOR_PIR
  119. #ifndef ENABLE_INPUT_BUTTONS
  120. #define ENABLE_INPUT_BUTTONS
  121. #endif
  122. #endif
  123. #ifdef ENABLE_LCD_I2C
  124. #ifndef ENABLE_I2C_INTERFACE
  125. #define ENABLE_I2C_INTERFACE
  126. #endif
  127. #endif
  128. #ifdef ENABLE_I2C_PORTEXPANDER
  129. #ifndef ENABLE_I2C_INTERFACE
  130. #define ENABLE_I2C_INTERFACE
  131. #endif
  132. #endif
  133. // some settings
  134. #define WEB_CONSOLE_BUFFER_SIZE 4000
  135. #define ARDUINO_OTA_PORT 8266
  136. // default values, can later be overridden via configuration
  137. #define MAX_MEASUREMENT_AGE 30000 // in ms, for measured inside Temp/Hum
  138. #define MAX_MEASUREMENT_AGE_OUT 300000 // in ms, for received outside Temp/Hum
  139. // NTP defaults
  140. #ifdef ENABLE_FEATURE_NTP_TIME
  141. #define DEFAULT_NTP_ENABLED true
  142. #define DEFAULT_NTP_SERVER "pool.ntp.org"
  143. #define DEFAULT_NTP_SYNC_INTERVAL 7200
  144. #define DEFAULT_TIMEZONE "CET-1CEST,M3.5.0/02,M10.5.0/03"
  145. #endif
  146. // confDevWiFi
  147. //#define DEVICE_NAME "WTherm-1" // now created from FIRMWARE_SHORTNAME + last 2 octets of MAC address
  148. //#define DEFAULT_HOST_NAME "" // now created from FIRMWARE_SHORTNAME + last 2 octets of MAC address
  149. #define DEFAULT_WIFI_APMODE_PASSWORD "nichtsicher" // min 8 chars!
  150. #define DEFAULT_WIFI_APMODE_TIMEOUT 5 //min
  151. #define DEFAULT_WIFI_RETRY_INTERVAL 5 //min
  152. #define DEFAULT_WIFI_CONNCHECK_INTERVAL 20 //s
  153. #define DEFAULT_WIFI_REBOOT_ONNOCONNECT 60 //min
  154. // confWeb
  155. #define HTTP_SET_TOKEN ""
  156. #define DEFAULT_HTTP_USER ""
  157. #define DEFAULT_HTTP_PASS ""
  158. #define DEFAULT_HTTP_USER_AUTH false
  159. #define DEFAULT_ENABLE_WEBCONSOLE true
  160. // confMqtt
  161. #define MQTT_ENABLE false
  162. #define MQTT_SERVER ""
  163. #define MQTT_PORT 1883
  164. #define MQTT_USER ""
  165. #define MQTT_PASS ""
  166. #define MQTT_TOPIC_IN "Test/ESPHeiz"
  167. #define MQTT_TOPIC_OUT "Test/ESPHeiz/stat"
  168. #define MQTT_OUT_RETAIN false
  169. #define MQTT_OUT_RETAIN_SENSORS false
  170. #define MQTT_OUT_PUBLISH_INTERVAL 0 // min, 0=only on change
  171. #define MQTT_OUT_PUBLISH_INTERVAL_SENSORS 5 // min, 0=only on change
  172. #define MQTT_WILLTOPIC "Test/ESPHeiz/availability"
  173. #define MQTT_WILLQOS 2
  174. #define MQTT_WILLRETAIN false
  175. #define MQTT_WILLMSG "offline"
  176. #define MQTT_CONNMSG "online"
  177. #define MQTT_ENABLE_HEARTBEAT true
  178. // max interval for MQTT heartbeat message. only applicable if MQTT
  179. // IN-topic is defined. after this timeout MQTT reconnect is forced
  180. #define MQTT_HEARTBEAT_MAXAGE 180000
  181. // max interval for MQTT heartbeat message. only applicable if MQTT
  182. // IN-topic is defined. after this timeout the ESP will reboot
  183. #define MQTT_HEARTBEAT_MAXAGE_REBOOT 1800000
  184. // confBas
  185. #define DEFAULT_SETTEMP_MIN 16.0 // minimal temperature that can be set
  186. #define DEFAULT_SETTEMP_MAX 26.0 // maximal temperature that can be set
  187. #define AUTOSAVE_SETTEMP true
  188. #define AUTOSAVE_SETMODE false
  189. #define SAVE_TO_MQTT_RETAINED false
  190. #define DEFAULT_MEASURE_INTERVAL 15 // interval for temp/hum measurement
  191. // interval for display updates (if out-temp is active, display will toggle
  192. // in this interval)
  193. #define DEFAULT_DISPLAY_INTERVAL 5
  194. #define DEFAULT_DISPLAY_TIMEOUT 30 // display timeout after keypress (illumination)
  195. #define DEFAULT_PIR_ENABLES_DISPLAY false
  196. #define DEFAULT_PIR_ENABLES_DISPLAY_PRESET0_ONLY true
  197. #define DEFAULT_TOGGLING_I_O_TEMPHUM false
  198. // confAdv
  199. #define DEFAULT_HYSTERESIS 0.15 // hysteresis, normally 0.1 - 0.3
  200. #define DEFAULT_HEATING_MIN_OFFTIME 300 // minimal time the heating must keep turned off until it can start again, in s
  201. // correction value for temperature sensor reading
  202. #define TEMPSENSOR_CORRECTION_VALUE 0.0
  203. #define HUMSENSOR_CORRECTION_VALUE 0 // correction value for humidity sensor reading
  204. // decreases the set temp to overcome further temperature rise when the
  205. // heating is already switched off
  206. #define SETTEMP_DECREASE_VALUE 0.0
  207. #define OFF_MESSAGE "HEATING OFF"
  208. #define INSIDE_TEMP_LABEL "I"
  209. #define OUTSIDE_TEMP_LABEL "O"
  210. #define MODE_NAME_0 "off"
  211. #define MODE_NAME_1 "heat"
  212. #define PRESET_NAME_0 "Normal"
  213. #define PRESET_NAME_1 "Reduction 1"
  214. #define PRESET_NAME_2 "Reduction 2"
  215. // confAdd
  216. #define OUTTEMP_TOPIC_IN ""
  217. #define OUTHUM_TOPIC_IN ""
  218. #define MQTT_TOPIC_PIR "" // extra publish topic for PIR sensor
  219. #define MQTT_TOPIC_PIR_ON "ON"
  220. #define MQTT_TOPIC_PIR_OFF "OFF"
  221. // confLog
  222. #define DEFAULT_LOGLEVEL_SERIAL LOGLEVEL_DEBUG
  223. #define DEFAULT_LOGLEVEL_WEB LOGLEVEL_INFO
  224. #define DEFAULT_LOGLEVEL_MQTT LOGLEVEL_INFO
  225. #define DEFAULT_LOGLEVEL_SYSLOG LOGLEVEL_DEBUG // SYSLOG not implemented yet
  226. #define LOG_WEB_REQUESTS false
  227. // other (not configurable via commands/WebIF)
  228. #define DEFAULT_SETTEMP_HEATOFF 5.0 // heating target temperature in OFF mode (freezing guard, therefore > 0)
  229. #define SETTEMP_LOW_MIN 14.0 // minimal configurable temperature for reduction mode
  230. #define SETTEMP_LOW_MAX 21.5 // maximal configurable temperature for reduction mode
  231. // default initial values
  232. #define DEFAULT_SETTEMP 21.5
  233. #define DEFAULT_HEATINGMODE 1
  234. #define DEFAULT_PRESET 1
  235. #define DEFAULT_SETTEMP_LOW 20.0 // set temperature in night/low mode
  236. #define DEFAULT_SETTEMP_LOW2 17.0 // set temperature in night/low mode
  237. // COMPILE TIME SETTINGS
  238. // default values that can only be configured at compile time / hardware configuration
  239. #define BUTTON_DEBOUNCE_TIME 120
  240. #define BUTTON_HOLD_TIME 750
  241. // pin assignments and I2C addresses
  242. //#define USE_MQTT_TLS
  243. // currently does not work
  244. #ifdef USE_MQTT_TLS
  245. static const char *MQTT_TLS_fingerprint PROGMEM = "EC 0E 4B 32 77 6B 6A 03 C6 60 37 A4 DD 0C 4C 47 BC 2D 11 23";
  246. //static const char *MQTT_TLS_fingerprint PROGMEM = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
  247. #endif
  248. // ---------------------------------------------------------
  249. //#define DEBUG_SECRETS_ENCRYPTION // WARNING - reveals secrets on the console!!!