Skip to main content
Arduino

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

UART communication - Serial is always empty

I have a payment terminal which uses UART (or simply speaking Rx, Tx, Gnd pins) and I have an Android tablet app which is connected to the terminal using USB to DB9 adapter based on PL2303 chip. The Android app works well and it uses https://github.com/felHR85/UsbSerial to support serial communication. The protocol is very simple, basically Android sends strings like "REQINFO,4", "L2,xxx,xxx,*" etc. and recieves back a string statuses.

I'm trying to replace Android app with Arduino UNO, for which I naively assumed would be enough just to connect Tx,Rx of the terminal with Rx,Tx pins of the Arduino and also to connect Gnd pins. But I can't get it working. The only thing I noticed is when I connect Arduino Rx to terminal Tx, the terminal's screens briefly shows "Connecting..." but that's probably because it detects some incoming voltage. When it comes to reading Serial (or also I tried SoftwareSerial) nothing is ever returned.

String data = "";
void setup() {
 Serial.begin(9600);
 while (!Serial);
 delay(1000);
 Serial.println("REQINFO,4");
 delay(1000);
}
void loop() {
 if (Serial.available()) {
 char c = Serial.read(); // also I tried readString() and readStringUntil()
 if (c == '\n' || c == '\r') {
 Serial.println(data); // jsut to see it in the montor
 } else {
 data += c;
 }
 }
}

So do I miss anyting in order to have a proper communication? Thanks.

Answer*

Draft saved
Draft discarded
Cancel
6
  • I'm pretty sure that whole system functioning using 5V but indeed it's a good idea to doublecheck that. Regarding sniffing, I actually tried something similar by connecting my Arduino to the tablet and staring into monitor window. For some reason that didn't show me any info either. Commented Oct 8, 2019 at 7:15
  • So, are you suggesting to try a TTL adapter like this -m.ebay.co.uk/itm/… ? Commented Oct 8, 2019 at 7:17
  • That hardware would do it, yes. You might need 2 of them, one to the tablet, and one for the reader. But first, check the voltages! Commented Oct 8, 2019 at 12:17
  • today I tried your suggestion with TTL converter and indeed it works well. Now I can sniff data coming from tablet to Arduino. I used Arduino Mega so I hooked terminal to Rx2,Tx2. But for some reason attaching another TTL on between these pins and the terminal didn't bring any value. I wonder do I need it at all, as without TTL for terminal I can at leat recieve some gibberish -- ⸮⸮i⸮v맧⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮u[[⸮⸮_gu}Yu⸮Yucw⸮}⸮gaqmc⸮[uya[w⸮⸮ possible there's a way to adjust something (baud rate?) to see real content. Anyway thanks, you helped me a lot! Commented Oct 11, 2019 at 2:05
  • If you have access to - even a cheap (8ドル) - logic analyzer, you can determine the speed. Or you can test common baud values. You can also send to your PC hex values, the data might be binary, and it'll stay gibberish, even when the settings are right. Commented Oct 12, 2019 at 15:36

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /