I would like to use my Arduino Mega2560 to communicate with an inertial measurement unit CHR-6d. The CHR-6d communicates over a TTL UART at 115200 baud. Therefore its connected to TX1, RX1, 5V and GND. TX0 and RX0 are used for serial communication with the PC.

CHR-6d RX packet structure:

- first three bytes contain 's' 'n' 'p' - this is the start sequence- byte four specifies the packet type (PT)- byte five specifies the number of data bytes to expect (N)- byte N+6 and N+7 contains two-byte checksum

To set the sensor into silent mode I have to send: 73:6E:70:83:00:01:D4. This works while using a software terminal like Hterm. But I can't figure out how to send this sequence using the Mega.

Is it possible that the packet has to be finished with a line feed/carriage return or both?

The sequence of Serial1.write()s is doing what you describe as the packet structure. How do you send it in Hterm? Do you send the hex code string as written in the post? Do you send single bytes using a hex code entry method?

Is it possible that the packet has to be finished with a line feed/carriage return or both?

I don't think so. The Sensor (CHR-6d) will recognize the packet length from byte five. When using HTerm I'm not sending line feed or carriage return as well. I'm just sending let's say 73 6E 70 83 00 01 D4 in hex code entry method for setting the silent mode. And it works just perfect.

Serial1.println(F("73:6E:70:83:00:01:D4"));I've tried this and it seems to work, but now I'm receiving a packet from sensor which contains "buffer_overflow". Meaning the internal receive buffer of the CHR-6d overflows before receiving a full packet. I'm not sure, but should I synchronize Sensor's reading and Mega's writing somehow?

I've tried this and it seems to work, but now I'm receiving a packet from sensor which contains "buffer_overflow". Meaning the internal receive buffer of the CHR-6d overflows before receiving a full packet. I'm not sure, but should I synchronize Sensor's reading and Mega's writing somehow?

If the packet size is limited to 5 bytes (+2 checksum) I understand that the buffer is overflowing with 20 characters sent in the string.