Hi, I’m an experienced dev, but new to ESPHome and rusty on C++
I have a UHF RFID reader that just outputs a series of bytes via UART on successful read. I’ve go this working using the generic UART bus with a debug call.
I’d like to create a custom component that listens for UART, then on a delimiter e.g. 0x00 (or possibly a 100ms timeout) takes the buffer (which will contain the last read card ID as a list of bytes). Then publishes this as a hex string to a given MQTT topic, as a JSON string with some other stuff.
I want to be able to configure it with the following:
optional UART bus ID - If none configured then just default to UART bus
mqtt topic - the topic to publish the data to
device-name - can this be gotten from somewhere?
example:
uhf-rfid:
topic: example/rfid/read
This would publish {"device":"my-card-reader","card":"23-23-64-62-14"}
I made a start here → GitHub - NemiahUK/esphome-uhf-rfid but it’s just based on the very limited example in the docs. Any help would be massively appreciated.
Thanks for the info. I’m currently using the UART debug and a lambda call but the delimiter option just doesn’t seem to work properly.
The UART device returns a fixed number of bytes per read, each one is separated by a few 100ms and they contain the same start and end bytes.
I’ve tried setting the delimiter to time based, a specific byte and a fixed length, however it seems to wait until an arbitrary amount of data is in the buffer then dumps it all in one go.