Reading a tab-deliminated ASCII text at a 9600 baud rate using serial monitor

Hello There , hope you are fine .

I have a problem with reading the data from a device
( cycle analyst ) it outputs a " tab-deliminated ASCII
text at a 9600 baud rate"
like

first it outputs a header line,
and then at a rate of once a second or 5 times a second
and i want to receive and format the data like above in the serial monitor or any other way i don't know .
Thanks

Is the serial output from the device at TTL levels or maybe RS232 ? Please provide a link to the device that you want to read from

Forget about the formatting for now.

I would start by writing a small sketch that reads the Serial data from the device and prints it on the Serial monitor one character per line.

Have you tried that ?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

If your data is sent with a carriage-return or linefeed character at the end of each line then the second example should be appropriate. You can adapt the parse example to work with that. But make sure you can receive the data properly before worrying about parsing it.

...R

UKHeliBob:
Is the serial output from the device at TTL levels or maybe RS232 ? Please provide a link to the device that you want to read from

Forget about the formatting for now.

I would start by writing a small sketch that reads the Serial data from the device and prints it on the Serial monitor one character per line.

Have you tried that ?

Hi
you will find the data sheet here

The data is at 0-5V CMOS voltage levels

i just see the numbers comes out and do not understand what is to whom ?

The data is at 0-5V CMOS voltage levels

That is good news as you can feed the serial output from the device directly into the Arduino

i just see the numbers comes out and do not understand what is to whom ?

Are you saying that you have managed to read the data from the device and print them on the Serial monitor ?

abdo558:
I have a problem with reading the data from a device
( cycle analyst ) it outputs a " tab-deliminated ASCII
text at a 9600 baud rate"
like

first it outputs a header line,
and then at a rate of once a second or 5 times a second
and i want to receive and format the data like above in the serial monitor or any other way i don't know .

You may follow these steps:
1. Connect the TX-line of CA (Cycle Analyst) with DPin-2 (digital pin 2) of UNO; RX-line of CA with DPin-3 of UNI; GND-line of CA with GND-pin of UNO.

2. Upload the following sketch in the UNO.

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPin-2, STX = DPin-3

void setup()
{
   Serial.begin(9600);
   SUART.begin(9600); //this software UART Port communicates with CA
}

void loop()
{
   byte n = SUART.available();
   if(n !=0)
   {
       char x = SUART.read();
       Serial.print(x)
   }

}

3. Check that the Serial Monitor of UNO/IDE shows data that are coming from CA.

4. If Step-3 works, please upload the following sketch and post the image of the Serial Monitor. This is to understand what 'messages' are coming from the CA against 'header (probably it is -- tab separated : : : : :)' and 'line termination (probably it is -- Newline character 0x0A = '\n')'. These two pieces of information are not explicitly told in the User Manual of the CA. These information will help us to save the data into variables for user analysis and processing.

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPin-2, STX = DPin-3

void setup()
{
   Serial.begin(9600);
   SUART.begin(9600); //this software UART Port communicates with CA
}

void loop()
{
   byte n = SUART.available();
   if(n !=0)
   {
       byte x = SUART.read();
       if(x < 0x10)
       {
          Serial.print('0');
       }
       Serial.Write(x);
   }
}

5. Upload the following sketch to save the variables: V (Battery Voltage, A (Load Current), W (Load), Ah (Battery Ampere-hour), D (Distance), and kph (Speed).

It is left as an exercise.