Outils pour utilisateurs

Outils du site


id-12la

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
id-12la [2016/05/23 15:20]
colin
id-12la [2018/05/26 03:14] (Version actuelle)
colin
Ligne 1: Ligne 1:
-====== ​RFID ======+====== ​ID12LA ​======
  
-ID-12LA fonctionne jusqu'​à environ 2.5 cm de distance+ID-12LA fonctionne jusqu'​à environ 2.5 cm de distance
 +Le rafraîchissement des données se fait à environ 8Hz.
  
 Liens : Liens :
Ligne 7: Ligne 8:
 [[http://​bildr.org/​2011/​02/​rfid-arduino/​|http://​bildr.org/​2011/​02/​rfid-arduino/​]] [[http://​bildr.org/​2011/​02/​rfid-arduino/​|http://​bildr.org/​2011/​02/​rfid-arduino/​]]
 [[https://​hcgilje.wordpress.com/​resources/​rfid_id12_tagreader/​|https://​hcgilje.wordpress.com/​resources/​rfid_id12_tagreader/​]] [[https://​hcgilje.wordpress.com/​resources/​rfid_id12_tagreader/​|https://​hcgilje.wordpress.com/​resources/​rfid_id12_tagreader/​]]
 +[[https://​www.raspberrypi.org/​forums/​viewtopic.php?​t=31552|Raspberry]]
  
 Datasheet : Datasheet :
Ligne 13: Ligne 15:
  
  
 +Attention au conflit de port sur l'​entrée RX 0. 
 +Il faut débrancher le port 0 pour téléverser le programme.
 +Pour cette raison, j'ai utilisé la librairie SoftwareSerial pour éviter ce problème.
 +
 +Si 2 tags sont en même temps cela ne fonctionne pas !
 +
 +<code c>
 +/*
 + * Author : http://​bildr.org/​2011/​02/​rfid-arduino/ ​ and Colin Bouvry
 + */
 +
 +#include <​SoftwareSerial.h>​
 +
 +// ID12LA
 +const int RFIDResetPin = 13;
 +const int MAXCHARACTER = 10;
 +char tagString[MAXCHARACTER];​
 +unsigned long timeElapsedMs;​
 +
 +// software serial #2: RX = digital pin 8, TX = digital pin 9
 +// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
 +SoftwareSerial portId12LA(8,​ 9);
 +
 +void setup(){
 +  Serial.begin(9600);​
 +
 +  // ID12LA
 +  portId12LA.begin(9600);​
 +  pinMode(RFIDResetPin,​ OUTPUT);
 +  digitalWrite(RFIDResetPin,​ HIGH);
 +}
 +
 +void loop(){
 +
 + // ID12LA
 +
 +  if(millis() - timeElapsedMs > 150)
 +  {
 +    timeElapsedMs = millis();
 +    ​
 +    int index = 0;
 +    boolean bReading = false;
 +    boolean bNewTag = false;
 +    portId12LA.listen();​
 +    while(portId12LA.available()){
 +  ​
 +      int readByte = portId12LA.read();​ //read next available byte
 +  ​
 +      if(readByte == 2) 
 +      {
 +        bReading = true; //begining of tag
 +        index = 0;
 +      }
 +      if(readByte == 3) 
 +      {
 +        bReading = false; //end of tag
 +        bNewTag = true;
 +      }
 +  ​
 +      if(bReading && readByte != 2 && readByte != 10 && readByte != 13){
 +        //store the tag
 +        if(index < MAXCHARACTER)
 +          tagString[index] = readByte;
 +        index ++;
 +      }
 +    }
 +  ​
 +    if(bNewTag)
 +      sendTag(tagString);​ //Send tag
 +      ​
 +    clearTag(tagString);​ //Clear the char of all value
 +    resetReader();​ //Reset the RFID reader
 +  }
 +}
 +
 +
 +void sendTag(char tag[]){
 +///////////////////////////////////​
 +//Check the read tag against known tags
 +///////////////////////////////////​
 +  if(strlen(tag) == 0) 
 +     ​return;​ //empty, no need to contunue
 +  Serial.println(tag);​ //read out any unknown tag
 +}
 +
 +void resetReader(){
 +///////////////////////////////////​
 +//Reset the RFID reader to read again.
 +///////////////////////////////////​
 +  digitalWrite(RFIDResetPin,​ LOW);
 +  digitalWrite(RFIDResetPin,​ HIGH);
 +  //​delay(150);​ //150
 +}
 +
 +void clearTag(char one[]){
 +///////////////////////////////////​
 +//clear the char array by filling with null - ASCII 0
 +//Will think same tag has been read otherwise
 +///////////////////////////////////​
 +  for(int i = 0; i < strlen(one);​ i++){
 +    one[i] = 0;
 +  }
 +}
 +
 +</​code>​
id-12la.1464009627.txt.gz · Dernière modification: 2016/05/23 15:20 par colin