Hi there,
I finally implemented the slowpwm PID following the great example of mcarter14777:
Now my wish is to automate a temperature ramp for increasing and decreasing temperature.
I have found only the light transition.
Is there a way (I am sure there are many) to create a program for the setpoint temperature, for instance: goes from ambient temperature to 65°C 1 deg/minute, stay there for 6 hours and then let it cool at 2°C/minute?
Best it would be if the program is editable before run from the frontend: increase and decrease ramp, stationary temperature, time for stationary temperature.
The code for the slowpwm PID, basically cut and paste from the mcarter14777.
It runs on an esp32 that drives directly a 50A SSR. The load is around 10A.
esphome:
name: pidslowpwm
platform: ESP32
board: esp-wrover-kit
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "b8f1c9c3cf3b466ceea07e8afe4fad04"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pidslowpwm Fallback Hotspot"
password: "zpo00ha4Gyi6"
captive_portal:
#https://community.home-assistant.io/t/diy-electric-grill-powered-by-esphome/232710
### Pull time from Home Assistant because everything needs a clock on it ###
time:
- platform: homeassistant
id: my_time
spi:
miso_pin: GPIO19
mosi_pin: GPIO23
clk_pin: GPIO18
switch:
### Switches for Setting and Getting PID Values in Home Assistant ###
- platform: template
name: "PID Set"
turn_on_action:
- climate.pid.set_control_parameters:
id: pid_climate
kp: !lambda
return id(p_coefficient).state;
ki: !lambda
return id(i_coefficient).state;
kd: !lambda
return id(d_coefficient).state;
- platform: template
name: "Get PID Values"
turn_on_action:
- homeassistant.service:
service: input_number.set_value
data:
entity_id: input_number.p_coefficient
value: !lambda return id(kp).state;
- homeassistant.service:
service: input_number.set_value
data:
entity_id: input_number.i_coefficient
value: !lambda return id(ki).state;
- homeassistant.service:
service: input_number.set_value
data:
entity_id: input_number.d_coefficient
value: !lambda return id(kd).state;
### Switch to reset integral term for PID calculation ###
- platform: template
name: "Reset Integral"
turn_on_action:
- climate.pid.reset_integral_term: pid_climate
### PID Loop ###
climate:
- platform: pid
visual:
min_temperature: 0 °C
max_temperature: 350 °C
temperature_step: 0.1 °C
id: pid_climate
name: "FornelloPID"
sensor: pt100
default_target_temperature: 0°C
heat_output: heater
control_parameters:
kp: 0.001
ki: 0.00003
kd: 0.1
min_integral: 0
max_integral: 0.5
### Slow PWM for PID Output ###
output:
- platform: slow_pwm
pin: GPIO22
id: heater
period: 3s
sensor:
### Sensors to Read PID information into Home Assistant ###
- platform: pid
name: "PID Result"
type: RESULT
- platform: pid
name: "PID Integral Term"
type: INTEGRAL
- platform: pid
name: "PID Derivative Term"
type: DERIVATIVE
- platform: pid
name: "PID Proportional"
type: PROPORTIONAL
- platform: pid
name: "PID P Coefficient"
id: kp
type: KP
- platform: pid
name: "PID I Coefficient"
id: ki
type: KI
- platform: pid
name: "PID D Coefficient"
id: kd
type: KD
- platform: pid
name: "PID Output"
type: HEAT
### Sensors to read input numbers for PID tuning in Home Assistant ###
- platform: homeassistant
name: "P Coefficient"
entity_id: input_number.p_coefficient
id: p_coefficient
- platform: homeassistant
name: "I Coefficient"
entity_id: input_number.i_coefficient
id: i_coefficient
- platform: homeassistant
name: "D Coefficient"
entity_id: input_number.d_coefficient
id: d_coefficient
- platform: max31865
name: "sondaPt100PID"
id: pt100
reference_resistance: 430 Ω
rtd_nominal_resistance: 100 Ω
rtd_wires: 3
cs_pin: GPIO04