RFID(Radio Frequency Identification) cards are like an electric
key to unlock and lock things by holding unique data. For example,
your credit card is an RFID card if it has the contact-less
payment option.
This can be used, in my case for switching things on and off or
unlocking something. We will be using the RFID-RC522 board for
this project. You can buy it here.
1. Firstly, we need to wire it up to the pi. (Pin numbers):
2. We need to enable the SPI interface for the pi. Do this by running he following command going to interfaces > SPI > enable > finish.
$ - sudo raspi-config
3. Reboot the Pi
$ - sudo reboot
4. Check that the spi_bcm2835 module is loaded. If it is it should appear under this command when we run it.
$ - lsmod | grep spi
5. Next, install python2.7-dev.
$ - sudo apt-get install python2.7-dev
6. Next, download and install SPI-Py using the following commands.
$ - git clone https://github.com/fraser148/SPI-Py.git $ - cd SPI-Py $ - sudo python setup.py install
7. Install MFRC522-python
$ - git clone https://github.com/fraser148/MFRC522-python.git
To read a card there is some example code called "Read.py" in
the MFRC552-python folder. Run this and it will display the data
held on the card.
I adapted this code to turn on and off a camera. Look at
my tutorial to
see how I did it. The code was very difficult to understand at
first but I managed to make it suit my needs.