Read from weighing scale using RS232

Hey guys,
I have a weighing scale that sends data using RS232, I am trying to read the data using Arduino UNO.

For that, I have bought max3232 RS232 TO TTL converter.

This is my schema:

I tried a lot of code I found on the internet, but nothing worked.


#include <SoftwareSerial.h>

SoftwareSerial myScale(0, 1); // RX, TX

void setup() {
  // Open serial communications and wait for the port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for the serial port to connect. Needed for native USB port only
  }


  // set the data rate for the SoftwareSerial port
  myScale.begin(9600);
}

void loop() { // run over and over
  if (myScale.available()) {
    Serial.write(myScale.read());
  }
  
}

By the way, I have RS232 to USB convertor which I have plugged into the PC, and I have connected to the device COM using putty and I can see the data clearly.

You cannot have software serial sharing the pins use to communicate with the pc. Use a different pair for software serial.

hi, thanks!
2,3 sounds good?

You will know when you try it!

Your UNO is a 5V board, so power your RS232-TTL converter from the UNO 5V. You don't need to wire up the SoftwareSerial Tx pin as you are not sending any data to the scales. But, maybe you should be ...

There was a recent discussion regarding scales and RS232. Those particular scales needed a serial command in order to take a measurement and send it over the serial link. Check your documentation.

Thanks for your help, It's seem to be working now and there is a progress,
I am able to receive data from the scale but not the data I have expecting for:
image

Do you have any idea how can I parse it to ASCII?

void loop() { // run over and over
  if (myScale.available()) {
    Serial.println(myScale.read() & 0x7F);
    delay(50);
  }
  
}

Does your user manual give indication of the format of the serial data? Is it plain ASCII?

If it was ASCII, then i'd expect to see numbers like 48 (=0) through to 57 (=9) plus 46 (=decimal point) and probably a 10 and 13 at the end of each reading.

That's nice. We could be about 12000 percent more helpful if you supplied make and model of this device, and links to ant documentation that exists for it.

You could probably do a good amount of research using a terminal program like putty or coolterm, no program, no Arduino.

a7

@markd833, thank for you response.
image

thanks for your help

Is that from the user manual? That's pretty standard for the data frame for 1 byte but tells us nothing about the expected output from the scales?

As @alto777 says, what's the make/model of your scales. Can you post a link to the user manual.

this is the user manual: https://www.zemiceurope.com/media/Documentation/A12(E)(OC).pdf
I have connected the scale to the PC and received ASCII straight a head without doing anything:
image

Page 12 pretty much covers all you need to know about the serial data.

With your PC, what baud rate did you have? Is it the same at that used in your sketch?

Now post the code where you trying software serial.

What baud rate works direct to the PC? What program is running in the PC?

Pretend like we aren't in the room with you and are not mind readers.

a7

@markd833, @alto777
Like i mentioned above, I have used putty.
i used baud rate 9600 which is the same in my code


#include <SoftwareSerial.h>

SoftwareSerial myScale(2, 3); // RX, TX
String inData;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Starting");
  // set the data rate for the SoftwareSerial port
  myScale.begin(9600);
}

void loop() { // run over and over
  if(myScale.available()){
    Serial.println(myScale.read());
  }
  
}

Thank for your help.

Seems plausible.

Draw schematics or share what you have already drawn showing one: exactly how you have successfully received using putty, and two: exactly how you've hooked it up with the Arduino and are failing.

Including how all the parts are powered.

a7

@alto777 this is the fixed schematic:

While connecting the RS232 via USB converter I have check the COM is device manager and simply logged into using putty like that:
image
and this is the results:
image

the scale is power using 220v,
arduino is powered through the USB cable from PC
max3232 is connected like the schema above.

I think I have covered everything

Look at the example here Using serial_avaiable() and see how to use it correctly. Your method is causing you to have problems.

No. I mean srsly, real schematic diagrams: we are at the point where "this is connected to that like this and that is connected the same way" just won't do.

Draw schematics. Take a picture or two maybe.

I am curious why and where 3.3 volts ever enters into it this.

When you say MAX3232, are you talking about the chip or some module you got somewhere?

How is the chip wired, or what module are you using and how is it connected? Schematics would show that level of detail.

There is nothing obvsly wrong with what you are trying.

What means this?

While connecting the RS232 via USB converter

What converter? How is it wired? How is it powered?

Please confirm or correct the output you get from your program. The nonsense output.

Bury us in information.

a7

1 Like

How does it differ from the examlpe at the link?

void loop() {
  if (mySerial.available() > 0) {
    mySerial.read();
  }
}

a7

Try this instead:

void loop() { // run over and over
  while (myScale.available()){
    Serial.write(myScale.read());
  }

myScale.read() returns an int, which is equal to the ASCII value of the character.

And for the Uno, power the RS232 converter with 5V.