Digital Scale RS232 MAX3232 with Arduino Mega

Hi I want to ask, I am trying to receive data from a CAS CI-200SC digital scale Manual Owner with Arduino Mega using RS232 to ttl MAX3232 with serial hardware. This is the code I used for testing.

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

void loop() {
  if (Serial1.available() > 0) {
    Serial.println(Serial1.read(), HEX);
  }
}

but from the coding above, the 9600 baudrate serial monitor only displays 0.

please help me so that the reading value of the digital scale can appear correctly in my arduino serial monitor.

are you sure your TTL-RS232 module is working
do a simple loopback test, e.g.

// Arduino Mega serial1 test

// mega Serial1 pin 18 is TX1
//      Serial1 pin 19 is RX1
// for loopback test connect pin 18 to pin 19

// for RS232 shield connect
// Mega pin 18 TX1 to TTL/RS232 Tx
// Mega pin 19 RX1 to TTL/RS232 Rx
// for loopback test connect 9-pin D_type connector pins 2 Tx to 3 Rx (pin 5 is GND)
// connect GND pins together and VCC to 5V

void setup() {
  Serial.begin(115200);     // initialise serial monitor port
  Serial1.begin(9600);//115200);    // initialise Serial1
  Serial.write("Arduino Mega Serial1 test -  for loopback test connect pin 18 to pin 19\n");
  Serial.write("RS232: Mega pin 18 TX1 to TTL/RS232 Tx and pin 19 RX1 to TTL/RS232 Rx\n");
  Serial.write("RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx\n");
}


void loop() {
  if (Serial1.available()) {  // read from Serial1 output to Serial
    Serial.write(Serial1.read());
  }
  if (Serial.available()) {  // read from Serial outut to Serial1
    char inByte = Serial.read();
    //Serial.write(inByte);     // local echo if required
    Serial1.write(inByte);
  }
}

How is it wired? A little schematics please. Pen and paper is fine.

this is the wiring I use, sorry if it's bad

how to test it? is it after uploading the program to the arduino then immediately connect the db9 pins 2 and 3 and wait in the serial monitor? sorry I'm a beginner in this section.

You can connect the pins first and next load the sketch from post #2.

I'm not 100% sure, but I suspect that need to connect Tx1 of the Arduino to Tx of the adapter and Rx1 of the Mega to Rx of the adapter.

connect D-type 9pin pins 2 and 3 together
image

run program - text entered on serial monitor should echo back to display
this tests the Mega to TTL-RS232 module connections and the module

How is the scale wired to the RS-232 converter? You may need to swap around the wiring to pins 2 and 3 on that side of the connector.

I agree with you, sterretje.

The crossover connection of Transmit to Receive (and vice versa) needs to be done between the scale and the MAX3232.

just tested on a Mega and my original code post 2 had them the wrong way around (in fact I had a Mega in which pins 18 and 19 were labled the wrong way around) - code now correct
the following worked when I connected D-type pins 2 and 3 for the loopback test

// for RS232 shield connect
// Mega pin 18 RX1 to TTL/RS232 Tx
// Mega pin 19 TX1 to TTL/RS232 Rx

you can check which are the TX and Rx lines
e.g. on my TTL-RS232 module not connected to anything in idle (no transmission)
pin 2 Tx is -9volts
pin 3 Rx is 0volts

if you check the scale the TX pin should be between -8 and -12 volts and the RX pin 0volts
you then connect
RS232 Tx pin 2 to scale Rx
RS232 Rx pin 3 to scale Tx
connect GNDs together (D-type pin 5)

this photo shows a Mega/RS232 module connected to a Quectel ES21 modem (note pins 2 and 3 interconnections)

ohh ok, I've tried it and it works, when I send text on the serial monitor, it will redisplay the text I input.

that shows the Mega <> TTL_RS232 module connection is operational
you can now connect it to the scale with some confidence that part of the system is OK

did you try checking the voltages of the scale RS232 wires when not connected to anything?
the TX line should be -8 to -12 volts if the connection is idle

if both are female D-type 9 pin connections the typical connection would be
TTL-RS232 pin 2 Tx to scale RS232 pin 3 Rx
TTL-RS232 pin 3 Rx to scale RS232 pin 2 Tx


Is there usually only 3 cables for RS232 on CAS CI-200CS digital scales? I tried to disassemble the DB9 connector belonging to the scale and there are only 3 connected to pins number 2, 3 and 7.

According to the CI200 Series owner's manual, pins 2, 3, and 7 are correct for the scale end of the cable. Pin 2 is Tx, 3 is Rx, and 7 is GND.
What type connector is on the other end of the cable?

For the other end I use MAX3232 with db9 female connector. Previously the digital scale db9 connector was damaged and replaced with a new one so I tried to see the wiring in the db9 connector and the results were as shown in the picture in post 15. What I know is that pin 7 on RS232 is used for RTS and GND is on pin 5, so I am a little confused whether the wiring above is correct or wrong. I am still a beginner in this RS232.

Look at pages 72 and 73 of the owner's manual, that shows the cable wiring.

ohhh ok i see

I tried with putty and connected the DB9 RS232 connector of the digital scale to RS232 to USB to the computer with the wiring as shown below.

but in putty it appears like this

how to solve it? did I make a mistake? I don't know how come the result of reading in putty is even like that

On the scale, pin 2 is Tx, pin 3 is Rx.

Are you certain of the settings for baud rate, number of data bits, and parity bit? There is definitely a pattern in the putty output, that appears to repeat in a 17-character sequence.