Could you upload your code please?
For the GIF shown above, I only built a microcontroller with ESPHome on a phase angle dimmer. With the light function I could control the phase angle (=power). I haven’t had time for automation yet. My plan is for the future when I have replaced my heating rods with a heat pump. To control the power of the heat pump with the pwm signal of the microcontroller.
Just re-found my post here - but my question still remains: is it possible to achieve efficient (i.e. proportional) use of solar surplus with a simple on-off pulsing switch? I still don’t think so - some kind of phase-angle device must be needed at the hardware level for the utility meter to not “see” any positive import pulses?
Hi,
I want to set up a zero export with my heater-rod, but can’t get it working.
Any help appreciated!
I want (0 up to 1) values out of sensor.power_export to control the power level.
sensor:
#Powerfactor - Leistungsberechnung
- platform: template
name: "Leistungsfaktor"
id: pwrfactor
unit_of_measurement: '%'
accuracy_decimals: 0
lambda: |-
float allowed_power = id(pwrfactor).state/100.0;
float temp_pwr = 0.0;
float max_pwr = 1000;
id(KemoM240).set_level(allowed_power);
return allowed_power*100;
update_interval: 5s
#PV Überschuss von Homeassistant
- platform: homeassistant
id: grid_power_supplied
name: "PV-Überschuss"
entity_id: sensor.power_export
internal: false
unit_of_measurement: W
accuracy_decimals: 0
on_value:
then:
- component.update: pwrfactor
Hi, I’m interested in use my solar surplus in a radiator heater.
My approach is using esp32 , state solid relay with zero cross integrated in it. , and pzem004.
The esphome esp32 gets the surplus in watt from home assistant. I have Huawei inverter. And the consumption of the heater with the pzem004
The idea is adjusting the pwm make the surplus equal to 0.
Not yet I have the components, I will post de progress.
Before you buy randomly components, may I suggest you to do research how your electricity meter is sampling and measuring the consumption. That tells you what hardware you need.
Hi, Finally I did some test and it works fine!
This project uses 240V, so take care! And because to adjust consumption it trims the electricity wave, it can be only used for pure resistive loads
For this project I’m using
- ESP32
- robotdyn pwm triac module
- PZEM004T(only for monitoring)
- RGB led (because I have an spare one)
The original Triac is a BTA16-600B, for a 2000W heater is too small, you can replace for an BTA41-700B. This triac is bigger, so yo need to extend with wires (The wires must be as short as possible and 2.5mm thick). Also you need an aluminium heatsink of sufficient size.
BTAxx-xxxB → for this project any like this reference is fine.
esphome:
name: excedent-solar-pid
friendly_name: Excedent Solar PID
esp32:
board: esp32dev
framework:
type: arduino
logger:
level: INFO
api:
encryption:
key: "xxxxx"
ota:
platform: esphome
password: "xxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "Excedent-Solar-TRIAC"
password: !secret wifi_password
captive_portal:
# Globals per al nivell (amb suavitzat)
globals:
- id: nivell_target
type: float
initial_value: "0.0"
- id: nivell_suau
type: float
initial_value: "0.0"
- id: pas_ajust
type: float
initial_value: "0.02" # 2% per lectura HA (suau)
# UART PZEM
uart:
tx_pin: 17
rx_pin: 16
baud_rate: 9600
# Sortida TRIAC (RobotDyn AC Dimmer)
output:
- platform: ac_dimmer
id: ac_dimmer_resistencia
gate_pin: 23
zero_cross_pin:
number: 22
mode:
input: true
pullup: true
min_power: 0%
max_power: 100%
# Suavitzat cap al nivell target (rampa suau)
interval:
- interval: 500ms
then:
- lambda: |-
float dif = id(nivell_target) - id(nivell_suau);
id(nivell_suau) += dif * 0.4f; // 40% cada 0.5s ≈ constant i suau
if (id(nivell_suau) < 0.0f) id(nivell_suau) = 0.0f;
if (id(nivell_suau) > 1.0f) id(nivell_suau) = 1.0f;
if (id(control_auto).state) {
id(ac_dimmer_resistencia).set_level(id(nivell_suau));
} else {
id(ac_dimmer_resistencia).set_level(0.0f);
id(nivell_suau) = 0.0f;
}
ESP_LOGI("control", "TRIAC: target %.0f%% → suau %.0f%%",
id(nivell_target)*100.0f, id(nivell_suau)*100.0f);
- interval: 10s
then:
- lambda: |-
float n = id(nivell_suau);
float r, g, b;
if (n <= 0.0f) { r=0; g=0; b=80; }
else if (n < 0.5f) { float f=n/0.5f; r=255*f; g=255; b=0; }
else { float f=(n-0.5f)/0.5f; r=255; g=255-(255*f); b=0; }
auto call = id(led_excedent).turn_on();
call.set_rgb(r/255.0f, g/255.0f, b/255.0f);
call.set_transition_length(1000);
call.perform();
# Sensors
sensor:
# PZEM: potència càrrega (informatiu)
- platform: pzem004t
id: pzem
power:
name: "Potència Càrrega Resistiva"
id: pot_estufa
unit_of_measurement: "W"
# Huawei: excedent (+) / compra (−)
- platform: homeassistant
name: "Potència Injectada (Huawei)"
entity_id: sensor.huawei_huawei_meter_active_power
id: pot_injectada
on_value:
then:
- lambda: |-
float v = x * 1000.0f;
if (v > -50.0f && v < 50.0f) return;
float niv = id(nivell_target);
// Ajust proporcional al desfasament (més ràpid si hi ha molt excedent)
float delta = v / 2000.0f; // divideix pel marge desitjat (2 kW = canvi total)
niv += delta;
if (niv > 1.0f) niv = 1.0f;
if (niv < 0.0f) niv = 0.0f;
id(nivell_target) = niv;
ESP_LOGI("excedent", "Huawei: %.1f W → target %.0f%%", v, niv*100);
# WiFi RSSI
- platform: wifi_signal
name: "Intensitat WiFi ESP32"
id: wifi_signal_sensor
update_interval: 60s
# Percentatge actual TRIAC (per HA)
- platform: template
name: "Percentatge TRIAC"
id: percentatge_triac
unit_of_measurement: "%"
accuracy_decimals: 0
update_interval: 5s
lambda: |-
return id(nivell_suau) * 100.0f;
# Switch de control automàtic
switch:
- platform: template
name: "Control Automàtic Excedent"
id: control_auto
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
# LED RGB indicador (WS2812B)
light:
- platform: fastled_clockless
id: led_excedent
name: "Indicador Excedent"
internal: true
chipset: WS2812B
pin: 25
num_leds: 1
rgb_order: GRB
# Color LED segons nivell (cada 10 s)
Robotdyn has also module with BTA24.
Be aware that the formula used in ac_dimmer library is an approximation. There is noticeable error when close to min and max power.
He made no such thing! Why would lie to my friends on here about that? ; ) jk man.
Just saying Hey and Hope all is well.