Assembling int received to one string (WL-125 RFID)

Dear all,
I recently bought a RFID WL-125 devise for an instalation.
I try to exploit the Identification Number of the card with arduino. The arduino input is in RX. With Serial.read, I can catch some number. See the picture :

with this code :

  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
if (Serial.available()>0)
  {
    while(Serial.available()) 
    {
      int data = Serial.read();
      Serial.println(data);
    }
  }
}

The problem is that all the int I have can't be use in this format. I think I have to "assemble" all the number to creat the ID.

Because after, I would like to do : num 02484948705369495254704303 match (or not) with the data base. "approved or disapprove"

Please, is someone can help me ? Thanks a lot in advance !

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

will you please paste your whole program?

The program I sent was the whole one.

I also try this :

#include <SoftwareSerial.h>

unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 
const int tagLength = 13;

String matchingTag = "010F5E146F+";


void setup()
{ 
  Serial.begin(9600);             // the Serial port of Arduino baud rate.
  Serial.println("RFID module started in Auto Read Mode, Waiting for Card...");
}

void loop()
{
  
  
  
  if (Serial.available())              // if date is comming from softwareserial port ==> data is comming from SoftSerial shield
  {
    while(Serial.available())          // reading data into char array 
    {
      buffer[count++]=Serial.read();     // writing data into array
      if(count == 64)break;
    }
    
    //Serial.write(buffer,64);
   Serial.write(buffer,count);     // if no data transmission ends, write buffer to hardware serial port
    clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
    count = 0;                       // set counter of while loop to zero
  }
}

void clearBufferArray()              // function to clear buffer array
{
  for (int i=0; i<count;i++)
  { 
    buffer[i]=NULL;
  }                  // clear all index of array with command NULL
}

but it give me an output value like that : "010F5E1467#" but this is not a String ...

Thank for your help and sorry for my mistake#UKHeliBob ! i am new on this forum.

what type is it reading?

I think this is HEX. In reality, I can configure the format I want with this fonction :
with : Serial.println(data, HEX);


or with : Serial.println(data, BIN);

looks like ascii codes to me..

02 Start of Text
48 0
49 1
48 0
70 F
53 5
69 R
49 1
52 4
54 6
70 F
43 +
03 End of text

Thanks a lot for your answer. :slight_smile:

Do you have an example of a code whitch can read the serial value from the D0 (RX) of the arduino and put it in a String please?
My programation level is realy bad ... !

you were doing pretty good..
took what you had a worked it a bit for you..

#include <SoftwareSerial.h>

unsigned char buffer[64]; // buffer array for data recieve over serial port
int count = 0;   // counter for buffer array
const int tagLength = 13;


const char matchingTag[] = "010F5E146F+";


void setup()
{
  Serial.begin(9600);             // the Serial port of Arduino baud rate.
  Serial.println("RFID module started in Auto Read Mode, Waiting for Card...");
  clearBuffer();
}

void loop()
{

  if (ChecForTag())
  {

    if (strcmp(buffer, matchingTag) == 0)
    {
      Serial.println("Tag Matched");
      Serial.write(buffer, count);
      Serial.println();
    } else {
      Serial.println("Tag Not Matched");
      Serial.write(buffer, count);
      Serial.println();
    }
    //clear buff
    clearBuffer();
    //reset count
    count = 0;
  }

}

// function to clear buffer array
void clearBuffer()
{
  for (int i = 0; i < count; i++)
  {
    buffer[i] = NULL;
  }                  // clear all index of array with command NULL
}

bool ChecForTag()
{
  bool haveTag = false;
  //is there a byte
  if (Serial.available())
  { //while there is a byte
    while (Serial.available())
    { //read a byte
      char c = Serial.read();
      // SOT, EOT, NL don't include
      if (c != 2 && c != 3 && c != 10)
      { //save byte to butter, increase count
        if (count < sizeof(buffer)) {
          buffer[count] = c;
          count++;
        }
      } else { //EOT recvd, we have a tag
        if (c == 3) haveTag = true; //EOT -end of text
        if (c == 10) haveTag = true; //NL - also trigger here in case no EOT, for sim
      }
    }
  }
  return haveTag;
}

try it here..

have fun!! ~q

lol, spelled check wrong.. coding from couch, sorry.. got buffer as butter too but that's a comment so don't count.. :slight_smile:

Ho my god !!! It is working !!! :smiley:

See the picture :

Thanks a lot for your contribution :slight_smile:

you're melcome! :slight_smile: