diff --git a/intern/docker_esphome/templates/config/esphome_popcorn.yaml b/intern/docker_esphome/templates/config/esphome_popcorn.yaml index 1e64af81a94822f99fb2d93275ec7dbf747b7556..465104cb7dec8959d357085e2413e80641348584 100644 --- a/intern/docker_esphome/templates/config/esphome_popcorn.yaml +++ b/intern/docker_esphome/templates/config/esphome_popcorn.yaml @@ -17,13 +17,88 @@ spi: mosi_pin: GPIO23 clk_pin: GPIO18 +climate: + - platform: pid + id: pid_heater + name: "PID Heater Controller" + sensor: pot_sensor + default_target_temperature: 264 + heat_output: pot_heater + control_parameters: + kp: 0.0 + ki: 0.0 + kd: 0.0 + visual: + min_temperature: 0 + max_temperature: 275 + temperature_step: 1 + +button: + - platform: template + name: "PID Heater Autotune" + on_press: + - climate.pid.autotune: pid_heater + +sensor: + - platform: max31855 + name: "Pot Temperature" + id: pot_sensor + cs_pin: GPIO15 + update_interval: 30s + - platform: pid + name: "PID Heater Result" + type: RESULT + - platform: pid + name: "PID PROPORTIONAL Result" + type: PROPORTIONAL + - platform: pid + name: "PID INTEGRAL Result" + type: INTEGRAL + - platform: pid + name: "PID DERIVATIVE Result" + type: DERIVATIVE + - platform: pid + name: "PID HEAT Result" + type: HEAT + +output: + - platform: slow_pwm + pin: GPIO0 + id: pot_heater + period: 15s + - platform: ledc + pin: GPIO4 + id: gpio_4_backlight_pwm + +binary_sensor: +- platform: gpio + pin: + number: GPIO32 + inverted: true + mode: + input: true + pullup: true + name: "Heat Button" + id: heat_button + on_release: + then: + - climate.control: + id: pid_heater + mode: "OFF" + on_press: + then: + - climate.control: + id: pid_heater + mode: HEAT + target_temperature: 264 + font: - file: "gfonts://Roboto" - id: my_font + id: temp size: 115 - - file: "04B03.ttf" - id: b03 - size: 20 + - file: "gfonts://Roboto" + id: text + size: 40 color: - id: my_red @@ -52,21 +127,42 @@ display: rotation: 90° lambda: |- - it.printf(160,120,id(my_font),TextAlign::CENTER,"264°C"); + it.printf(160,120,id(temp),TextAlign::CENTER,"%.1f°C",id(pid_heater).current_temperature); + if ((id(pid_heater).action) == 0) { + it.printf(0,10,id(text),TextAlign::TOP_LEFT,"PID: OFF"); + } + else if ((id(pid_heater).action) == 4) { + it.printf(0,10,id(text),TextAlign::TOP_LEFT,"PID: IDLE"); + } + else { + it.printf(0,10,id(text),TextAlign::TOP_LEFT,"PID: ERROR"); + }; + it.printf(0,230,id(text),TextAlign::BOTTOM_LEFT,"Target: %.1f°C",id(pid_heater).target_temperature); time: - platform: sntp id: ntp_time timezone: 'Europe/Berlin' - -output: - - platform: ledc - pin: GPIO4 - id: gpio_4_backlight_pwm - + light: - platform: monochromatic output: gpio_4_backlight_pwm name: "ILI9341 Display Backlight" id: back_light - restore_mode: ALWAYS_ON \ No newline at end of file + restore_mode: ALWAYS_ON + +text_sensor: + - platform: template + name: "PID State" + id: pid_state + lambda: |- + if ((id(pid_heater).action) == 0) { + return {"OFF"}; + } + else if ((id(pid_heater).action) == 4) { + return {"IDLE"}; + } + else { + return {"NaN"}; + } + update_interval: 5s