Roboteq Arduino Serial string

Hi folks,

I have a roboteq motor controller and I would like to control it and an arduino Mega which has more than one ttl channels.
I have to mention that my knowledge with serial programing is very low and I'll need your precious help on this.

First of all I am sending a telemetry string from my roboteq through the serial line, it is a string with some different infos like voltage, amps, temperature, encoder counts, etc, this string is terminated with "/r" for the arduino to know that the string is completed.
Now, my first need is to receive the string on the arduino as it is and print it on the terminal window just to see how the string is constructed in order to understand how to parse it later.

Can someone share a piece of code that can do this?

Thank in advance

Kind regards

Do a search for the Serial Input Basics - updated thread to get ideas.

Is the terminator the string /r or the character \r (carriage return)?

Hi, you are right, it is \r

I have read quite a lot about serial comunication but the more I read the more confused I get.

Do you mean the example #2 of that thread?

Yes; just change the endmarker. Depending on the length of the text that you receive, you might have to change

const byte numChars = 32;

to a bigger number.

Read from e.g. Serial1 instead of Serial.

If you're also planning to receive data from serial monitor as well, it's advisable to modify the example now.
1)
Rename the function recvWithEndMarker to e.g recFromRoboteq so you know what happens in loop.
2)
Change the names of the involved variables so they reflect what they are used for
e.g. replace receivedChars by roboteqRxBuffer and newData to roboteqNewData

sterretje, awesome help you gave me... I'll try that in about an hour...

Thanks