Arduino Mega 2560 RFID Serial Communication

I have an RFID reader:

Something like same above along with ITEAD TFT shield & GSM Modem. The RFID reader has RS-232 port as well as GND,TX and 5V pins. I am using Arduino Mega 2560 Board. I have connected the TX,GND of RFID reader to RX3 pin 15 / GND (pin) of Arduino. Note I am supplying 12 V to RFID via a adapter.

Note the ITEAD TFT shield consumes TX0, RX0 pins - so I cannot make use of RX0 and TX0 pins. Though I have not written the code for GSM modem.

Now while running the below program I am getting junk output both in my TFT display as well as serila monitor:

#define __AVR__
#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB24,59,58,57,56);
String myString = "";

void setup() {
   Serial3.begin(9600);
   myGLCD.InitLCD();
   myGLCD.clrScr();
}

void loop() {
  myGLCD.setFont(BigFont);
  if (Serial3.available()) {
    int inByte = Serial3.read();
     myString += String(inByte);
    }
    if(myString.length() == 10)
      myGLCD.print(myString, CENTER, 0);
}

TFT Screen output:

1310494848

Serial Monitor Output- non printable junk character.

The value is incorrect I am pretty sure, what wrong am I doing?

I found that ITEAD shield is sending or rather using RX0/TX0 pins very frequently - some data is going thru.

BTW what is the functionality of http://arduino.cc/en/Tutorial/SoftwareSerialExample ?

Well in all other words “How can I use 3 different Serial I/Os individually at same time without disturbing any other I/O?”

Serial Monitor Output- non printable junk character.

Why do you expect your SerialMonitor to output any readable text if the display is connected to that interface?
BTW, you're not writing anything to the Serial object (which is good).
The output on the TFT screen may show the serial of an RFID Token but that's just a guess.

Please provide links to the hardware you're using.

Please find the details in link - http://forum.arduino.cc/index.php?topic=276581.0

The below code works well [I get the corect reading at Serial Monitor] but no display of data in TFT screen even I have checked with constant values to be displayed:

#define __AVR__
#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

String myString = "";
    UTFT myGLCD(ITDB24,59,58,57,56);
void setup() {
   Serial3.begin(9600);
   Serial.begin(9600);
   myGLCD.InitLCD();
   myGLCD.clrScr();
    myGLCD.setFont(BigFont);
   }

void loop() {
   
      if (Serial3.available()) {
       int inByte = Serial3.read();
       Serial.write(inByte);
       //myString += String(inByte);
    } 
    if (Serial.available()) {
    int inBytet = Serial.read();
    myString += String(inBytet);
    }
    if(myString.length() >= 10){
     myGLCD.print(myString, CENTER, 0);
     myString = "";
    }
}

prakash_prasad:
Please find the details in link - http://forum.arduino.cc/index.php?topic=276581.0

I cannot find a link to the hardware in that post. Why do you think that the Display uses TX0 and RX0?

The below code works well [I get the corect reading at Serial Monitor] but no display of data in TFT screen even I have checked with constant values to be displayed:

#define __AVR__

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont;
extern uint8_t BigFont;
extern uint8_t SevenSegNumFont;

String myString = “”;
    UTFT myGLCD(ITDB24,59,58,57,56);
void setup() {
  Serial3.begin(9600);
  Serial.begin(9600);
  myGLCD.InitLCD();
  myGLCD.clrScr();
    myGLCD.setFont(BigFont);
  }

void loop() {
 
      if (Serial3.available()) {
      int inByte = Serial3.read();
      Serial.write(inByte);
      //myString += String(inByte);
    }
    if (Serial.available()) {
    int inBytet = Serial.read();
    myString += String(inBytet);
    }
    if(myString.length() >= 10){
    myGLCD.print(myString, CENTER, 0);
    myString = “”;
    }
}

You don’t write the string to the display anymore but you wait for characters from the Serial Monitor.

Thanks I got the issue. The issue was that the String Object in Arduino does not supports ‘+’ operator (I was assuming it to concat values). As such my string variable was always empty and nothing got printed in TFT.

The below code works fine and I am able to integrate RFID reader at Serial port 3 along with displaying of data in ITEAD TFT screen :

#define __AVR__
#include <UTFT.h>

extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB24,59,58,57,56);
char myString[15];
int ind = 0;

void setup() {
   Serial3.begin(9600);
   myGLCD.InitLCD();
   myGLCD.clrScr();
   myGLCD.setFont(BigFont);
}

void loop() {
  if (Serial3.available()) {
     int inByte = Serial3.read();
     if(inByte >= 33 && inByte <= 127)
       myString[ind++] = char(inByte);
    }
    if(ind >= 10)
    {
      myString[ind] = '\0';
      myGLCD.print( (char *)myString,CENTER, 0);
      memset(myString, 0 , 15);
      ind = 0;
    }
}

Thanks I got the issue. The issue was that the String Object in Arduino does not supports '+' operator (I was assuming it to concat values). As such my string variable was always empty and nothing got printed in TFT.

Arduino's String object does support the '+' operator but you should avoid using the String object anyway because the implementation does not work well on an embedded platform with very little memory and no memory management unit as todays PCs have.