esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
417 stars 26 forks source link

UART: support sending of break signal #1494

Open andyboeh opened 2 years ago

andyboeh commented 2 years ago

Describe the problem you have/What new integration you would like

I am working on a DMX-512 implementation based around the MAX485 IC. The UART can be used for sending data, but a break signal of a specific length needs to be sent before starting the transmission. Unfortunately, this is not supported by the UART component.

Please describe your use case for this integration and alternatives you've tried:

I suggest a new sendBreak(usecs) method that allows sending of the break signal.

Additional context

There are a few workaround options that I could find for different controllers that involve either changing the baud rate on-the-fly and sending a 0 byte or detaching the Tx pin and driving it manually for the break generation. However, that is hardware-specific and can't be done in the DMX component.

martgras commented 2 years ago

Probably the idf function uart_write_bytes_with_break is what you need. But I don't know if it can be used in esphome.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/uart.html#_CPPv427uart_write_bytes_with_break11uart_port_tPKv6size_ti

andyboeh commented 2 years ago

Thanks for the answer and adding this possibility. Unfortunately, according to the docs, it doesn't work without sending data. For DMX, the break has to be sent first.

I think that I'll still be able to come up with a portable solution, though:

Tuckie commented 2 years ago

Thank you for starting to dig into this. Adding this functionality seems a lot cleaner for the dmx-512 implementation.

pruwait commented 1 year ago
  • ESP32 Arduino: pinMatrixOutDetach, set the pin, wait, clear the pin, pinMatrixOutAttach

can you write an example of use in the esphpme component?

andyboeh commented 1 year ago

Check https://github.com/andyboeh/esphome-dmx512, there are separate files for ESP32, ESP8266 and ESP32IDF. Or directly: https://github.com/andyboeh/esphome-dmx512/blob/49541b1e6bb9e897339fd8640298e9b1cc622923/components/dmx512/dmx512esp32.cpp#L11