1

I am reading an input from my Ohaus weighing scale using it's RS232 output using this code:

#define HWSERIAL Serial1

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

void loop() {
  int incomingByte;

  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    Serial.print("USB received: ");
    Serial.println(incomingByte, DEC);
    //HWSERIAL.print("USB received:");
    //HWSERIAL.println(incomingByte, DEC);
  }
  if (HWSERIAL.available() > 0) {
    incomingByte = HWSERIAL.read();
    Serial.print("UART received: ");
    Serial.println(incomingByte);
    //HWSERIAL.print("UART received:");
    //HWSERIAL.println(incomingByte);
  }
}

When pressing the print button on the scale, I was expecting data to come over in single burst with just the readings, but what I am getting is the expected data, but the scale keeps sending data afterwards (ES over and over). I need to parse out just what's needed. The below is the output from the console on my computer.

UART received:  
UART received:  
UART received:  
UART received:  
UART received: 0
UART received: .
UART received: 0
UART received: 0
UART received:  
UART received:  
UART received:  
UART received:  
UART received:  
UART received:  
UART received: ?
UART received: (This is a CR)

UART received: (This is a LF)

UART received:  
UART received:  
UART received:  
UART received:  
UART received: 0
UART received: .
UART received: 4
UART received: 0
UART received:  
UART received:  
UART received:  
UART received:  
UART received:  
UART received:  
UART received: ?
UART received: G
UART received:  
UART received:  
UART received: (CR)

UART received: (LF)

UART received: E
UART received: S
UART received: (CR)

UART received: (LF)
... (The ES loops over and over until the print button is pressed again)

0.00 is the current scale reading and 0.40 is the tare weight. That's all I need and I can't figure out how to parse it. The blocks aren't the same length so how do I pull out the needed information and ignore the repetitive 'ES'? I'm not 100% sure if I'm even going about this the right way?

Output as DEC

UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 48
UART received: 46
UART received: 48
UART received: 48
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 63
UART received: 13
UART received: 10
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 48
UART received: 46
UART received: 52
UART received: 48
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 63
UART received: 71
UART received: 32
UART received: 32
UART received: 13
UART received: 10
UART received: 69
UART received: 83
UART received: 13
UART received: 10
UART received: 69
UART received: 83
...
  • Can you give a full working sketch and a output that is actually from that sketch. Make incomingByte an int, and remove the cast to char when you print it. Print it as DEC or HEX, so you can see the numbers of the characters or spaces or linefeeds or other fancy bytes. – Jot Jan 20 '18 at 23:49
  • Is that a real RS-232 signal? What do you use to convert it to a ttl-level signal? If you use a module, tell us which module. Add to you question the model of the weighting scale. The document mentioned by @jdwolf show different formats for different models. The 'g' is the unit and the '?' is unstable. The rest should fit into one of the formats. I suppose the two character 'term' is the cr lf. – Jot Jan 21 '18 at 0:51
  • Well, I tried to use a Max 3232, but for some reason, the scale wasn't pushing enough voltage to trigger it to send the ttl, so what I did was connect it directly to pin 0 on the leonardo to get this readout and I actually got the above UART readings. The problem was that the 232 was sending some erroneous signals and causing issues. I don't understand why this worked, because RS232 is inverted from ttl, so my only assumption is that ohaus already converts their signal to ttl? – polyhedron Jan 21 '18 at 4:45
  • Noise on your TX line? Sounds like maybe your sending random data the device doesn’t understand. – tgunr Jan 22 '18 at 15:03
1

From the manual: http://dmx.ohaus.com/WorkArea/showcontent.aspx?id=4294974226

The balance will return “ES” for invalid commands.

Check to make sure you're using the correct serial parameters that the RX line is wired correctly.

  • Thanks, that definitely helped. I just removed the TX line from the Arduino, as I'm not sending data to the scale. – polyhedron Jan 21 '18 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.