{"id":1841,"date":"2015-11-23T00:01:26","date_gmt":"2015-11-22T22:01:26","guid":{"rendered":"http:\/\/saisa.eu\/blogs\/Guidance\/?p=1841"},"modified":"2015-11-24T15:13:13","modified_gmt":"2015-11-24T13:13:13","slug":"raspberry-and-rfid-readerwriter-first-test","status":"publish","type":"post","link":"https:\/\/saisa.eu\/blogs\/Guidance\/?p=1841","title":{"rendered":"Raspberry and RFID reader\/writer, first test"},"content":{"rendered":"<p>An RFID <a href=\"http:\/\/rfid-handbook.de\/about-rfid.html\">system<\/a> is always made up of two components:<\/p>\n<ul>\n<li>\n<div>the transponder, Proximity Integrated Circuit Card (PICC)<\/div>\n<\/li>\n<li>\n<div>the detector or reader , Proximity Coupling Device (PCD)<\/div>\n<\/li>\n<\/ul>\n<p><a href=\"http:\/\/rfid-handbook.de\/about-rfid.html\"><img loading=\"lazy\" alt=\"rfid-basic-scheme\" src=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/rfid-basic-scheme1.png\" width=\"600\" height=\"251\" \/><\/a><\/p>\n<p>The RFID reader\/writer (13.56MHz) <a href=\"http:\/\/www.nxp.com\/documents\/data_sheet\/MFRC522.pdf\">RF522<\/a> for arduino can be used in Raspberry. In this first test, the steps described <a href=\"http:\/\/raspmer.blogspot.fi\/2015\/07\/how-to-use-rfid-rc522-on-raspbian.html\">here<\/a> and <a href=\"https:\/\/github.com\/ondryaso\/pi-rc522\">here<\/a> were followed. They both are using the python source <a href=\"https:\/\/github.com\/mxgxw\/MFRC522-python\">code<\/a>. Please see these references for the correct connections between raspberry and the RC522 (see picture below).<\/p>\n<p><img loading=\"lazy\" alt=\"raspberry-RC522\" src=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/raspberry-rc5221.png\" width=\"584\" height=\"438\" \/><\/p>\n<p>The reader can read MIFARE cards. The <a href=\"http:\/\/www.nxp.com\/documents\/data_sheet\/M001053_MF1ICS50_rev5_3.pdf\">block diagram<\/a> is shown below. The data in the EEPROM can be &#8220;read &amp; write&#8221; with this RC522.<\/p>\n<p><img loading=\"lazy\" alt=\"RFID-mirafecard\" src=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/rfid-mirafecard1.png\" width=\"600\" height=\"294\" \/><\/p>\n<p>The 1024 x 8 bit EEPROM memory is organized in 16 sectors with 4 blocks of 16 bytes each.<\/p>\n<p><img loading=\"lazy\" alt=\"RFID-mirafecard2\" src=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/rfid-mirafecard21.png\" width=\"600\" height=\"483\" \/><\/p>\n<p>In the test, the <a href=\"https:\/\/github.com\/mxgxw\/MFRC522-python\">source code<\/a> worked out from the box without any changes..<br \/>\nA small modifications were made on the code to change the printout.<\/p>\n<p>Reading a card:<\/p>\n<div style=\"WIDTH: 650px; HEIGHT: 300px; OVERFLOW: auto\">\n<pre>\npi@raspberrypi ~\/SPI-Py\/MFRC522-python $ sudo python Read2.py\n\/home\/pi\/SPI-Py\/MFRC522-python\/MFRC522.py:113: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.\n  GPIO.setup(22, GPIO.OUT)\nWelcome to the MFRC522 data read example\nPress Ctrl-C to stop.\nCard detected\nCard read UID: 77,84,46,59\nSize: 8\nSector 0 [77, 84, 46, 59, 12, 8, 4, 0, 98, 99, 100, 101, 102, 103, 104, 105]\nSector 1 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nSector 3 [0, 0, 0, 0, 0, 0, 255, 7, 128, 105, 255, 255, 255, 255, 255, 255]\n<\/pre>\n<\/div>\n<p>Dumping the content of 1K card:<\/p>\n<div style=\"WIDTH: 650px; HEIGHT: 600px; OVERFLOW: auto\">\n<pre>\npi@raspberrypi ~\/SPI-Py\/MFRC522-python $ sudo python Dump2.py\n\/home\/pi\/SPI-Py\/MFRC522-python\/MFRC522.py:113: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.\n  GPIO.setup(22, GPIO.OUT)\nCard detected\nCard read UID(integer values): 77,84,46,59\nSize: 8\n Sector 0 Block 0  4d 54 2e 3b 0c 08 04 00 62 63 64 65 66 67 68 69\n Sector 0 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 0 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 0 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 1 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 1 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 1 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 1 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 2 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 2 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 2 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 2 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 3 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 3 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 3 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 3 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 4 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 4 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 4 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 4 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 5 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 5 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 5 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 5 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 6 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 6 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 6 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 6 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 7 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 7 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 7 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 7 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 8 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 8 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 8 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 8 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n Sector 9 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 9 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 9 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n Sector 9 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 10 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 10 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 10 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 10 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 11 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 11 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 11 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 11 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 12 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 12 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 12 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 12 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 13 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 13 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 13 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 13 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 14 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 14 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 14 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 14 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\nSector 15 Block 0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 15 Block 1  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 15 Block 2  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nSector 15 Block 3  00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff\nTrailer            !------keyA-----! !-access--! !-----keyB------!\n<\/pre>\n<\/div>\n<p>Modified\/New sources. Just add\/overwrite these in the same directory.<\/p>\n<ul>\n<li><a href=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/read2.py_.txt\">Read2.py<\/a>\n<ul>\n<li>tries to read blocks 0, 1 and 3 from sector 0 (printout says sectors 0, 1 and 3)<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/dump2.py_.txt\">Dump2.py<\/a>\n<ul>\n<li>the printout is formatted to show better the sectors and blocks, requires new MFRC522.py (see below)<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"http:\/\/saisa.eu\/blogs\/Guidance\/wp-content\/uploads\/2015\/11\/mfrc522.py_.txt\">MFRC522.py<\/a>\n<ul>\n<li>the additional parts required by Dump2.py are added at the end of the file<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Links<\/strong><\/p>\n<p>It is difficult to find good RFID overview articles or presentations. Good starting point is the excellent book <a href=\"RFID Handbook: Fundamentals and Applications in Contactless Smart Cards, Radio Frequency Identification and Near-Field Communication, 3rd Edition\">RFID Handbook, 3rd Ed<\/a>.<\/p>\n<ul>\n<li>\n<div><a href=\"http:\/\/www.engineersgarage.com\/rfid-radio-frequency-identification-and-detection\">RFID | Radio Frequency Identification and Detection<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"https:\/\/en.wikipedia.org\/wiki\/ISO\/IEC_14443\">https:\/\/en.wikipedia.org\/wiki\/ISO\/IEC_14443<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"https:\/\/en.wikipedia.org\/wiki\/Near_field_communication\">https:\/\/en.wikipedia.org\/wiki\/Near_field_communication<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"https:\/\/www.cs.cmu.edu\/~15-821\/CDROM\/PAPERS\/want2006.pdf\">An Introduction to RFID Technology<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/rfid.ctu.edu.tw\/8_lab\/rfid_reference\/1\/rfidprimer.pdf\">Radio Frequency Identification RFID A basic primer<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/cdn.mobiusconsulting.com\/papers\/HFE0805_RFIDTutorial.pdf\">A Radio-Oriented Introduction to RFID\u2014Protocols, Tags and Applications<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/www.rfidjournal.com\/get-started\">Get Started<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/www.rfidjournalevents.com\/map.php\">RFID Deployments Worldwide<\/a><\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/www.rfidjournal.com\/free-case-studies\">Case Studies<\/a><\/div>\n<\/li>\n<\/ul>\n<p><strong>Security related aspects<\/strong><\/p>\n<p>Hacking community has been active on RFID for some years.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.defcon.org\/images\/defcon-21\/dc-21-presentations\/Brown\/DEFCON-21-Brown-RFID-Hacking-Updated.pdf\">RFID Hacking, Live Free or RFID Hard<\/a><\/li>\n<li><a href=\"https:\/\/www.blackhat.com\/docs\/sp-14\/materials\/arsenal\/sp-14-Almeida-Hacking-MIFARE-Classic-Cards-Slides.pdf\">Hacking Mifare Classic Cards<\/a><\/li>\n<li><a href=\"http:\/\/arstechnica.com\/security\/2015\/08\/researchers-reveal-electronic-car-lock-hack-after-2-year-injunction-by-volkswagen\/\">Researchers reveal electronic car lock hack after 2-year injunction by Volkswagen<\/a><\/li>\n<li><a href=\"http:\/\/krebsonsecurity.com\/2014\/08\/how-secure-is-your-security-badge\/\">How Secure is Your Security Badge?<\/a><\/li>\n<li><a href=\"http:\/\/www.gravoc.com\/wp-content\/uploads\/2015\/05\/GraVoc_RFID_GNECUS-Presentation_April-2015.pdf\">RFID Hacking: Reconsidering Physical Security<\/a><\/li>\n<li><a href=\"http:\/\/www.rsaconference.com\/writable\/presentations\/file_upload\/br-r04a-fun-with-proxmark3.pdf\">Fun with Proxmark3<\/a><\/li>\n<\/ul>\n<p>There are some ways to protect your RFID cards.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.instructables.com\/id\/RFID-Secure-Wallet\/?ALLSTEPS\">RFID Secure Wallet<\/a><\/li>\n<li><a href=\"http:\/\/www.instructables.com\/id\/RFID-Reader-Detector-Easy-to-Build\/?ALLSTEPS\">RFID Detector<\/a> (125 KHz)<\/li>\n<li><a href=\"http:\/\/www.instructables.com\/id\/RFID-Reader-Detector-and-Tilt-Sensitive-RFID-Tag\/?ALLSTEPS\">RFID Reader Detector and Tilt-Sensitive RFID Tag<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>An RFID system is always made up of two components: the transponder, Proximity Integrated Circuit Card (PICC) the detector or reader , Proximity Coupling Device (PCD) The RFID reader\/writer (13.56MHz) RF522 for arduino can be used in Raspberry. In this &hellip; <a href=\"https:\/\/saisa.eu\/blogs\/Guidance\/?p=1841\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[68,74,67,34,80,82,66,51],"tags":[],"_links":{"self":[{"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/posts\/1841"}],"collection":[{"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1841"}],"version-history":[{"count":3,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/posts\/1841\/revisions"}],"predecessor-version":[{"id":1844,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=\/wp\/v2\/posts\/1841\/revisions\/1844"}],"wp:attachment":[{"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saisa.eu\/blogs\/Guidance\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}