Hello Arduino community!
I have been having a lot of problems trying to get my Arduino UNO (with the square MEGA328P chip) to read from an RS232 port on a scientific digital scale. My goal is to be able to read the exact value of weight from the scale so that I can display it on an LCD screen (the reasons for this are beyond what I want to explain in this post, but once I am able to print this number to the serial monitor at will, the rest of my project will be easy).
I have done a lot of reading on the forms over the last week, and have made many attempts to read serial values from my digital scale, so posting here is not my first attempt to solve the problem
The scale's settings are set to print continuously at a baud rate of 9600 in the 8-N-1 configuration.
My wiring setup is very simple, but please let me know if you would prefer an official schematic.
Scale RS232 -- > RS232 to TX/RX converter (URS232A with MAX232N chip) --> Arduino Uno RX(0) and TX(1).
I am able to see the numbers that I want printed into the serial monitor, but usually not for very long and absolutely never when I tell the Arduino to print these values. These printed values are often mixed in with random backwards question marks (which I assume is an asynchronous read of the byte). I have tried using this code (below) with various modifications such as using different pins, but I am only ever to see any data when I use pins 0 and 1.
From the converter to the Arduino, TX is connected to TX and RX is connected to RX. I am fairly sure that the converter does the swapping of TX and RX internally. When I swap them on purpose, I am no longer able to receive anything in the serial monitor.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0,1);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
char data = mySerial.read();
Serial.print(data);
}
When I upload this sketch to the arduino, I am greeted with several spurts of data which only happens for the first second or so after the sketch uploads. This even happens when I delete everything in the "void loop" section. Like I said, It seems like the arduino is reading these values automatically at the very beginning and ignoring everything that I have in the loop section. This is what is displayed in the arduino serial monitor. I do not know any of the C programming language, so I am not able to figure out exactly what the code is telling the arduino to do upon startup.
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮6斆⸮
31.98
39
31.99
31.99
⸮⸮
31.99
31.99
32.04
32.04
32.04
32.04
32.05
⸮3
31.93
31.93
⸮
Yet, as soon as I upload a nearly bare minimum sketch (see below), the serial monitor spits out a continuous stream of perfect data from the scale. It is exactly what I want, but it seems that as soon as I tell the arduino to do anything with this data (ie, read the data and save it to a variable), it stops being able to read the data continuously.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
void setup()
{
// Serial.begin(9600);
// mySerial.begin(9600);
}
void loop()
{
// char data = mySerial.read();
// Serial.print(data);
}
All I want to do is read the value from the scale, and store it as a variable.
Thank you for your support!!!!!