swap rx and tx

Hi is it possible to swap rx (pin 0) and tx (pin 1)?

rx to pin 1 and tx to pin 0 in code?


No, these are 'hardwired' inside the AVR chip to the hardware usart. However the various software serial libraries allows one to pic and choose which pins one uses for send and receive.


Thanks for your reply, I have tried softwareserial and newsoftserial but not working for me, I do receive serial data but they are all in weird characters, tried every baud rate possible but still the same problem. any other suggestions?


That sounds more like a coding problem. You have to know a lot about the data being sent to the Arduino, more then just it's baud rate. Are the characters being sent in binary format or ASCII characters? Are you interpreting the characters received in the correct matter.

So more details are needed about what is sending the data, it's format and of course your sketch code.


Thanks again for your quick reply

Am trying to send data from my android phone using bluetooth, on the arduino end am using an rn42 bluetooth module.

When I swap the rx and tx from the rn42 on the android board it works perfectly. I get all the bytes being sent.

that is rx from rn42 to tx of arduino board tx from rn42 to rx of arduino board it works perfectly, except for when it comes to uploading software to the arduino board i get

avrdude: stk500_getsync(): not in sync: res=0x00

which is really annoying.

this is the code am using in android for sending data (byte array)

String message = str;
byte[] msgBuffer = message.getBytes();

thank you

rx from rn42 to tx of arduino board tx from rn42 to rx of arduino board

This is the correct way to connect them. What the bluetooth module receives is transmitted by the Arduino. What the bluetooth module transmits is received by the Arduino.

The bluetooth module is using the hardware port, which is the same port used by the IDE to program the Arduino. Since only one application at a time can bind to the port, the failure to upload to the board with the bluetooth module in place is not surprising.

The same issue arises with XBee shields, but, at least they provide a jumper that can be moved to control which device (XBee or PC) can talk to the Arduino.

do you suggest to add a jumper?

is there no way to use newsoftserial?


I don't know how your bluetooth module connects to your Arduino. Therefore, I have no idea whether you could add a jumper.

If you connect the TX/RX of the bluetooth module to other pins, you should be able to use NewSoftSerial. Keep in mind that TX of the bluetooth module goes to the pin defined as RX, and vice-versa.

Thanks for your reply i tried newsoftserial and i get wierd characters. Tried differnt baud settings. any suggestions?

Not really. What baud rate is the bluetooth modem talking to the NewSoftSerial port at? Are you reading data at the same rate?

You mentioned earlier that you were getting weird characters when using the hardware port, when the bluetooth module was wired wrong. Are you sure that you are trying to receive on the right pin, now?