0

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:

Schematics of connections

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

This is the photo of the connections:

Actual photo

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:

Serial monitoring from PC

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?

  • pins 0 and 1 are used by the serial port to the PC ... choose some other pins and use software serial ...lots of examples can be found – jsotola Jan 25 at 22:14
  • Sorry, but It seems you did not read the whole question. I have connected pins 0 and 1 to the PC. Furthermore, I have done the same using SoftwareSerial library using other port. The same problem happens (as the final of the question tells) – jstuardo Jan 25 at 22:16
  • i only read to the first picture ... it shows an interference between USB serial and the IP modem ... it is pointless to read any further – jsotola Jan 25 at 22:57
  • @jsotola as a teaching, don't read only the introduction to get the whole knowledge of a text – jstuardo Jan 25 at 23:05
  • i understand what you are saying ... i simply made a comment about the first problem i saw .... please add your sketch that uses software serial – jsotola Jan 25 at 23:17
1

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
| improve this answer | |
  • you are a genius!! after 2 days of fight, that was the solution! – jstuardo Jan 25 at 23:20
  • @jstuardo Additional note for faster research results the next time: Write down the bits as they are sent, and as they are received. Asynchronous serial communications uses LSB first here. 'A' = 0x41 = 0b01000001. Sent:0-1-0-0-0-0-0-1-0-1 Received: 0-1-1-1-1-1-0-1-0-1. I think it's quite obvious. ;-) Alternative way: Use an oscilloscope and watch TX and RX. – the busybee Jan 26 at 10:57
  • @thebusybee that is transparent for the systems. Sender always sends the data using LSB first, and receiver receives the data with LSB first. By the way, if 0x41 (0b01000001) is sent, it is actually sent 1-0-0-0-0-0-1-0 and received 0-1-1-1-1-1-0-1. I don't know why do you showed different bit pattern. And using oscilloscope is interesting, however, it is not really necessary for now. The key point here is that inverted bits are actually transmitted. – jstuardo Jan 26 at 16:40
  • Yes, I know about the inverted bits. I added the start and stop bits to show that they are relevant for the analysis. -- And since I don't know your (and future readers') experiences I mentioned "LSB first." Not all serial communication protocols use this. – the busybee Jan 27 at 7:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.