0

I’m currently working on a project with Android, Firebase, and Arduino, where I want to send the UID from the FireBase project, to my arduino (after registering a new user) so that I can write it to a MIFARE tag using the MFRC522. I'm doing this with a USB OTG cable. For sending the UID string to arduino i'm using this [UsbSerial Library][1, which i found on this blogpost:

https://www.allaboutcircuits.com/projects/communicate-with-your-arduino-through-android/

Connecting with Arduino is working and when sending the UID from the app it shows be the UID string that I've just sent.However, when I read the tag, it shows a string like this:

⸮J⸮⸮⸮-⸮Zz⸮⸮Z/m⸮) h⸮1=#⸮⸮⸮⸮=?⸮

When I manually write the UID string to the serial monitor, it seems to work fine Because when I read the tag, it shows me the correct UID string, e.g.:

IaxeEXNUpRUhqfbyW78LtyoRbQw1

They are the same size. So something is going wrong when executing the following code in Arduino :

   byte buffer[28];


if(Serial.available()>0)  
      { 
    Serial.readBytes(buffer, 28); //UID is 28 bits long
    }

In Android I send the string by doing this:

public void SendUID(String s){
        byte[] bytesOut = s.getBytes();
        serialPort.write(bytesOut   );
        tvAppend(textView, "\nData Sent : " + uid + "\n");
    }

Is anyone familiar with this problem?

thank you.

PS: This is my first post so sorry if I'm not being clear enough

JAG
  • 1

1 Answers1

0

Use 64 byte buffer. Check whether the baud rates of sending from android and receiving on Arduino are same.

thapro
  • 44
  • 11