Output synchronization on AC (Heatzy Pilote)

Hi all,

First post for me here but I have following this forum for years to improve my HA.

I am struggling with a probably “weird” need: to get ride of cloud related issues, I have been trying to implement EspHome on a “Heatzy Pilote” device, based on a ESP8266 (I guess this is a really french-specific stuff).
Overall the retro-engineering of the board was easy and flashing also. Yet, I cannot figure out how to implement the following functionality:

  • the goal is to “alter” the fed AC (board is powered directly by AC via a non-isolated AC/DC converter) to output either the full wave AC, half-wave AC (either positive or negative) or no voltage. This output will be connected to a high impedance system (which will detect the form of the wave and react accordingly). The board is designed so the AC live is directly connected to the DC ground.
  • To do so, the neutral is connected to GPIO12 (via a BJT) - so the GPIO state will indicate if we are in negative or positive wave (since live is connected to DC gnd) and the GPIO5 drives a Triac Photocoupler, which link the live and the output. So GPIO5 is able to ultimately alter the live signal waveform to the output as needed, if correctly synchronized with the AC signal. The original proprietary firmware most probably uses the GPIO12 state to do so.

BUT, I cannot figure out how to do this in ESPhome… I have tried many stuff, based on binary sensors and so on, but I guess these components are not designed to work at 50 Hz. Using the pulse counter or pulse width components works fine to detect the frequency (or width) of AC based on GPIO12 but I cannot link this to GPIO5. Tried also to play with the AC dimmer but I do not think this will work. I thought that maybe trying to use the ESP8266_PWM component and getting a kind a synchronisation based on GPIO12 may do the trick but so far no luck either…

Would somebody have some suggestions how to cope with this need ? (Seems quite simple actually, at least using an Arduino IDE but I am not sure I would be able to write a custom component from scratch for ESP Home…)

Many thanks :grinning:

i asked your post to chatgpt and he had a response, dunno if it’s correct.

Blockquote
Your project involves modifying the behavior of an ESP8266-based device (Heatzy Pilote) to control AC waveforms using GPIO pins. The challenge lies in synchronizing the alteration of the live signal waveform based on the state of GPIO12, and controlling a Triac Photocoupler connected to GPIO5.

Here’s a general outline of how you might approach this in ESPHome:

  1. Frequency Detection: You mentioned that you can successfully detect the frequency of the AC signal using components like pulse_counter or pulse_width. This is a good starting point, as it allows you to know when to trigger the alteration of the waveform.
  2. Synchronization: To synchronize the alteration of the waveform with GPIO12, you may consider using an output component along with the lambda function. The idea is to create a custom output that mimics the state of GPIO12 and use it to control the Triac Photocoupler on GPIO5.

yamlCopy code

output:
  - platform: gpio
    pin: GPIO12
    inverted: true
    id: ac_state

# Synchronize GPIO5 with GPIO12
esphome:
  on_loop:
    then:
      - lambda: |-
          // Synchronize GPIO5 with GPIO12
          if (id(ac_state).state) {
            // GPIO12 is HIGH, alter the waveform
            digitalWrite(5, HIGH);
          } else {
            // GPIO12 is LOW, don't alter the waveform
            digitalWrite(5, LOW);
          }

This is a simple example, and you may need to adjust it based on your specific requirements and the characteristics of the Triac Photocoupler.
3. Waveform Alteration: Use the synchronized GPIO5 signal to control the Triac Photocoupler, altering the AC waveform as needed. You may need to experiment with timing and delays to ensure proper synchronization.
4. Testing and Debugging: Implement logging statements or use the serial output to debug and ensure that the synchronization and alteration of the waveform are happening as expected.

Remember, working with AC power involves potential safety hazards. Ensure that you have the necessary knowledge and precautions in place to handle high-voltage components safely.

If the above approach doesn’t work as expected, you might need to consider more advanced techniques or even writing a custom component. For a custom component, you would need to understand the ESPHome API and possibly write some C++ code. The ESPHome documentation (https://esphome.io/) can provide guidance on creating custom components. Additionally, the ESPHome community forum can be a valuable resource for seeking help or advice from other users with similar experiences.

1 Like

Thanks for your detailed feedback !
I was not aware of the “on_loop” possibilty, I will have a try asap. Yet the documentation indicates “usually around every 16 milliseconds” so I am not sure if this will be fast enough…
The option of custom component is probably the most sensible but also with a steep learning curve, I was hoping that I missed something more accessible :grinning:
Thanks again!