Hi guys,
I’m trying to use my Arduino Uno as an interface to collect data from different sensor outputs and output a ‘report’ when a test has been completed, I’m however running into difficulties reading data from a serial output via RS232. Your help would be much appreciated.
The sensor outputting RS232 is a set of scales, datasheet link:
https://www.scalesmart.com/media/PFB-Manual.pdf
The section on data output starts on page 44. It describes the serial communication setting (9600/8-N-1), and data output format (17 bytes long, starting with ST/US (stable/unstable) marker and ending with CR and LF line breaks). I’ve spoken to the scale manufacturer and they confirmed the data is in ASCII format.
Picture with RS232 monitor on PC: https://ibb.co/hMZQDL
I’ve plugged the scales into my PC, and using a piece of serial monitoring software have confirmed the data is being output as it should (although it actually outputs 18 bytes per message- I assume the datasheet was formatted incorrectly). The PC receives eg.: "ST,G 34.44 g ".
I’m using a DFROBOT RS232 shield (with integrated MAX3232 chip), link:
https://www.dfrobot.com/product-1030.html
I have the correct RS232 cable plugged into the RS232 shield, with headers running between the output pins on the shield to pins 10, 11 and GND on the Arduino (the VCC pin is left unused). I’m using the SoftwareSerial library to activate pins 10&11 for communication with the scales, and leaving 0&1 for USB.
Using the following code with the SoftwareSerial library (created by Tom Igoe, and posted on this forum) :
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
Serial.println(mySerial.read());
}
}
The serial monitor outputs seemingly nonsensical data, with boxes suggesting it’s receiving incomplete characters (see attached picture of the serial monitor). Note I added timestamps out of interest.
(Sadly the picture doesn’t want to embed- here’s a link)
Seeing as boxes are appearing in the serial monitor, I assume some of the data is being lost or I’m not giving Arduino the message structure it needs to interpret the incoming data. After research, I’m still not sure why the Serial Monitor is separating the data like it is- groups of characters (and boxes) seem to be coming in at exactly the same time (notice on the timestamps), but are still being separated by a line.
Please let me know if I can provide more information that would be any use. Your help is much appreciated!