Serial Connection of Arduino UNO to an old digital scale through the printer port

Trying to connect an old GF300 A&D scale to an Arduino UNO through the 25 pin printer port.
My serial connnection is:
15 characters long excluding the terminator (CRLF). The header consist of 2 characters in position 1 and 2 and indiactes the statuse of the scale ST, US, OL or QT, followed by a comma in position 3, and the polarity sign (+or -) in position 4. Characters 5-12 will be the numerical weight followed by the unit of measure in positons 13-15. All of this is followed by the terminator CRLF. It has downloaded without issue.

An example of the character string would be:
ST,+00012.78 gCRLF. This would indicate a stable positive reading of 12.78 grams. I have included my code.
I have wired the Arduino through the breadboard.

Sketch below. I manually hit the print key to output. I ma getting nothing on the serial monitor. I am wondering if I am using the RX and TX connections correctly.

#include <SoftwareSerial.h>

SoftwareSerial scaleSerial(0, 1); // RX, TX - adjust the pin numbers as needed
String incomingLine = ""; // Declare incomingLine to store the received line

void setup() {
    Serial.begin(9600); // Set your preferred baud rate for the Arduino IDE Serial Monitor
    scaleSerial.begin(2400); // Set baud rate to 2400 bps for the A&D GF-300 scale
}

void loop() {
    if (scaleSerial.available()) {
        // Read the incoming byte from the scale
        char incomingByte = scaleSerial.read();

        // Check if the received byte is the end of the line (newline character)
        if (incomingByte == '\r' || incomingByte == '\n') {
            // Process the custom-formatted data when a complete line is received
            processCustomFormat();
        } else {
            // Accumulate characters to form a complete line
            incomingLine += incomingByte;
        }
    }
}

void processCustomFormat() {
    // Check if the incoming line has exactly 15 characters (excluding terminator)
    if (incomingLine.length() >= 15) {
        // Extract information from the incoming line
        String header = incomingLine.substring(0, 2);
        String separator = incomingLine.substring(2, 3);
        String polaritySign = incomingLine.substring(3, 4);
        String weightData = incomingLine.substring(4, 12);
        String unitOfMeasure = incomingLine.substring(12, 15);

        // Print the received data in the desired format
        Serial.print("Header: ");
        Serial.println(header);
        Serial.print("Separator: ");
        Serial.println(separator);
        Serial.print("Polarity Sign: ");
        Serial.println(polaritySign);
        Serial.print("Weight Data: ");
        Serial.println(weightData);
        Serial.print("Unit of Measure: ");
        Serial.println(unitOfMeasure);
        Serial.println(); // Print a newline for readability
    }

    // Clear the accumulated line for the next iteration
    incomingLine = "";

That's a conflict.
You need to assign SoftwareSerial to 'pins' other than 0 and 1.

1 Like

Welcome to the forum

If the scale has a 25 pin serial port then it is almost certainly using RS232 for its serial connection. This is completely incompatible with the TTL voltage levels provided by the Arduino.

You need an RS232 to TTL converter between the 2 devices

1 Like

Thanks. Let me research.

Thanks. I will connect to digital pins 10,11.

Remember RS323 is a bit picky in that Tx expects a listner Rx and Rx expects a tallker Tx. There are other pins as well such as CTS, DTR, etc. No idea if they were used. Over the years I have seen several combinations. You can get the service manual from: A&d GF-300 Manuals | ManualsLib That should tell you.

As I remember the 25 pin port is a parallel "centronics" type port. As described by IEEE1284


image

The fun begins here --
Rs-232C Serial Interface / External Input - A&D GF-1200 Instruction Manual [Page 59] | ManualsLib

Legacy it is (and that's OK).

I have the connections right, I believe this is RS232C and the voltages are too high for my Arduino UNO. I was using a PB on the breadboard for print and Re-zero. The re-zero works, and I believe the print button is working, but I can't get anything ot print. I changed the Rx, Tx, to pins 10,11 and wired them for Rx to Tx and vice versa. Still nothing. I do not have a TTL convertor. If I understand correctly, I need the convertor to lower the voltage level. I am a bit lost, but will keep researching.

I didn't realize my image didn't load with the wiring. I will load it.

You can give this a try --
image

You may have to change SoftwareSerial to inverse_logic
SoftwareSerial Library | Arduino Documentation

Whilst there were large Centronics parallel printer ports there were also 2 flavours of serial ports, one with 9 pins and one with 25 pins so all bets are off

I am a little lost. I tried using the diode and resistors from runaway_pancake. Still not working. I am not understanding how to use the TTL. It is a simople pinout for the scale. I changed the code around.

#include <SoftwareSerial.h>

SoftwareSerial scaleSerial(8,9); // RX, TX - adjust the pin numbers as needed
String incomingLine = "";

void setup() {
    Serial.begin(2400); // Set baud rate for the Serial Monitor
    scaleSerial.begin(2400);

    Serial.println("Setup complete. Waiting for incoming data...");
}

void loop() {
    if (scaleSerial.available()) {
        char incomingByte = scaleSerial.read();

        if (incomingByte == '\r' || incomingByte == '\n') {
            Serial.println("Received End of Line. Processing...");
            processCustomFormat();
        } else {
            incomingLine += incomingByte;
        }
    }

    // Your main code here, without delay
}

void processCustomFormat() {
    if (incomingLine.length() >= 15) {
        Serial.println("Processing Custom Format...");

        String header = incomingLine.substring(0, 2);
        String separator = incomingLine.substring(2, 3);
        String polaritySign = incomingLine.substring(3, 4);
        String weightData = incomingLine.substring(4, 12);
        String unitOfMeasure = incomingLine.substring(12, 15);

        Serial.println("Hello, Print Part of Program!");
        Serial.print("Header: ");
        Serial.println(header);
        Serial.print("Separator: ");
        Serial.println(separator);
        Serial.print("Polarity Sign: ");
        Serial.println(polaritySign);
        Serial.print("Weight Data: ");
        Serial.println(weightData);
        Serial.print("Unit of Measure: ");
        Serial.println(unitOfMeasure);
        Serial.println();
    } else {
        Serial.println("Incomplete or invalid line. Discarding...");
    }

    // Clear the accumulated line for the next iteration
    incomingLine = "";
}

I get the message "Setup complete, waint for incoming data" , so the program is at least reading. Obviously have no incoming data.

Can you please post a clear picture of the "printer" port of the scale ?


I ahave connected Scale Pin1, or Frame ground, to the ground on the UNO. RX, or Pin 2, is connected to Arduion DO9,the designated UNO TX pin. The Scale TX, or Pin 3, is connected to Arduino DO8, the designated RX Pin. I have wired the Scale pins 18 and 19 to the signal ground pin through pushbuttons. The reset works fine. I am not getting anything at all when I hit print. I have put the diodes and resistors in place to reduce the voltage coming in to the arduino.

@runaway_pancake also said

You may have to change SoftwareSerial to inverse_logic

I would have said you will almost certainly have to change it. I don't see where you did that, and can't know if you tried.

a7

You should use pin 7, signal ground (SG). Frame ground is the electrical ground connections used for any shielding around the cable.

1 Like

Yes, I am working on that now. My program won't read the "inverse_logic" command for some reason. Thanks for the tip. I will get in in.

Thanks. Yes, I have the signal ground, pin 7, connected to the Arduino ground.

Jumper RTS to CTS, sometimes that's needed.