[chronojump] Added documentation for reading RFID tags from respberry



commit 4ebb029ed5b3755d66406dbbaeb9dd3045f79103
Author: Xavier Padullés <x padulles gmail com>
Date:   Fri Jan 20 20:40:54 2017 +0100

    Added documentation for reading RFID tags from respberry

 rfid/MFRC522-python-Examples |    1 +
 rfid/ReadChronojump.py       |   65 ++++++++++++++++++++++++++++++++++++++++++
 rfid/SPI-Py                  |    1 +
 rfid/howto_MFC522.txt        |   29 ++++++++++++++++++
 rfid/raspberry_wiring.JPG    |  Bin 0 -> 427475 bytes
 rfid/reader_wiring.JPG       |  Bin 0 -> 415955 bytes
 6 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/rfid/MFRC522-python-Examples b/rfid/MFRC522-python-Examples
new file mode 160000
index 0000000..8ddc994
--- /dev/null
+++ b/rfid/MFRC522-python-Examples
@@ -0,0 +1 @@
+Subproject commit 8ddc994007b9d2320b59e33e9e991cc4e0073aa3
diff --git a/rfid/ReadChronojump.py b/rfid/ReadChronojump.py
new file mode 100644
index 0000000..6d111f0
--- /dev/null
+++ b/rfid/ReadChronojump.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+
+import RPi.GPIO as GPIO
+import MFRC522
+import signal
+
+continue_reading = True
+
+# Capture SIGINT for cleanup when the script is aborted
+def end_read(signal,frame):
+    global continue_reading
+    print "Ctrl+C captured, ending read."
+    continue_reading = False
+    GPIO.cleanup()
+
+# Hook the SIGINT
+signal.signal(signal.SIGINT, end_read)
+
+# Create an object of the class MFRC522
+MIFAREReader = MFRC522.MFRC522()
+
+# Welcome message
+print "Welcome to the MFRC522 data read example"
+print "Press Ctrl-C to stop."
+
+# This loop keeps checking for chips. If one is near it will get the UID and authenticate
+while continue_reading:
+    
+    # Scan for cards    
+    (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
+
+    # If a card is found
+    if status == MIFAREReader.MI_OK:
+        print "Card detected"
+    
+    # Get the UID of the card
+    (status,uid) = MIFAREReader.MFRC522_Anticoll()
+
+    # If we have the UID, continue
+    if status == MIFAREReader.MI_OK:
+
+        # Print UID
+        print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3])
+
+       file = open("/tmp/chronojump_rfid.txt", "w")
+       file.write(str(uid[0]) + "," + str(uid[1]) + "," + str(uid[2]) + "," + str(uid[3]))
+       file.close()
+    
+        # This is the default key for authentication
+        key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
+        
+        # Select the scanned tag
+        MIFAREReader.MFRC522_SelectTag(uid)
+
+        # Authenticate
+        status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, 8, key, uid)
+
+        # Check if authenticated
+        if status == MIFAREReader.MI_OK:
+            MIFAREReader.MFRC522_Read(8)
+            MIFAREReader.MFRC522_StopCrypto1()
+        else:
+            print "Authentication error"
+
diff --git a/rfid/SPI-Py b/rfid/SPI-Py
new file mode 160000
index 0000000..b854590
--- /dev/null
+++ b/rfid/SPI-Py
@@ -0,0 +1 @@
+Subproject commit b854590bfa8efe413615f1800ea1388836ab2e0d
diff --git a/rfid/howto_MFC522.txt b/rfid/howto_MFC522.txt
new file mode 100644
index 0000000..7afb9d7
--- /dev/null
+++ b/rfid/howto_MFC522.txt
@@ -0,0 +1,29 @@
+This document describe the process to comunicate the Raspberry Pi with the
+MFC522 RFID reader
+
+RFID    RPI-SPI
+---------------
+RC522---RPI
+SDA-----24
+SCK-----23
+MOSI----19
+MISO----21
+GND-----20
+RST-----22
+3.3V----1
+
+#In raspbian 2016-05-27 you must add a line at /boot/config.txt
+dtoverlay=spi0-hw-cs
+
+#Download and install the SPI-Py libraries to use SPI in Python
+git clone https://github.com/lthiery/SPI-Py
+sudo apt-get install python-dev
+sudo python setup.py install 
+
+#The ReadChronojump.py reads from the RFID reader and writes it in /tmp/chronojump_rfid.txt
+python ReadChronojump.py
+
+#Download the MFRC522-python for the examples using RFID
+git clone https://github.com/mxgxw/MFRC522-python
+cd MFRC522-python
+python Read.py
diff --git a/rfid/raspberry_wiring.JPG b/rfid/raspberry_wiring.JPG
new file mode 100644
index 0000000..f5f1af9
Binary files /dev/null and b/rfid/raspberry_wiring.JPG differ
diff --git a/rfid/reader_wiring.JPG b/rfid/reader_wiring.JPG
new file mode 100644
index 0000000..d09db68
Binary files /dev/null and b/rfid/reader_wiring.JPG differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]