TX pin sends wrong data in Arduino Uno I want to send some data to an IP Modem from Arduino Uno. That IP Modem has TTL levels TX and RX inputs. 

I used this connection between Arduino to the IP Modem:



I am powering Arduino with 12 V plugged in the barrel.

This is the photo of the connections:



I connected the PC to the USB connector of Arduino and I uploaded the following sketch to send "AABB" to the Modem:

void setup(void) {
  Serial.begin(115200);
}

void loop(void) {
 Serial.print("AABB");

 delay(5000); // Envía la temperatura cada 5 segundos
}


When monitoring what is received by the modem, it is 

0x5F 0x5F 0xAF 0x2F

If I send just "A", the character received each 5 seconds is 0x5F.

Of course, both ends are configured as 115,200bps, 8N1.

In order to discard Modem problem, I connected RX, TX and GND in Arduino to a DB9 female connector and then to a RS232 - USB converter and started monitoring with my PC.

My surprise was that the data received is exactly the same as the received by the modem when it was connected. As seen in the following picture:



As you see in the picture, "_" twice was shown (ASCII 0x5F), {\xaf} and finally "/" (ASCII 0x2F).

Above test confirms Arduino is sending wrong data.

Something to note. When I monitor using USB cable connected to Arduino and using Monitor Serie in the Arduino IDE, I  see correctly "AABB". The problem is when using TX and RX pins (the same happened if I used other pin along with SoftwareSerial library)

What may be going on?
Since you have already tried SoftwareSerial, also try inverting the serial protocol via SoftwareSerial.  Sometimes a device uses inverted serial protocol and you don't know it.

So initialize inverted add 1 to the end of the contructor like so :

SoftwareSerial mySerial(RXPIN, TXPIN,1); // RX, TX, inverted