Digital Scale RS232 to RX(0) / TX(1) data reading problems

Hello Arduino community!

I have been having a lot of problems trying to get my Arduino UNO (with the square MEGA328P chip) to read from an RS232 port on a scientific digital scale. My goal is to be able to read the exact value of weight from the scale so that I can display it on an LCD screen (the reasons for this are beyond what I want to explain in this post, but once I am able to print this number to the serial monitor at will, the rest of my project will be easy).

I have done a lot of reading on the forms over the last week, and have made many attempts to read serial values from my digital scale, so posting here is not my first attempt to solve the problem :slight_smile:

The scale’s settings are set to print continuously at a baud rate of 9600 in the 8-N-1 configuration.

My wiring setup is very simple, but please let me know if you would prefer an official schematic.

Scale RS232 – > RS232 to TX/RX converter (URS232A with MAX232N chip) → Arduino Uno RX(0) and TX(1).

I am able to see the numbers that I want printed into the serial monitor, but usually not for very long and absolutely never when I tell the Arduino to print these values. These printed values are often mixed in with random backwards question marks (which I assume is an asynchronous read of the byte). I have tried using this code (below) with various modifications such as using different pins, but I am only ever to see any data when I use pins 0 and 1.

From the converter to the Arduino, TX is connected to TX and RX is connected to RX. I am fairly sure that the converter does the swapping of TX and RX internally. When I swap them on purpose, I am no longer able to receive anything in the serial monitor.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,1);

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()
{
  char data = mySerial.read();
  Serial.print(data);

}

When I upload this sketch to the arduino, I am greeted with several spurts of data which only happens for the first second or so after the sketch uploads. This even happens when I delete everything in the “void loop” section. Like I said, It seems like the arduino is reading these values automatically at the very beginning and ignoring everything that I have in the loop section. This is what is displayed in the arduino serial monitor. I do not know any of the C programming language, so I am not able to figure out exactly what the code is telling the arduino to do upon startup.

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮6斆⸮
31.98
39
31.99
31.99
⸮⸮
31.99
31.99
32.04
32.04
32.04
32.04
32.05
⸮3
31.93
31.93

Yet, as soon as I upload a nearly bare minimum sketch (see below), the serial monitor spits out a continuous stream of perfect data from the scale. It is exactly what I want, but it seems that as soon as I tell the arduino to do anything with this data (ie, read the data and save it to a variable), it stops being able to read the data continuously.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11);

void setup()
{
 // Serial.begin(9600);
 // mySerial.begin(9600);
}

void loop()
{
  
//  char data = mySerial.read();
//  Serial.print(data);
  

}

All I want to do is read the value from the scale, and store it as a variable.

Thank you for your support!!!

Please, try the following codes:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11);  //SRX, STX   

void setup()
{
   Serial.begin(9600);
   mySerial.begin(9600);
}

void loop()
{
      if(mySerial.available()>0)
      {
           byte x = mySerial.read();
           Serial.println(x, HEX);
      }  
}

Hello,

Thank you for the prompt reply. I have just tried your code.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11);  //SRX, STX   

void setup()
{
   Serial.begin(9600);
   mySerial.begin(9600);
   
}

void loop()
{
      if(mySerial.available()>0)
      {
           byte x = mySerial.read();
           Serial.println(x, HEX);
      }  
}

If I have RX, TX hooked up to pins 0 and 1, I get two spurts of data and then nothing happens.

If I have RX, TX hooked up to pins 10 and 11, I get absolutely nothing.

Cheers,
Tyler

Which digital scale?

I seriously doubt that it continuously is sending out data without a query.

Did you bother reading the manual?

It is the OHAUS Adventurer pro. Yes, I read the manual which is how I got to get the device to send continuous data without query.

I have just swapped the TX and RX inputs to the arduino (from the RS232 converter) on pins 10 and 11 using the code that was previously suggested. I am now getting a continuous stream of data to read, but it looks like this:

A
20
20
30
20
20
20
2E
20
20
20
2E
D
20

tylerrterhune:
It is the OHAUS Adventurer pro. Yes, I read the manual which is how I got to get the device to send continuous data without query.

I have just swapped the TX and RX inputs to the arduino (from the RS232 converter) on pins 10 and 11 using the code that was previously suggested. I am now getting a continuous stream of data to read, but it looks like this:

A
20
20
30
20
20
20
2E
20
20
20
2E
D
20

A very poor idea to have continuous data.

I have just gone through this with a valve regulator.

Much easier to have it respond to a query.

Oh, and since it is RS232, using TeraTerm to debug would not be a bad idea. Take the Arduino Uno out of the equation.

.

@OP

You have said, in Post#2, that there is absolutely no data.

Now, you are saying (in Post#4) that you are getting data.

It is the responsibility of the user/programmer to interpret the data to extract the meaning.

tylerrterhune:
I have just swapped the TX and RX inputs to the arduino (from the RS232 converter) on pins 10 and 11 using the code that was previously suggested. I am now getting a continuous stream of data to read, but it looks like this:

Pins 0 & 1 are used by the hardware serial port so you can't use them for software serial at the same time as they will be in conflict with one another.

Those are the hex ASCII codes that are being received from the scale, which is what you asked for when you used Serial.println(x, HEX); If you use Serial.print(x); you will see that actual transmission.