Solar diverter project using an ESP32 and solid state relay

I have built a very simple generic solar diverter based on an ESP32 and Solid State Relay (SSR) that diverts excess solar power using the multi-sinewave approach. I am using it to modulate the amount of power going into resistive loads inside heaters. At the moment it uses the ESP32 software created by F1ATB. A description is available at his site https://f1atb.fr/fr/realisation-dun-routeur-photovoltaique-multi-sources-multi-modes-et-modulaire/

This is an alternative approach to the usual method of utilising an SCR to constantly chop parts out of every sinewave which generated lots of harmonics and messes up power measurement. It is also very very simple and only needs the ESP32 and SSR with no additional components at all.

I tried his method and it seems to work fairly nicely but there is a slight delay as I feed the net power measurement via MQTT from Home Assistant, so there can be a bit of overshooting of the target power of net zero. What I would like to do is use ESPhome instead and write the code there to do the SSR control.

My questions are:

  1. Has anyone here already tried something like this or does anyone want to help as my ESPhome coding skills are more or less non-existent just now?
  2. Is the right place for the control code inside ESPHome or is better in an HA automation which I am a lot more familiar with.
  3. The maximum update frequency must be more than 20ms, is ESPhome happy updating at that speed?

I have DIY triac based diverter for few years now. I personally have no problems with interferences, neither power measurement.
I didn’t read your description for F1ATB, but I suggest to not route time critical info through HA/MQTT . Also Esphome loop cycle is quite long, minimum 16ms.
What device is measuring net power? Measurements could be sent directly?

ps. “multi-sinewave” aka pulse train didn.t work for me, it was my first option…

I have various ct clamp power monitors. The best has been the Aliexpress bidirectional dual power monitor and the PZEM004’s that montior specific circuits like the EV solar charger. The previous units like Current Cost Clamp meter are very affected by my triac hot water diverter when it is running
I could attach power measurement directly to the ESP32 as I did build that circuit but found it also to be very inaccurate which came down to the poor onboard ADC.

So I need the net power monitor to instruct the solar diverter every second which pulse train to output. Hopefully a 16ms loop time should be fine for that. That also means that I can schedule all the priorities for power directly from HA automations. e.g. heat the hot water first, then charge the car whilst giving the excess to the heaters etc.

I use Shelly Em for “total” energy measurement and get actual power through Shellys HTTP api to Esphome device. It’s very accurate even for small loads.

Billybob,
Hopefully you have solved your issues by now but if not, I have independently built a similar diverter to what you describe and can share data and HA/ESPHome code if still interested. In answer to your queries:

  1. My diverter uses 1 second updated mqtt nett consumption data from an enphase envoy to control a zero crossing SSR based PWM power control module feeding a 3.6kW water heater element. Results have been very good.
  2. My objective was to carry out the bulk of the control in Home Assistant as I find ESPHome coding for an ESP32s microcontroller very tedious. This greatly simplifies the power controller with the ESP32 just receiving a % demand setpoint from Home Assistant and converting it to the PWM durations for the SSRs. I have used two SSRs setup in 180degree out of phase PWM control and mounted on large H style heatsinks to ensure cool operation even in 40DegC+ ambient conditions. I use a PWM frequency of 2Hz which keeps the utility meter happy seeing the PWM import/export cycles as a single nett export value. The 180Deg split phase PWM helps in this regard as well there being 4 PWM bursts of mains power cycles per second.
  3. My experience is that you do not need a data or control update period anywhere near 20msec. My 1 second mqtt data update rate seems perfectly adequate. I estimate that the overall response of the diverter to switching on a large non water heater load is a few seconds. Sure this produces a brief import spike while the diverter adjusts but over a day this is immaterial. It is pointless chasing perfection in faster response as the cost of these import spikes is neglible.

An interesting solution. I also use an SSR with zero cross detection.

Excess Electricity Compensation

Here, the ESP32 actually handles all tasks and doesn’t require a higher-level system like HA.

Since multiple controllers are active simultaneously, a small power management system is also integrated to prevent them from “fighting” each other.

I have used two SSRs setup in 180degree out of phase PWM control

How did you implement this?

John

John, the below ESPHome code snippet from my application best explains the method of achieving 180degree offset for the SSR PWM outputs.
The two ledc PWM outputs utilise adjacent low number channels. In this case channels 8 & 9. Line 44 specifies that the SSR2 PWM output is 180degrees offset from the channel. The default offset used for SSR1 is 0degrees offset.

33 output:
34 - platform: ledc #This ledc drives SSR1
35 pin: GPIO1
36 id: ssr1output
37 channel: 8
38 frequency: 2 Hz
39 - platform: ledc #This ledc drives SSR2
40 pin: GPIO3
41 id: ssr2output

42 channel: 9
43 frequency: 2 Hz
44 phase_angle: 180

Lucky you.
I tried as well but meter was way smarter than me, also my inverters zero export feature got crazy and even Shelly EM got completely useless.
I had to go with phase-cut approach.

Are you using a burst fire appoach here with bursts of .5 second on and off pulses?

I tried a burst fire immersion controller (not using HA) and got complaints from the neighbour about his lights flickering. I couldn’t find a way to keep inside the EMI statutory limits. So I went back to chopped single waves with an EMI filter. Never had a problem with EMI in >10 years in 3 different houses.

Just common line filter or something else?

Not a common mode choke I think. Cost well over £20 so not simple. Can’t remember the details now.

Solar2, sorry for the delay in replying, was busy on other matters.
I use zero crossing SSRs to minimise mains interference. Although the SSR zero crossing detectors are not perfect and the firing and switch off can occur at up to around 30v of mains voltage, I have not been able to detect any increase in EMI from my house wiring whether the solar diverter is running or not using an AM radio set to around 500kHz. I purposely restricted the pulse widths used to whole numbers of mains sine waves to further help minimising potential EMI and prevent imposing a DC component on the mains supply. This limits me to 25 power steps but the diverter still works fine.
So, from my experience, the key to minimising EMI in a PWM system is to use zero crossing SSRs which only turn on or off near the mains waveform zero crossing voltage point and only use pulse widths corresponding to a whole number of mains sine waves.
If you are interested, I can provide the complete ESP32 code as a starting point for you.
Regards