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.