Interfacing weighing scale with rs232

I need to interface weighing scale with Arduino UNO to see the weighing scale data in serial monitor of arduino ide. That weighing scale has rs232 port for communication. Weighing scale sends weight data whenever we send the "R" to the weighing scale. I am new to arduino programming.BElow is my code.

#include <SoftwareSerial.h> 
#define rxPin 10
#define txPin 11 
String answer;
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()
{
      pinMode(rxPin, INPUT);
      pinMode(txPin, OUTPUT);
      mySerial.begin(9600);
      Serial.begin(9600);     
}

void loop()
{ 
      delay(1500);
      mySerial.write('R');
      answer=mySerial.read(); 
      mySerial.println(answer); 
}

This only reads a single byte... is that what you are expecting?

Should this line...

be

Serial.println(answer);

I want to continously receive data

Still iam not able to read the data in serial monitor

You should also check that the software serial port has data to be read before issuing the read call.

I am not understood what you are saying

Try this test sketch. Enter an 'R' in the Serial Monitor. Set the "line ending" to none.

#include <SoftwareSerial.h>                     

SoftwareSerial softSerial(10, 11);


void setup()
{
  Serial.begin (115200);
  softSerial.begin (9600);
}


void loop()
{
  
  while (Serial.available() > 0)
    softSerial.write(Serial.read());

 
  while (softSerial.available() > 0)
    Serial.write(softSerial.read());

}

EDIT: Change baud rate to 9600.

1 Like

when I send "R", the Rx LED in arduino only blinking. no data is available at serial monitor

what baud rate i have to set in serial monitor, I already read the data from weighing scale through putty they i set baud rate as 9600

Use 9600 in the test sketch for the Software Serial connection. The monitor can stay at 115200.

1 Like


Is this right?

did you click [Send] ?

yeah yes nothing is printing just Arduino rx led is blinking

How have you got the scale connected? Please post a schematic or photo.

You don't appear to be connected to the correct pins on the Arduino.

image

You should be using pins 10 (Arduino Rx) and 11 (Arduino Tx)

SoftwareSerial softSerial(10, 11);

1 Like

RS232 can use different voltage levels. Some of it are incompatible with arduino ports. Do you know exact characteristics of your scale rs232 interface?

1 Like

I used RS232 to TTL converter


Still its not printing anything in serial monitor

There's more to an RS232 device interface than the TxD and RxD signals. You need to read the user manual for the scales to see if it uses handshaking (either hardware or software).

Do you have a schematic of your RS232-TTL converter?

You may need to override the hardware handshaking in order to get your scales to send data. It's been a while since i played with DB-9 RS232, but you may need to put a wire link between pins 4&6 and another between pins 7&8 if this ins't already done on your RS232-TTL midule.