Serial RS232 from Scale

Hello. I feel as though I am SO close to the answer. But not there yet. Can someone help? I'm ultimately trying to get input from a shipping scale into an Arduino. I can then manipulate the input and output something more interesting. I'm not worried about the manipulation. Right now, I'm just trying to get the Arduino to recognize the scale's output.

01

First, I got the scale simply sending data via a serial cable to my COM1 port of my computer. I can read it via Putty or AccessPort just fine. See images attached for config settings, wiring diagram, and results. Yeah, the scale works.

02

Next I tried using the Arduino without the scale. I connected my Windows computer via COM1 to the Arduino (using a MAX3323 chip to get the power levels right -- https://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232). Then the Arduino sends the incoming message to my Mac computer, which is connected via USB. This works just fine. Again, see attachments below. I'm using the exact same config settings in AccessPort as step 01 above.

And see my code here:

#include <SoftwareSerial.h>

int result = 0;                   // lbs on earth (or the inputted value)
int resultMoon = 0;               // lbs on the moon
SoftwareSerial scale(10,11);      // RX, TX
String rx_str = "";               // stores raw serial input by string

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps

  // set the data rate for the SoftwareSerial port
  scale.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  scale.println("Setup Complete");
  Serial.println("Setup Complete");
}

void loop() {
  readScale();
}

void readScale() {

  // send data only when you receive data:
  //scale.listen();
  while (scale.available() > 0) {
    char inByte = scale.read();
    Serial.write(inByte);
  }
}

03

Then all I did was unplug the serial cable from my Windows Computer's COM1, and plug that directly into the scale. I want to Arduino to read the incoming data, and report it back to the Mac. I get nothing.

04

I tried modifying the code to see if any data is coming through, but the Arduino does not recognize any data being available.

#include <SoftwareSerial.h>

int result = 0;                   // lbs on earth (or the inputted value)
int resultMoon = 0;               // lbs on the moon
SoftwareSerial scale(10,11);      // RX, TX
String rx_str = "";               // stores raw serial input by string

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps

  // set the data rate for the SoftwareSerial port
  scale.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  scale.println("Setup Complete");
  Serial.println("Setup Complete");
}

void loop() {
  readScale();
}

void readScale() {

  // send data only when you receive data:
  //scale.listen();
  if (scale.available() > 0) {
    char inByte = scale.read();
    Serial.write(inByte);
  } else {
    Serial.println("no data available");
  }
}

Can anyone point me in the right direction? Thank you in advance.

02c Mac Readings.png

03 Mac Readings.png

Am I correct in thinking you were using the PC just to send test serial data to the Arduino and that that data was correctly received?

But when you connect the scale to the Arduino in place of the PC you are not getting data?

First thought that springs to mind is that your Tx and Rx lines may be the wrong way round.

...R
Serial Input Basics

You are making it way too complicated. Making my head spin. :roll_eyes:

Robin2, thanks. You are correct that I used my Windows computer to send messages via Serial to the Arduino. I was trying to replicate the Scale and make sure my wires were correct.

I tried switching out the RX and TX wires too. But if it works as is with the scale to/from windows computer, why would it need to be switched out? Shouldn't I just be able to unplug the serial cable from the COM1 port and plug it into the scale?

drumminhands:
Robin2, thanks. You are correct that I used my Windows computer to send messages via Serial to the Arduino. I was trying to replicate the Scale and make sure my wires were correct.

I tried switching out the RX and TX wires too. But if it works as is with the scale to/from windows computer, why would it need to be switched out? Shouldn't I just be able to unplug the serial cable from the COM1 port and plug it into the scale?

You do realize that serial != RS232 ? ? ?

So.... I knew I was close. But this is silly. I tried switching the RX and TX wires so many times during different iterations. But after Robin2 suggested it, I thought I'd try it one more time. OK, now I got it right. It works just fine.

But I am confused why I need to switch the wires when a computer is the input vs when the scale is the input.

Thanks for letting me bounce my ideas at you all.

ieee488 sorry my labels are not up to par. Sleepy morning.

I am still shaking my head because I see a complicated setup for communicating with a scale with a RS232 interface. Seriously?

What would you suggest instead? I see the link above to a shield, but basically I just built my own. How is that any different?

drumminhands:
What would you suggest instead? I see the link above to a shield, but basically I just built my own. How is that any different?

You built your own which isn't working.

You can either continue with your "shield" or buy a RS232 shield.

Your choice.

As far as I know @drumminhands has a MAX232 chip to convert between RS232 and the Arduino - that sounds right to me - and it seems to be working for him. Why would you need an expensive RS232 shield?

...R

Robin2:
As far as I know @drumminhands has a MAX232 chip to convert between RS232 and the Arduino - that sounds right to me - and it seems to be working for him. Why would you need an expensive RS232 shield?

...R

If it was working for him, why is he here?

I'd hardly call a $10 shield "expensive".

It now works thanks to Robin2. And yes, $10 is not expensive. But I now have something that works for less, takes up less room, and can be easily customized. And I understand more about Serial communication.

drumminhands:
It now works thanks to Robin2. And yes, $10 is not expensive. But I now have something that works for less, takes up less room, and can be easily customized. And I understand more about Serial communication.

Good for you.

Easily customized for what?

Takes up less room? It doesn't look like it to me. You are using discrete parts not SMT parts.

To me it seems to be much time wasted re-inventing the wheel instead of concentrating on the important thing which would be to use the scale for your intended purpose.

If you are a student that is fine. I wouldn't be too happy if I was your manager and you were doing this at work.

ieee488:
If it was working for him, why is he here?

Because it was not working originally. But the absence of a shield was never the problem.

I have a few Arduinos. I have no shields.

I suspect $10 is 2 or 3 times the price of a Max232. The saving would buy beer.

...R

Robin2:
Because it was not working originally. But the absence of a shield was never the problem.

I have a few Arduinos. I have no shields.

...R

I have an Ethernet shield.

A properly working shield would mostly have saved him a lot of wasted time. As I wrote before, wasting time on re-inventing the wheel as an employee is not something a manager would look kindly on.

I don't go re-inventing the wheel when the end goal is to use the scale. My employer is not paying me to experiement and "learn more about serial communication" per the OP. Get the job done. Pronto. Eye on the prize. etc. etc.

I was once told my worth to a former employer was $250/hour. If I did what the OP did and spent 8 hours on this boondoggle, I would have wasted the company $2000. Yeah, really good to go on a yearly review.

What has value to an employer got to do with a hobby Arduino project?

I, for example, am retired so I am no value to anyone except myself.

...R