Help With Code To Receive and Process ASCII From Industrial Machine


I'm trying to receive data from a piece of industrial test equipment and process it with an Arduino UNO.

The end goal is to receive two pieces of data (numbers between 0 and 5000; whole numbers and decimals) and display the difference in values on an LCD screen.

To start small, right now I'm just [u]trying to receive data from the tester and display it in the serial monitor[/u].

The serial settings for the tester are set to: BAUD RATE = 9600 DATA BITS = 7 STOP BITS = 1 PARTITY = NONE

I’m using a “Cutedigi” RS232 Shield ( with a null cable connecting the shield and the tester.

I’ve used some sample code that I’ve found online, but I can’t get the test values to show up in the serial monitor. One piece of code just gave many lines of gibberish that I can't understand, but at least it was something.

Is there some simple code for testing this?

Have you got a link the the tester? Are you sure is 7 bits of data? Where did you get that from?


Yes, I'm sure about the bits. The tester allows this to be set to "7" or "8". I set it to "7" as I read in another thread that this is the default for Arduino.

The stops bits can be set to "1" or "2" as well.

This is the link to the tester:

I read in another thread that this is the default for Arduino.

I'd be interested to see that thread. It's 8.


I read in another thread that this is the default for Arduino.

I'd be interested to see that thread. It's 8.

Thanks for the reply! I should just stick with this forum. The previous mis-information came from this site:

I'll set the tester to 8 bits.

Is there sample code that you think might work as a simple test?

I’m trying to use the following sample code from the Arduino serial read() page (

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte =;

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);

I do not see any values appearing in the serial monitor when the tester completes its cycle.

Is typing in the serial monitor and pressing “send” basically the same as receiving data from the test instrument? In other words, can I mimic received data by typing without cycling the tester?

With the Arduino/shield disconnected from the tester, I get the 1st attached image (one line) when I send the number “2” in the serial monitor.

With the Arduino/shield connected (via the null modem cable), I get the 2nd attached image (seemingly infinite lines) when i send the number “2” in the serial monitor.


I just realized that the installed adapter is not a "null modem adapter" but a regular "gender changer".

I will find the null adapter and report results. Sorry for wasting time.

Partial success!

After ensuring a null cable was installed, I conducted a test and have received data within the serial monitor!

The test result should be a value of zero (that’s what the screen on the actual tester says). This is what I get in the serial monitor (see attached, below).

How do I “decode” this?

Along with the test result, the tester can also output the units of measure, “Pass”, “Fail”, “Abort”, “PER” (pressure error detected) or “Gross” (for a gross leak). I just don’t know what the numbers mean in the serial monitor.

This is getting exciting!

Converting that to ASCII it is this:


where I have represented the TAB character (9) by ^
and the numbers in square brackets, e.g. [160], are not ASCII characters so I left them as they were. The line ends with carriage return and line feed.


Sorry for the multiple posts. I tried this code and received easier to read output:

// Buffer to store incoming commands from serial port
String inData;

void setup() {
    Serial.println("Serial conection started, waiting for instructions...");

void loop() {
    while (Serial.available() > 0)
        char recieved =;
        inData += recieved; 

        // Process message when new line character is recieved
        if (recieved == '\n')
            Serial.print("Arduino Received: ");

            // You can put some if and else here to process the message juste like that:

            if(inData == "+++\n"){ // DON'T forget to add "\n" at the end of the string.
              Serial.println("OK. Press h for help.");

            inData = ""; // Clear recieved buffer

The result is readable; see below.


Read up on the sscanf function. This will allow easy interpretation of strings. It isn't the fastest function in the world, but it should do what you want it to.