Invalid output from serial communication

Good day everyone.

I have a barcode scanner which i have interfaced to Arduino UNO using the SoftwareSerial function.

The barcode gives the output via RS232.

I have wired the barcode scanner to arduino as follows:

Barcode-----------------UNO

VCC 5V
GND GND
TX D10(configured as RX by SoftwareSerial)
RX D11(configured as TX by SoftwareSerial)

In addition to this, the barcode has 3 extra wires at its output connected as CTS,RTS and Shield.

I have connected the Shield to GND.

My code is as follows:

#include<SoftwareSerial.h>

SoftwareSerial mySerial(10,11); //(RX,TX)

void setup()
{
Serial.begin(9600);
Serial.println(“BEGIN”);

mySerial.begin(9600);
Serial.println(“START COMMUNICATION”);
}

void loop()
{
char bytes[20] = {’\0’};
int i = 0;

mySerial.listen();

while(mySerial.available() > 0)
{
bytes =mySerial.read();

  • //Serial.println(mySerial.read());*
    _ Serial.println(bytes*);_
    _
    delay(100);_
    _
    }_
    _
    //Serial.println();_
    _
    }[/quote]_
    Once i start the Serial Monitor and scan a barcode, I get the output as follows:
    _
    > BEGIN*_
    > START COMMUNICATION
    > c
    > d
    > L
    > L
    > ¦
    > æ
    > f
    > &
    > ¦
    > æ
    > ¦
    > æ
    > ¦
    > Ö
    My expectation is ‘9789350235010*’ which is the barcode i see. Instead ‘cdLL¦æf&¦æ¦æ¦Ö’ is displayed.
    What might be the mistake?
    As of now i have not connected the CTS and RTS to any pin on Arduino.
    Should i connect CTS and RTS of scanner to UNO? If yes, to which pin and what configuration?
    Please help me out.
    Regards.

The barcode gives the output via RS232.

Has the Arduino got an RS232 input or is is TTL ? They use different voltage levels and it is common to use an interface circuit between the two.

UKHeliBob:
Has the Arduino got an RS232 input or is is TTL ?

I think that would be clearer if it was like this

Does the Barcode reader output RS232 or TTL? The Arduino needs a TTL signal. RS232 uses higher voltages that may damage an Arduino.

You can use the MAX232 chip to interface between RS232 and TTL.

...R

I tried the interface using MAX232 and i am able to communicate according to my requirement.

But there is a SP232een chip on the scanner which does the same job. But this gives the output as stated above.

What is happening here?

Good day everyone.

Sometimes in a hurry we forget the basics. This is what happened here.

The barcode engine gives a TTL output and Arduino can read TTL signals. In a hurry i skipped reading the datasheet of the scanner.

Sorry for my mistake.

An easy thing to do.

Glad you have it figured out.

...R