PWM control - bit values instead of %

Hello everyone,

I have an electrical heater in my hot water tank that I can control between 45W and 3.2kW via PWM.
I do this with an M5stack PWM module (Atom light platform), which technically works perfectly.
I use the following YAML code for this:

output:
  - platform: ledc
    pin: GPIO22
    id: gpio_22
    frequency: "400Hz

light:
  - platform: monochromatic
    gamma_correct: 0
    output: gpio_22
    name: "Heater_Boiler_Power_Setpoint"

My problem: I can only adjust the power between 10% and 90%, the heating rod then starts at just under 50W, which is about 35W/% over the whole spanā€¦
My goal is to regulate the power in much smaller steps.

Question(s):

  • Can I also transmit bit values from Home Assistant instead of %?
  • In the next step, I would like to regulate the power automatically (availability of PV power), perhaps via a thermostat?

Iā€™m pretty much at a loss at the moment, maybe someone here has an idea?

Thanks and best regards
Jƶrg

I donā€™t think you should be using the light integration. Perhaps a numeric value (clamped between the known power outputs you want) for the wattage is more useful instead?

Actually, Iā€™m looking for a solution to hand over 10bit (or 8bit) values to LEDC, which does the PWM on the esphome side. Monochromatic only provides values in %.
So, monochromatic (and LEDC) is only a ā€œhackā€ for me, to generate a PWM Signal on my ESP32.
The solution is working, the only lack are the unprecise steps of about 35W.

And in the second step, a slow regulator (PID?) for using that amount of PV power that is available.

Use a number entity that goes from 0 to 65535 with the corresponding on_state_change event to control your output. 16 bit precision AND it shows up in your home assistant.

1 Like

Thank you for the hint, Iā€™ll try that out.