I’ve been searching trying now for hours without finding a solution for my problem.
I have a on old RFID Card Reader from a door access system which communicates by UART.
I would like to get the Card ID into a text sensor via ESPHome (Wemos D1).
Inside the Arduino IDE I can successfully get the data. Also with the UART Debugging Function from the esphome-website I get the readings from the Reader.
This is the value that I get from the reader, when using the debugging from ESPHome.
\x02n110A1C000E1F003038\x03d
So now my problem. I am unable to get any value with the Custom UART Text Sensor.
I configured everything as mentioned in the ESPHome Cookbook ( Custom UART Text Sensor — ESPHome, but the Text Sensor won’t update, when I try to read a card.
From my point of view it looks like that the RFID Reader is not sending \n as delimiter, but I am not that experienced in this type of communication to verify this.
Does anybody have an Idea what I am missing here or what else I could try to get this working with ESPHome?
String readString;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available()) {
delay(2); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString.substring(5,20));
readString="";
}
}
That code gives me this as output: A1C000E1F003038
So it looks like you need to either customize the uart_read_line_sensor.h to deliminate on \x03d and substring the header.
Or you could bulk replace everything in the uart_read_line_sensor.hwhile loop with the Arduino while code. Obviously the Serial.println won’t work but you can replace that with the appropriate publish_state