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:
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?
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.
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:
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.
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.
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.
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.
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.
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
Zero crossing is good to minimise the EMI but am not sure any method that uses burst of whole sine waves is going to pass the flicker standard. If your supply has a low impedence though it may be OK as the flicker standard assumes an average impedence.
In reality a lot of people ignore the flicker standard and get away with it.
Many thanks for the code offer but i am happy with what I have thanks.
Interesting.... I'm currently using a Kemo which receives a PWM signal through an ESP32.
I'm using the 'LEDC' platform on 1000 Hz.
This has been running perfectly for almost 1.5 year now. But I'm not very satisfied with the additional parts required to run this. (resistors/transistors etc to go from 3.3v to 5v etc).
The system is coordinated through an automation in Home Assistant. This raises or lowers the ledc output percentage.
At the moment I'm looking at a SSR relay now and looking at the possibilities of using it directly with an ESP32.
Which SSR's have you been using? Anyone got examples of their code?
You can look for "proportional Solid State Relay", they usually have some standard control method like 0-10V or PWM.
If I had to build my setup today from scratch, I would go with these (including uart controller):