This is my first post, so please forgive any missed steps. I am about 1 year into Arduino programming, and have been reading topics here for that time.
I am starting a project that involves reading the output of a laboratory scale to an Arduino. Eventually the project will use an Arduino Giga, but I wanted to start small and am using a Nano for bench testing to confirm that I can read the serial data. I have been reading threads for several days and the closest that I came to my topic was how to get weight form Weight Scale and ek 300i. This topic used a very similar scale to the one I am using, which is an A&D FX-120i (https://weighing.andonline.com/sites/default/files/documents/FX-i%20et%20FZ-i%20Manuel%20Francais.pdf).
After going through the electronics, I determined that I should be able to read the output directly from the DB9 connector on the scale to the Arduino, so it is wired with the Signal Ground (pin 5) from the DB9 to the Nano GND pin, and as I only need to read the data, the TXD pin (2) is wired to pin D6 on the Nano. I checked the printer setup, and it is set to 19200 Baud, and 8 bits w/no parity.
Here is the code that I am using, which I mostly copied from the other topic thread, but I am using SoftwareSerial to use additional pins on the Nano:
#include <SoftwareSerial.h> // Include lbrary to do serial communications on alternate pins
SoftwareSerial scale(6, 7); //(TXD, RXD)
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
void setup() {
scale.begin(19200);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (scale.available() > 0 && newData == false) {
rc = scale.read();
Serial.print("Char received ");
Serial.print((byte)rc);
Serial.println();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
} else {
receivedChars[ndx] = '\0';
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
newData = false;
delay(5000);
}
}
When I run the program, I get the "", if the TXD line is not connected, if it is connected, nothing happens. If I connect the TXD pin after the program gives the "", I get the data set below:
Char received 191 Char received 113 Char received 99 Char received 229 Char received 235 Char received 0 Char received 86 Char received 213 Char received 90 Char received 237 Char received 246 Char received 214 Char received 150 Char received 182 Char received 54 Char received 107 Char received 151 Char received 191 Char received 113 Char received 99 Char received 229 >>>>Repeats indefinitely>>>>>>>The scale is showing "132.92 gn" so based on the printer manual, I would expect to see data of "ST,00132.92 g" followed by a carriage return and a line feed (ASCII 0Dh and 0Ah respectively). I also never see the "This just in ... " text from the second subroutine.
Can someone explain what I need to do to get the data formatted into something I can use? Also, is there any need for the "showNewData()" subroutine?
Thanks for the help