Pages: [1]   Go Down
Author Topic: error detecting rfid tags  (Read 812 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sir  im new to arduino my project is using RFID
when tag is shown in rfid it transmits tag information via xbee
on arduino serial data received via xbee
But when tag is shown on reader it produces output like this "16703301<CR><LF>"
i cant predetermine this in aurdino program my code is

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

String readString;

void setup() {
Serial.begin(9600);
         lcd.begin(16, 2);
        }

void loop() {

        
        lcd.setCursor(0, 1);
        while (Serial.available()) {
        delay(10);  
    
        char c = Serial.read();  
        if (c == ',') {break;}  
        readString += c; }
            
      if (readString.length() >0) {
      Serial.println(readString);

       if(readString == 16703301) // Here i can determine tag no only
       {
          Serial.print("hello");
          lcd.print("hello");
        }
        
        else if(readString == 16705890)
       {
          Serial.print("HI");
          lcd.print("hi");
        }
        else
        {
          Serial.print("enterno");
          lcd.print("enter no");
        }
        readString="";
   }
}

Moderator edit: CODE TAGS

so when tag is shown it cant execute if loop it displays enter no:

can anyone help to fix this
im using 125KHZ RFID Reader
« Last Edit: March 09, 2012, 02:44:12 am by AWOL » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
String readString;   
       if(readString == 16703301) // Here i can determine tag no only

You should probably be comparing String to a character string, not an integer constant:
Code:
       if(readString == "16703301")
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sir i tried tht it works when i send data via serial monitor
but when this transmitted via xbee 16703301<CR><LF> it displaying serial data as 16703301 and showing enter no
RFID Reader sends 16703301<CR><LF> this data via xbee
if i connect receiver xbee to pc and opened RS232 analyzer in tht it displays 16703301<CR><LF> this data correctly.
BUT in aurdino
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

String readString;

void setup() {
Serial.begin(9600);
         lcd.begin(16, 2);
        }

void loop() {

        //expect a string like wer,qwe rty,123 456,hyre kjhg,
        //or like hello world,who are you?,bye!,
        lcd.setCursor(0, 1);
        while (Serial.available()) {
        delay(10);  //small delay to allow input buffer to fill
    
        char c = Serial.read();  //gets one byte from serial buffer
        if (c == ',') {break;}  //breaks out of capture loop to print readstring
        readString += c; } //makes the string readString  
            
      if (readString.length() >0) {
      Serial.println(readString); //prints string to serial port out
      
       if(readString =="16703301<CR><LF>")
       {
          Serial.print("hello");
          lcd.print("hello");
        }
        
        else if(readString == 16705890)
       {
          Serial.print("HI");
          lcd.print("hi");
        }
        else
        {
          Serial.print("enterno");
          lcd.print("enter no");
        }
        readString=""; //clears variable for new input
   }
}
Moderator edit: CODE TAGS again.

and showing this no only 16703301
wht can i do pls help me sir
« Last Edit: March 09, 2012, 02:44:56 am by AWOL » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
"16703301<CR><LF>"
Is that really what is transmitted?
Or is it
Code:
"16703301\r\n"
?

When posting code, please use the # icon on the editor's toolbar to give a code box - it avoids all sorts of potential code corruption and misinterpretation.
« Last Edit: March 09, 2012, 02:54:59 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sir i write this program to check rfid output when i declared as char it displays card no as 16703310
but when i declare as string it displays the rfid output as 49545548515148491310

Code:
#include <LiquidCrystal.h>

String  incoming = 0;  
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);
  lcd.print("ARMCET");
  Serial.begin(9600);  
}

void loop()
{
  lcd.setCursor(0, 1);
  if (Serial . available() > 0) {
                incoming =  Serial.read();
                //Serial.println( "I received: ");
                lcd.println( incoming  );
                Serial.print(incoming );
                
              
}
}
« Last Edit: March 09, 2012, 04:03:01 am by vsathish » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
49 54 55 48 51 51 48 49 13 10
ASCII - look up the codes.

What happened to the code tags?

And stop calling everyone "sir" .
« Last Edit: March 09, 2012, 02:55:40 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

16703301<CR><LF> only sir the got in RS232 analyzer
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand your last post.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What happened to the code tags?
i cant understand this sir im new to aurdino code tags means
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When posting code, please use the # icon on the editor's toolbar to give a code box - it avoids all sorts of potential code corruption and misinterpretation.
Put your code between the [ code ]  [ / code ] tags which appear.

Stop calling me "sir" - I am not (yet) a Knight of the Realm.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

first i checked the serial input of aurdino thts y i wrote this program
Code:
#include <LiquidCrystal.h>

String  incoming = 0;  
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);
  lcd.print("ARMCET");
  Serial.begin(9600);  
}

void loop()
{
  lcd.setCursor(0, 1);
  if (Serial . available() > 0) {
                incoming =  Serial.read();
                lcd.println( incoming  );
                Serial.print(incoming );
                
              
}
}

in this when i declared as char it shows the card no as 16703301 but when i change the decleration as string it shows card no as 49545548515148491310

in the below prg i declered as string only #include <LiquidCrystal.h>
Code:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

String readString;

void setup() {
Serial.begin(9600);
         lcd.begin(16, 2);
        }

void loop() {

        //expect a string like wer,qwe rty,123 456,hyre kjhg,
        //or like hello world,who are you?,bye!,
        lcd.setCursor(0, 1);
        while (Serial.available()) {
        delay(10);  //small delay to allow input buffer to fill
    
        char c = Serial.read();  //gets one byte from serial buffer
        if (c == ',') {break;}  //breaks out of capture loop to print readstring
        readString += c; } //makes the string readString  
            
      if (readString.length() >0) {
      Serial.println(readString); //prints string to serial port out
      
       if(readString =="16703301<CR><LF>")// here i changed to "49545548515148491310" but when card shown it is not executing this loop
       {
          Serial.print("hello");
          lcd.print("hello");
        }
        
        else if(readString == 16705890)
       {
          Serial.print("HI");
          lcd.print("hi");
        }
        else
        {
          Serial.print("enterno");
          lcd.print("enter no");
        }
        readString=""; //clears variable for new input
   }
}
« Last Edit: March 09, 2012, 04:05:28 am by vsathish » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, go back to you last post.
Click on "modify".
Highlight all the code, then click on the # icon on the toolbar, then click "save".

Then we can talk.

Quote
shows card no as 49545548515148491310
I've already explained that bit - look up the decimal values of the ASCII codes for the digits 16703301
« Last Edit: March 09, 2012, 03:33:52 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: