Arduino > RFID
Le Seeedstudio RFID est un lecteur à très faible coût qui détecte les tags RFID à une distance d'environ 1". Lorsqu'un tag est détecté, il allume une DEL externe et envoie par protocole série TTL à 9600 baud:
Pour pouvoir recueillir les tags détectés par le Seeedstudio RFID, l'utilisation de la carte Arduino est exagérée. Un simple convertisseur USB vers série? est suffisant.
Fiche technique: seeestudio_rfid_datasheet.pdf
Recueillir les données dans votre logiciel hôte avec un des exemples de la communication série ASCII?.
Brancher le lecteur RFID à l'Arduino selon le tableau suivant:
Broche RFID | Broche Arduino |
TX | 2 (numérique) |
GND | GND |
5V | 5V |
#include <SoftwareSerial.h> // This simple example echoes a detected tag id to the computer // The computer's serial port baud rate must be set to 57600 // Tag ids are 10 chars long, but we add an 11th null char to convert // the data to a string when passed to Serial.print() char tag[11]; byte index = 0; // Index of char being written // Connect the seeedstudio's TX pin to pin 2 of the Arduino #define RX 2 #define TX 3 // Not used SoftwareSerial softSerial = SoftwareSerial(RX, TX); void setup() { tag[10] = 0; Serial.begin(57600); softSerial.begin(9600); } void loop() { // Read serial data byte b = softSerial.read(); if ( b == 2 ) { // Tag ids start with a 2 index = 0; } else if ( index == 10 ) { // We received the 10 bytes of the id Serial.print("tag "); Serial.println(&tag[0]); index = 0; } else { tag[index] = b; index = index + 1; } }