Strange reverse ? mark and " in serial monitor and its not baud rate

Hi Everyone,

I have been working on a RFID reader, using some example code and adapting it.

Most of it works ok but I get a strange reverse ? and " before the code is printed on the serial monitor.

Heres my code-:

int val = 0;
int ledPin = 13;
int sigPin = 11;
int status = 0;
long tagNum = 0;
unsigned char searchCMD[] = {0xAA, 0xBB, 0x02, 0x20, 0x22};
unsigned char searchRES[4];

void setup()
{
  Serial.begin(19200);
  pinMode(13, OUTPUT);
  pinMode(sigPin, INPUT);
  Serial.println("Waiting for Card");
}

int searchCard()
{

  Serial.write(searchCMD, 5);
  delay(300);
  status = 0;
  while (true) {
    if (Serial.available() > 0) {
      val = Serial.read();

      switch (status) {
        case 0:                         // parse 0xAA
          if (val == 0xAA) status = 1;
          break;

        case 1:                         // parse 0xBB
          if (val == 0xBB) status = 2;
          else return -1;
          break;

        case 2:                         // parse 0x06
          if (val == 0x06) status = 3;
          else return -1;
          break;

        case 3:                         // parse 0x20
          if (val == 0x20) status = 4;
          else return -1;
          break;

        case 4:
        case 5:
        case 6:
        case 7:
          searchRES[status - 4] = val;
          Serial.print (val);
          status ++;
          break;
        case 8:
          return 0; // read successfully
          break;
        default:
          return -1;
          break;
      }
    }
  }
}

void loop()
{

  delay(100);
  if (digitalRead(sigPin) == LOW) {
    Serial.println("Card Detected");
    Serial.write(searchCMD, 5);
    if (searchCard() != -1) {

    }
    else {

    }
  }
}

and here is a screenshot of the serial monitor attached.

Could anyone please tell me whats wrong? The baud rate is fine set at 19200 for the module and in the serial monitor. What else could it be?
I need to get rid of this as I need it clean to go into Excel.

Thanks for your time

What do you expect Serial.write(searchCMD, 5);to print on your serial monitor?

Did you actually connect both the serial console and some sort of serial external device on pin 0 and 1? That’s not a good idea, Serial is point to point, you can’t really have 3 devices on the serial line.

Hi,
Thanks for the reply but I dont understand most of what you are stating. Sorry I am not very good at coding but very willing to learn.

I only expected the number to be displayed on the serial monitor and dont understand what the additional characters are or caused by?

I actually connected 1 RFID to the Tx Rx pins of the arduino uno, apart from that I am only using the serial monitor within the IDE. I dont know what you mean by a third device?

Thanks

In simple terms The serial monitor (through the USB cable) is connected to the same 0 and 1 pin. (In technical terms, on a UNO, Serial: 0 (RX) and 1 (TX) are Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.)

If you do Serial.print you send stuff over USB by tickling the Tx pin

You can’t have both, explore software serial or go for another arduino with more than one hardware serial port

As a side note, im confused about what thought process would get you to think that the first line means go to the monitor and the second line go to the RFID device. How should the code know?

Serial.println("Card Detected");
Serial.write(searchCMD, 5);

both are sending bytes over the same Serial object.