hi i am trying to read data from a scale that has an rs232 8 bit 9600baud no parity signal output
i bought a rs232 to ttl adapter and tried to read it from the tx rx ports on the arduino uno howver no data is being sent or recieved which can be seen by the unlit activity LEDs on the converter, i have tried swapping the wire to no avail. after measuring the voltage on the converter the rx is 5v and tx is 3.5v. another odd thing is that the rs232 signal is 5v which i dont think is normal and as such i have tried reading it directly and just got decimal numbers which corresponded to nothing eg 8 8 8 8 8 8 4 4 68 68 136, this may be because on rs232 1 is low and 0 is high the opposite of ttl.
the script i am using is just the arduino serial read reference;
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
does anyone know how I could read this data, i also have an rs232 to usb adapter which i had planned to use with a usb shield but the script wont verify because the library gives errors
I think you should use SoftwareSerial for the scale instead.
Please read
General guidance and
How to use this forum
Especially item #7 on posting code.
The serial port on a Uno is shared with the USB connector, which makes it a problem to use.
+5V is the standard idle condition for serial.
For more about how to use serial communications please read Serial input basics.
If you are using the RS232<--->TTL converter Module of Fig-1, then check that the connection is similar to the diagram of Fig-2.
Fig-1:
Figure-2:
Test Sketch:
void setup()
{
Serial.begin(9600); //UART0 Bd for communicating with Serial Monitor
Serial2.begin(9600); //enter correct Bd = Baud Rate of your Weighing Scale
}
void loop()
{
byte n = Serial2.available();
if(n != 0)
{
char x = Serial2.read();
Serial.print(x); //just print as the characters/data are coming form scale.
}
}
That needs a SoftwareSerial.h include, Yes?
" after measuring the voltage on the converter the rx is 5v and tx is 3.5v. another odd thing is that the rs232 signal is 5v which i dont think is normal and as such i have tried reading it directly and just got decimal numbers which corresponded to nothing"
If the resting voltage on the scale rx and tx lines are positive, then the output is most likely TTL and not rs232, and you may not need the adapter. You can try connecting the scale and arduino grounds together and the scale tx to the arduino tx, then see if you receive the scale output in the serial monitor. Does the scale output readable text or is it coded output?
zoomkat:
" after measuring the voltage on the converter the rx is 5v and tx is 3.5v. another odd thing is that the rs232 signal is 5v which i dont think is normal and as such i have tried reading it directly and just got decimal numbers which corresponded to nothing"
If the resting voltage on the scale rx and tx lines are positive, then the output is most likely TTL and not rs232, and you may not need the adapter. You can try connecting the scale and arduino grounds together and the scale tx to the arduino tx, then see if you receive the scale output in the serial monitor. Does the scale output readable text or is it coded output?
I have tried that but only RX to RX appears to give any signal and that is in the form of decimal numbers eg 4 8 and several others that dont appear to have any value on ascii tables or are just random signals
runaway_pancake:
I think you should use SoftwareSerial for the scale instead.
I have also tried the software serial example but it does not appear to read anything either
Do you have the model number of the scale, or a link to the manual?
You may need to swap pins 2 & 3 between the cable from the scale and the RS-232 adapter.
david_2018:
Do you have the model number of the scale, or a link to the manual?
You may need to swap pins 2 & 3 between the cable from the scale and the RS-232 adapter.
i have tried manually wiring each pin and swapping them as well as a male to male rs232 cable between the adapter and scale and neither has changed the result
So did you ever measure the resting voltage on the scale tx and rx lines? If they are actually TTL lines, you are just spinning your wheels fiddling with an adapter. Is the scale of recent manufacture or is it somewhat old?