Problemi con lettore RFID ID-12LA


salve tutti, mi chiamo gabriele e mi sono da pochissimo tuffato nel magico mondo di arduino.
premetto che ho scarsissime capacità elettroniche e software, mi sono letto il libro allegato allo starter kit arduino e fatto vari progetti del libro. adesso, però, sono alle prese con un progettino rfid che sto provando fare seguendo il libro "creare progetti per arduino dummies", e sinceramente non è proprio dummies.. o per lo meno, secondo me, da per scontate troppe cose che non conosco.

il problema è questo: ho collegato il lettore con la breakout sparkfun, attaccato alla breadboard - controllato mille mila volte le connessioni e mi sembra che sia tutto ok. lanciando lo sketch, dal monitor seriale non accade niente quando passo il tag.

code: [select]


/* arduino projects dummies
 * brock craft
 *
 * chapter 9: building rfid tag reader
 * system reads , matches rfid tag trigger relay
 *
 * v0.1 30.04.2013
 * adapted bildr.com
*/


 const int relaypin = 11;      // pin relay connected to
const int ledpin = 12;        // pin indicaor led connected to
const int rfidresetpin = 13;  // pin tells reader read again
const int relayontime = 5000; // time leave relay on, in ms.

// make list of rfid tags here.
// if don't know them, leave @ least 1 in place starter
// starter id , delete later. otherwise code break.
// (you have have compare read tags to.)

char tag1[13] = "4b00ddbf9fb6";  // scanned tag id goes here
char tag2[13] = "010203aabbcc";  // these example iag ids only
char tag3[13] = "010203aabbdd";  // these example iag ids only
// etc. more tags

void setup(){
  serial.begin(9600);               // start serial connection tx/rx data
  pinmode(rfidresetpin, output);    // tells reader start again
  pinmode(ledpin, output);          // set led pin output
 pinmode(relaypin, output);          // set led pin output
  digitalwrite(rfidresetpin, high); // make ready read
  serial.println("ready.");         // advise consoe ready.
}

void loop(){

  serial.println("looking tag..."); // doing
  char tagstring[13];      // create array hold tag reading
  int index = 0;           // utility counter track in tagstring[]
  boolean reading = false; // stores whether have reading

  while(serial.available()){  // if there serial connection...

    int readbyte = serial.read();      // read next available byte
    if(readbyte == 2) reading = true;  // 2 indicates begining ofa tag
    if(readbyte == 3) reading = false; // 3 indicates end of tag
   
    // if there reading , it's not beginning or end, store it
    if(reading && readbyte != 2 && readbyte != 10 && readbyte != 13){
     
      tagstring[index] = readbyte;  // store tag @ index point
      index ++;                     // increment in storage array
    }
  }

  checktag(tagstring); // check if match
  cleartag(tagstring); // clear char array of values
  resetreader();       // reset rfid reader

}

void checktag(char tag[]){

  // compare tag stored tags
  if(strlen(tag) == 0) return; // if there's nothing here, nothing

  if(comparetag(tag, tag1)){   // if read tag matches tag1, this
    lightled();
 // relay non c'è per ora! ****   triggerrelay();
  }
  else if(comparetag(tag, tag2)){ // if read tag matches tag2, this
    lightled();                   // have function here!
  }
  else if(comparetag(tag, tag3)){ // if read tag matches tag3, this
    lightled();
  } else {                        // if doesn't match list of tags...
    serial.println("new tag found: ");
    serial.println(tag);         // print tag number of new tag
    delay(5000);                 // wait 5 seconds, can make note of it
  }

}

boolean comparetag(char one[], char two[]){
  // compare our 2 chars see whether tag
  // read same stored tag
 
  if(strlen(one) == 0) return false; // if there's nothing here, nothing

  for(int = 0; < 12; i++){
    if(one[i] != two[i]) return false; // if 2 tags are not same, return no match
  }
  serial.println("valid tag found!");
  return true; // otherwise, return there match!
}

void lightled(){
  digitalwrite(ledpin, high);  // turn on ledpin
  delay(250);                  // wait moment
  digitalwrite(ledpin, low);   // turn off ledpin
}

void triggerrelay(){
digitalwrite(relaypin, high);  // turn on ledpin
delay(relayontime);            // wait moment
digitalwrite(relaypin, low);   // turn off ledpin
}

void cleartag(char one[]){
  // clear tag reading char array filling ascii 0
  // if not null, indicate tag read
  for(int = 0; < strlen(one); i++){
    one[i] = 0;
  }
}
 
void resetreader(){
  // toggle reset pin rfid reader read again
  digitalwrite(rfidresetpin, low);
  digitalwrite(rfidresetpin, high);
  delay(150);
}



edit: ho fatto un test con la scheda rfid usb reader per capire se in effetti è il lettore che ha un malfunzionamento o meno... funziona! se passo un tag si accende la spia ed il buzzer emette un leggero suono.

a questo punto la mia domanda è: il lettore rfid id-12la deve essere per forza saldato alla breakout? ho provato, come consigliato in diversi altri progetti, ad utilizzare piedini pettine e quelli maschio/maschio ma in questo modo non funziona niente. credo che il problema sia proprio nel fatto che il lettore non riesce collegarsi.. mentre utilizzato la rfid usb reader non ci sono problemi.

grazie in anticipo chi saprà aiutarmi!

saluti.

buongiorno,
essendo il tuo primo post, nel rispetto del regolamento, ti chiedo cortesemente di presentarti qui (spiegando bene quali conoscenze hai di elettronica e di programmazione ... possibilmente evitando di scrivere solo una riga di saluto) e di leggere con attenzione il su citato regolamento ...

... poi, in conformità al suddetto regolamento, punto 7, edita (in basso destra del post, bottone more -> modify) il tuo post e racchiudi il codice all'interno dei tag code (... sono quelli che in edit inserisce il bottone fatto così: </>, tutto sinistra). grazie.

guglielmo


Arduino Forum > International > Italiano > Generale (Moderator: leo72) > Problemi con lettore RFID ID-12LA


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'