Serial port RS-232

Hi all,

I'm new at arduino and I would like to retrieve the data that is sent after pressing a button in a program on my pc.
The program sends a signal through RS-232 serial port to another controller.
Then the other controller sends a response to the pc.
I'm not interested in the response only in the signal that is sent.

What i've tried is connecting the transmit pin (from the serial port pin n°3) to the arduino A0 pin and print the signal that is sent.
I get a bunch of numbers but when i try to rewrite it to A1 (and A1 is connected to the otherside of the cut transmit wire) the program says that the communication is interrupted.

So the connection of the serial is completly the same only the transmit wire is cut and arduino is put in the middle.

What I would like to accomplish is making a universal system for getting data from al of the different controller manufactures.

Can anybody help me?

Kind regards,

William

You need to connect to the Arduino Rx pin instead, then monitor the signal using the Serial library:

byte incomingByte;
void setup(){
Serial.begin(speed); // 9600? 115200?
}
void loop(){
  if Serial.available()>0){
  incomingByte = Serial.read();
  Serial.print( incomingByte ); // maybe Serial.write( incomingByte ); ??
  }
}

CrossRoads:
You need to connect to the Arduino Rx pin instead, then monitor the signal using the Serial library:

byte incomingByte;

void setup(){
Serial.begin(speed); // 9600? 115200?
}
void loop(){
  if Serial.available()>0){
  incomingByte = Serial.read();
  Serial.print( incomingByte ); // maybe Serial.write( incomingByte ); ??
  }
}

Awesome Thank you very much for the quick response!!!
Going to try it.
I'll keep you posted.

Kind regards,

William

Are you really using the old fashioned "serial port" on a PC?

If so, the voltages on the TX and RX pins are not compatible with the Arduino and could damage it. Also, the logic levels are inverted. You will need an RS232-TTL serial adapter to correct that situation.

With the code from crossroads i get the following results:
16
0
186
°186
°23
0
0
0
1
52
4

And to answer your question I use RS232 to connect the serial to the usb on the pc.

When I want these bytes to be send to the controller to avoid the communication error.
Do I do this with the following?:
digitalWrite(1,incomingByte);

and then connect the TX pin to pin 3 of the serial port?

==> When I do so it still gives an error.

Kind regards,

William

And to answer your question I use RS232 to connect the serial to the usb on the pc.

That is not clear. If you have a USB to RS232 connector then you need a voltage and logic level translator. If you have a USB to TTL serial connector then you do not.

With the code from crossroads i get the following results:
16
0......

So what were you sending? And what did you expect?

Do I do this with the following?:
digitalWrite(1,incomingByte);

Absolutely not.

However your explanation of what you actually want to do is not clear enough for me to understand.

Yes, if you do not have 0-5V levels you need to connect an RS232 chip (such as MAX3232) to the Rx/Tx lines and then look at the TX output with the Arduino's Rx pin.

Uses 0.1uF caps

Or older MAX232, uses 1uF caps, only supports slower speeds