déclaration rfid


bonjour,
utilisant un programme de domotique j'aimerai envoyer les code rfid de mes cartes via ethernet
je possede une carte rc522 connecte à un arduino mega + w5100.
j'ai utilisé le code suivant pour recuperer le code uid d'une carte
code: [select]

/*
 * dump block 0 of mifare rfid card using rfid-rc522 reader
 * uses mfrc522 - library use arduino rfid module kit 13.56 mhz tags spi w , r cooqrobot.
 -----------------------------------------------------------------------------
 * pin layout should follows:
 * signal     pin              pin               pin
 *            arduino uno      arduino mega      mfrc522 board
 * ------------------------------------------------------------
 * reset      9                5                 rst
 * spi ss     10               53                sda
 * spi mosi   11               52                mosi
 * spi miso   12               51                miso
 * spi sck    13               50                sck
 *
 * hardware required:
 * arduino
 * pcd (proximity coupling device): nxp mfrc522 contactless reader ic
 * picc (proximity integrated circuit card): card or tag using iso 14443a interface, eg mifare or ntag203.
 * reader can found on ebay around 5 dollars. search "mf-rc522" on ebay.com.
 */

#include <spi.h>
#include <mfrc522.h>

#define ss_pin 53    //arduino uno; changed 8 avoid conflict ethernet
#define rst_pin 5
mfrc522 mfrc522(ss_pin, rst_pin);        // create mfrc522 instance.

void setup() {
        serial.begin(9600);        // initialize serial communications pc
       
       
       
        spi.begin();                // init spi bus
        mfrc522.pcd_init();        // init mfrc522 card
        serial.println("print block 0 of mifare picc ");
}

void loop() {
       
        // prepare key - keys set ffffffffffffh @ chip delivery factory.
        mfrc522::mifare_key key;
        (byte = 0; < 6; i++) key.keybyte[i] = 0xff;
       
        // new cards
        if ( ! mfrc522.picc_isnewcardpresent()) {
                return;
        }

        // select 1 of cards
        if ( ! mfrc522.picc_readcardserial())    return;
       
        serial.print("card uid:");    //dump uid
        (byte = 0; < mfrc522.uid.size; i++) {
          serial.print(mfrc522.uid.uidbyte[i] < 0x10 ? " 0" : " ");
          serial.print(mfrc522.uid.uidbyte[i], hex);
        }
        serial.print(" picc type: ");   // dump picc type
        byte picctype = mfrc522.picc_gettype(mfrc522.uid.sak);
        serial.println(mfrc522.picc_gettypename(picctype));
         
        byte buffer[18]; 
        byte block  = 0;
        byte status;
        //serial.println("authenticating using key a...");
        status = mfrc522.pcd_authenticate(mfrc522::picc_cmd_mf_auth_key_a, block, &key, &(mfrc522.uid));
        if (status != mfrc522::status_ok) {
           serial.print("pcd_authenticate() failed: ");
           serial.println(mfrc522.getstatuscodename(status));
           return;
        }
       
        // read block
 byte bytecount = sizeof(buffer);
 status = mfrc522.mifare_read(block, buffer, &bytecount);
 if (status != mfrc522::status_ok) {
    serial.print("mifare_read() failed: ");
    serial.println(mfrc522.getstatuscodename(status));
 }
        else  // dump data
 for (byte index = 0; index < 16; index++) {
    serial.print(buffer[index] < 0x10 ? " 0" : " ");
    serial.print(buffer[index], hex);
    if ((index % 4) == 3) serial.print(" ");
 }
        serial.println(" ");
        mfrc522.picc_halta(); // halt picc
        mfrc522.pcd_stopcrypto1();  // stop encryption on pcd
       
}


je suppose que ce sont les lignes qui suivent : serial.print("card uid:");
qui extraient l'uid de chaque carte
mais comment déclarer la suite pour pouvoir l'envoyer via ethernet avec un code sendget
merci
mickael



Arduino Forum > International > Français (Moderators: jfs, Snootlab) > déclaration rfid


arduino

Comments

Popular posts from this blog

arduino bug sur secteur, batterie, mais pas en usb?

Static ip - Raspberry Pi Forums

What voltage is sent to the arduino GND when a transistor is used