Arduino Mega ASCII communication with rfid device

Hello there,

I'm using Arduino Mega Serial1 port for communicating with rfid RS485 device. I use TTL to RS485 converter with my Mega on pins TX1(18), Rx1(19). I need to send specific ASCII frame to this device, to get back answer:

byte cmd[]={0x09,0x41,0x31,0x46,0x33,0x46,0x0D, 0x0A};

If I use terminal window on my computer to send this frame to the rfid device, I get an answer like it should be, but If I send it with mega, I ain't get an answer at all. I also use terminal window for sniffing port traffic.

Here is my Mega code:

byte cmd[]={0x09,0x41,0x31,0x46,0x33,0x46,0x0D, 0x0A};
void setup()

void loop()
  Serial1.write(cmd, 7);

Terminal-no answer

Could someone tell me what I'm doing wrong?

thanks in advance,

Here is also an answer in terminal window, like it should be if I get an answer from rfid device:

Terminal-answer OK

You are talking to the device using Serial1. But I believe the Arduino connection to your PC is at Serial

Should you redirect received data from Serial1 to Serial?

First thanks for fast answer.
Yes, but I should see in terminal window an answer, right?
You thought that if I wan't to see it in monitor window, I should write this?:

if (Serial1.available())

I did this, but nothing in serial monitor.

I’m no expert with serial but I noticed your byte array is 8 bytes but you’re only writing 7. I don’t know enough to know if that’s the problem just something I noticed.

No it is not, because I just send first 7 bytes.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.