background image

-9-

v7.0

RFID Tags

4. RFID Tags

Libelium offers Mifare® Classic 1k cards tags and stickers along with the Waspmote RFID/NFC module. More than 3.5 billions of 

this type of cards have been sold around the world up now. 

An RFID card has a thin form factor (81x54x1 mm), like a driving license or identification card, and can be kept in the user’s wallet. 

However, an RFID tag is smaller and thicker (around 20x20x5 mm) but can be kept in the user’s keyring. Last, an RFID sticker has 

an intermediate size (50x50) and it is really thin and flexible. Of course, a sticker can be stuck in any object so it focuses on the 

Internet of Things (IoT) and logistics applications. 

It is important to note that a card always has a longer range than a tag or sticker because the antenna of a card has more surface.

Figure : 

RFID cards

Figure : 

RFID keyrings

Figure : 

RFID sticker

A Mifare® Classic 1k card has 1024 bytes of internal storage capacity, divided into 16 sectors. Each sector is composed of 4 blocks, and 

each block is composed of 16 bytes. That is to say, each card has 64 blocks, from number 0 to 63. Let’s describe the structure of a card: 

1.  In each sector, the last block (blocks number 3, 7, 11..) is called the sector trailer. This block stores the 2 keys or passwords 

and controls the access to the rest of the blocks in the sector (e.g. block number 7 controls block 4, 5 and 6). The first 6 bytes 

(0..5) are the key A, and the last 5 bytes (10..15) are the key B. As we will see, before reading or writing in any block, we must 

first authenticate us to that sector by providing one of the two keys (normally the A key). The bytes number 6, 7 and 8 store 

the control bytes, which control the way the the blocks may be accessed (read/write). Byte number 9 is not defined in all 

sector trailers. 

2.  The very first block (number 0) is called the manufacturer block and has special characteristics. The first 4 bytes (0..3) are the 

unique identification (UID). The UID can be seen as the serial number of the card and identify the card in a unequivocal way 

(read more in the “Security with RFID/NFC at 13.56 MHz” chapter). The next byte (number 4) is the CRC check byte so it can 

be used to check the correct read; it is calculated with the XOR of the 4-byte UID. The rest of the bytes in the block number 

0 (bytes 5..15) are the manufacturer data. This block 0 has read-only access for security reasons. We need to authenticate 

before reading the block number 0 but the UID can be obtained anyway, without the key.

3.  The rest of the blocks (1 and 2; 4, 5 and 6; 8, 9 and 10; etc) are known as data blocks and they are available to read and write 

operations, after the needed authentication process. 

To sum up, the Mifare® 1k cards have a net storage capacity of:

 (16 sectors/card x 3 data blocks/sector X 16 bytes/block) – 16 bytes (first block) = 752 bytes/card

The cards have been tested to conserve data for 10 years and to have a write endurance of 100,000 cycles.

Summary of Contents for Libelium

Page 1: ...RFID NFC 13 56MHz Networking Guide...

Page 2: ...he module off 16 8 4 Initiating the module 16 8 5 Authenticating a sector 17 8 6 Reading a block 17 8 7 Reading a block with authentication 18 8 8 Writing in a block 18 8 9 Writing in a block with aut...

Page 3: ...3 v7 0 10 Certifications 24 11 Code examples and extended information 25 12 API changelog 28 Index...

Page 4: ...tood as a remote storage unit where we can read and write information without contact Most of the RFID tags are passive which implies that the RFID module must create an electromagnetic field in order...

Page 5: ...e RFID NFC applications the most common are access control security events ticketing public transport equipment and personnel tracking logistics real time inventories marketing information kiosks Figu...

Page 6: ...ol these operations Waspmote is connected to the RFID NFC module through its UART interface The ISO IEC 14443 A Mifare standard offers a 3 pass authentication method to enable secure encrypted communi...

Page 7: ...igfox LoRaWAN Bluetooth Pro Bluetooth Low Energy and RFID NFC Besides the following Industrial Protocols modules are available RS 485 Modbus RS 232 Serial Modbus and CAN Bus Some of the possible combi...

Page 8: ...Sensor Boards Agriculture v30 and Agriculture PRO v30 Incompatible with Watermark and solar radiation sensors Events v30 Incompatible with interruption shift register Gases v30 DIGITAL6 is incompatibl...

Page 9: ...and 6 The first 6 bytes 0 5 are the key A and the last 5 bytes 10 15 are the key B As we will see before reading or writing in any block we must first authenticate us to that sector by providing one...

Page 10: ...mains within the field until the whole process is completed Figure Typical RFID NFC operation Some kind of indicator is strongly advised to let the user know that data exchange was successful Waspmote...

Page 11: ...usands of millions that you find another card like yours Q Can I order or select a specific UID for my card A No the cards UIDs are set in a random way Q I do not know remember the key for a certain b...

Page 12: ...n other sectors One example sector 2 personal general info key only known by all the institutions of the city council sector 3 city s transport info key only known by the bus company sector 4 city s l...

Page 13: ...ange bigger amounts of data Libelium s RFID NFC module supports both operations in a native way RFID 13 56 MHz ISO IEC 14443 A Mifare protocols and NFC NFCIP 1 but Libelium has not implemented softwar...

Page 14: ...nction Brief description bool configureSAM void set internal parameters of the PN532 sendTX uint8_t dataTX uint8_t length uint8_t outLength Send data stored in dataTX getACK void Wait for ACK response...

Page 15: ...ne card s block readWithAuth UID key data ad authenticates one card s sector and reads one block write ad data writes one card s block writeWithAuth UID key data ad authenticates one card s sector and...

Page 16: ...EC 14443 A card in the field does the anti collision loop and selects the card to operate This function is enough for those applications which just require to get the UID of cards since most of the IS...

Page 17: ...TQ inits systems and look for cards state RFID13 authenticate UID 2 key authenticates block number 2 all sector 0 actually of the selected card State of the executed function is stored http www libeli...

Page 18: ...unique identification of a card uint8_t key 6 stores the key or password memset key 0xFF 6 the key by default edit if needed state RFID13 init UID aux inits systems and look for cards state RFID13 aut...

Page 19: ...ards state RFID13 authenticate UID 2 key authenticates the block memset aux 0x00 16 stores 0 s in aux 16 bytes writeAndCheckWithAuth UID key aux 2 authenticates block 2 then writes the content of aux...

Page 20: ...6 stores the new key A uint8_t keyB_new 6 stores the new key B uint8_t config_new 4 0xFF 0x07 0x80 0x00 same cfg memset keyA_old 0xFF 6 the key by default edit if needed memset keyA_new 0x88 6 the ne...

Page 21: ...if the read UID is the same than the original card tr will be true http www libelium com development waspmote examples RFID1356 06 single cards counter 8 17 Searching a UID among a group of UIDs This...

Page 22: ...text aux converts from string to a uint8_t pointer http www libelium com development waspmote examples RFID1356 03 bus ticketing 8 19 Converting from a uint8_t pointer to an integer This function conv...

Page 23: ...d 25 ms write 25 ms So a full read or write in a block process init authenticate read or init authenticate write could take around 75 ms However a standard UID read init can take just 25 ms There is a...

Page 24: ...ifications See below the specific list of regulations passed More info at www libelium com products plug sense Besides Meshlium our multiprotocol router for the IoT is also certified with the certific...

Page 25: ...ut WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of...

Page 26: ...ock number 1 and check afterwards state RFID13 writeAndCheck aux 1 if state 0 for int i 0 i sizeof text i clear this variable text i 0 firstDone true check the 16 bytes in block 1 state RFID13 read 1...

Page 27: ...ess happened check the 16 bytes in block 1 state RFID13 read 1 aux if state 0 if the read command was successful we show the data 16 bytes USB print r n Credit after the trip for int i 0 i 16 i if aux...

Page 28: ...28 v7 0 API changelog 12 API changelog Keep track of the software changes on this link www libelium com development waspmote documentation changelog RFID1356...

Reviews: