Using SL030 RFID Module with Raspberry Pi


This project uses the SL030 RFID module with the Raspberry Pi. This will allow the Pi to read the 13.56MHz Mifare RFID cards.

The SL030 modules uses the I2C interface at 3.3v.

Parts List

Hardware Setup

The SL030 has a 6 pin header, this would need to connect to the Raspberry Pi as shown below.

A ready made cable is also available to purchase.

UPDATE : 27-08-14

A new software driver and demo is now available from please use this instead.

Software Setup

Install the i2c driver.

Install the Quick2Wire Python library.

Change to the directory where the Quick2wireWire is installed. In our case (your setup might be different):

cd git/quick2wire-python-api/ 

Download the example python script (thanks to @whaleygeek by:


Change the file permission to allow execute:

chmod +x

Start the Python script:

sudo ./

Swipe a RFID card or tag onto the reader and you should get some similar to this screen.

Short URL:

Tags: , , ,

67 Responses to Using SL030 RFID Module with Raspberry Pi

  1. Perry Ismangil on 28/06/2013 at 12:04

    What is the difference between SL030 and SL031?

    • admin on 28/06/2013 at 12:16

      The SL030 has an I2C interface where the SL031 has an UART interface. Both operate at 3.3v

  2. Peter on 11/08/2013 at 23:17

    What is the typical reading distance in cm?
    Meaning how close has the RFID Tag to be to get recognized?

    • admin on 11/08/2013 at 23:32

      It needs to be 2.5cm or closer.

  3. Ahmed on 03/12/2013 at 16:33

    Does the SL030 cable need to be soldered to the SL030 RFID Module?

    • admin on 03/12/2013 at 21:30

      The ready cable comes with a 6way header. You would need to solder the header to the module then you can plug the cable in.

  4. jim humphries on 04/12/2013 at 14:50

    I am writing firmware to link to the SL030 via I2C from an ARM7 processor. To test if the comms is correct I am writing the simple command to go to power down mode. How do I know if it has been understood by the SL030? Does the red LED that shows card auto-detected switch off when it powers down or does that continue to work?

    • admin on 04/12/2013 at 16:08

      The SL030 does not acknowledge the power down command. During your test you can measure the current consumption, it should be about 10uA.

  5. Ahmed on 06/12/2013 at 17:40

    I followed your instructions on installing i2c driver which was very detailed and done that successfully. But i’m completely lost with the link to the Quick2Wire Python installation guide. I followed the Dependencies installation part and installed the two optional pip and virtualenv. After that point i’m completely lost and do not understand what the guide is talking about. Is there a better installation guide for this QuickWire? something like the guide for your i2c installation?

    • Ahmed on 06/12/2013 at 22:48

      Nevermind figured it out. Just typed git clone and that downloaded the quick2wire library.

      Is there any sample scripts to encode and write data to a blank rfid card? also, when the file runs it initializes the rfid unit and then shows the version of the hardware. At this point while the script is listening for card scans is it possible to have the rasberry pi power an led ?

      • Ahmed on 09/12/2013 at 12:24

        Nevermind about this either. I have managed to wire up LED to an unused GPIO pin and turn it on when the python script is ready.

  6. Ahmed on 07/12/2013 at 11:11

    The sample script, when it listens for card scans, if i was to leave it running for a long time will it time-out and stop listening or is the script running all the time?

    • David Whale on 19/02/2014 at 14:37

      Hi Ahmed,

      The busy-wait loop for a tag read is inside this function in

      def wait_tag(self):
      while not self.tag_present():

      Instead of calling wait_tag() in your application, you could call tag_present() and if it is not present, run other code, and only if it is present, read the tag data and process it. This would allow you to do multiple things (cooperatively) without any significant changes to the python driver.

      Alternatively you could run the rfid code inside a Thread and get it to “call out” to a “tag_detected” callback when a tag is detected. This scheme is a bit more complex to do but does lead to a simpler and more flexible application architecture. To see how to do this, look at my module that I wrote to allow children to write network aware apps, which inside uses a thread that calls back to a user defined handler function when new data arrives from the network. This makes it easier to do two things (wait for input from the keyboard and send to the network, at the same time as processing any incoming data from the network and print it).

      In the networking example, the thread and the callback is a vital piece of application architecture, because input() or raw_input() in python is blocking – once you call it, it will not return until the user presses ENTER on the keyboard, and in a single threaded design you would never see incoming data until the user returned from the input() function.

      David Whale

  7. Ahmed on 09/12/2013 at 12:25

    Is there any sample python script to encode or write data to blank mifare cards? The sample script seems to only read data.

    • David Whale on 19/02/2014 at 14:44

      Hi Ahmed,

      The sample code was only designed to prove that the Mifare reader worked, and to give users a simple starting point on which to build their own code. If there is enough demand for it, I might consider writing a more complete python library that accesses all of the facilities of the MIFARE reader such as writing to card locations.

      If you wanted to do this yourself, you can follow my lead from the starter code, by looking at how I have implemented the tag_present() and select_mifare() functions, and compare these to the message definitions in the reader datasheet provided on Mr Pang’s website alongside this article. You could then write additional transaction handler functions that access the other features of the reader yourself.

      I would start with a working example like select_mifare(), copy and rename the function, and modify it to change the command bytes and message format as documented in the chip data sheet and get it working that way.

      If you have a commercial (non hobbyist) reason to be able to access the other features of the card reader and don’t feel confident at writing the rest of the drivers yourself, please consult with Mr Pang and we may be able to find a simple way for you to fund the development of new features to a more suitable timescale for you.

      David Whale

  8. Aristide on 27/02/2014 at 15:02

    How can I authenticate a card using the usual challenge/response procedure for MiFare card ? Is there a simple command to do it ?


  9. aliah makhali on 07/04/2014 at 17:02

    Hye. I just want to develop the project based on mifare and rasbberry pi in security door acces. What exactly the program that i should install?

    • David Whale on 20/07/2014 at 22:47

      Hi Aliah,

      There are a few packages to download, as detailed in the blog. Unfortunately there are two different I2C libraries in use – one has a useful toolset for finding the device (debug tools) in i2ctools, and the actual code library that we used was the “quick2wire” library which comes from a git repository. The standard i2c driver would not work with the SL030 due to the non standard payload format that it uses (length byte at the start).

      However, I am considering re-writing this example code using a new I2C driver that I have developed, and I hope this to be completed in time for early September 2014. I will get SKPang to post the code in this blog when it is written, and this will be much simpler and the python code should then just work out of the box without any setup or any special installation instructions.

      If you follow the instructions in this blog to the letter, they do indeed work, but I’m afraid there are lots of steps involved in this present scheme.

      David Whale

  10. David Whale on 15/08/2014 at 23:25

    Just a note that I have completely re-written the driver module for the SL030, which will be released on or after 6th September 2014 at the Cambridge Raspberry Jam. This new driver module is zero-install, meaning that you just copy some files onto your Raspberry Pi then run the script and it works. You will be able to get this new driver module from my blog after the 6th Sept 2014 from here:

    A number of people in the community, and a number of schools, commented that they wanted to use this RFID product in their projects but found the setup too complex, which prompted me to think about how to write a driver module that was zero-install. I have this working now, and it is indeed zero-install.

    David Whale

  11. Stephen on 17/08/2014 at 12:20

    Can that read LF RFID cards?

    • admin on 17/08/2014 at 20:17

      No, it does not read LF cards.

  12. Ryuuji on 09/09/2014 at 11:34

    Does SK Pang also ship outside UK? I wanna order one for my project. :(

    • admin on 09/09/2014 at 11:37

      Yes, we can ship outside the UK.

      • Ryuuji on 18/09/2014 at 02:17

        I am still learning programming and things like this but is it possible to remove the

        “card present
        type: mifare 1k,4byte UID

        Like I mean if I make an attendance system, will that appear on the screen too? Is there any way to remove it?

        • David Whale on 12/01/2015 at 20:49

          Yes, just remove the print statements from the demo program, and those messages will disappear.


  13. David Whale on 09/09/2014 at 19:16

    For those of you excited about RFID, SKPang and I demonstrated the RFID reader at the Cambridge Raspberry Jam on 6th September and it created a lot of interest.

    Note that the above links take you to a “zero install” driver for the RFID reader – just download and run the python and it works.

    (I think I still have to add support for model B rev1 as the pins are different) but it worked out of the box on about 8 Pi model B-s I tried it on, on different Raspbian builds.

  14. David Whale on 09/09/2014 at 19:17

    I also heard recently that there are some schools in Essex that have successfully got this working with the lunch tag system that the kids use to pay for their lunch, so every kid in the school already has a tag and they can now do projects with their Raspberry Pi using this scheme. This is really good news, I’m looking forward to hearing about more school projects with this RFID reader on the Raspberry Pi!

  15. Menno on 20/09/2014 at 15:04


    Is it possible to run this Python script in background and launch at startup?

    I tried several things. But I couldn’t get it working.
    It only working when I launch the script from the command line.


    • David Whale on 12/01/2015 at 20:51

      You can edit /etc/rc.local, and add this line to the line just before the exit 0

      sudo python /home/pi/

      David Whale

  16. Tom Hodder on 22/10/2014 at 06:30

    This script works for me, but then after a while I get an error;

    Traceback (most recent call last):
    File “/home/pi/mybot/”, line 486, in
    File “/home/pi/mybot/”, line 350, in example
    fw = rfid.get_firmware()
    File “/home/pi/mybot/”, line 172, in get_firmware
    master.transaction(writing_bytes(ADDRESS, 1, CMD_GET_FIRMWARE))
    File “/usr/local/lib/python3.2/dist-packages/quick2wire_api-”, line 78, in transaction
    ioctl(self.fd, I2C_RDWR, ioctl_arg)
    IOError: [Errno 5] Input/output error

    and restarting the pi solves the problem.

    Any ideas?

  17. John on 09/12/2014 at 15:04

    Hello! How do I do the zero-install code you were talking about? Shall I follow the instructions under the “Software Setup” mentioned above?

    • admin on 09/12/2014 at 15:42
      • John on 11/12/2014 at 12:14

        Uhmm.. Do I have to put the “rfid” folder (in the .zip file you posted) somewhere? Or the Desktop will do? Thanks

        • David Whale on 12/01/2015 at 20:54

          It would be useful to put the zip file inside your /home/pi folder, then unzip it there. Then run the example program as described on my blog, and it should just work.

          David Whale

  18. Wojtek on 10/01/2015 at 17:13

    Hi! I’ve just bought your RFID starter pack, used the instructions from and have such effect after using the tag:

    pi@raspberrypi ~/rfid2 $ sudo python
    Waiting for a card…
    Card present
    ERROR:readMifare:Cannot read, result=129
    Traceback (most recent call last):
    File “”, line 41, in
    if not rfid.readMifare():
    File “/home/pi/rfid2/rfid/”, line 218, in readMifare
    return instance.readMifare()
    File “/home/pi/rfid2/rfid/”, line 157, in readMifare
    error(“readMifare:Cannot read, result=” + str(result))
    File “/home/pi/rfid2/rfid/”, line 39, in error
    raise ValueError(str)
    ValueError: readMifare:Cannot read, result=129

    Could you please help me?

    • David Whale on 12/01/2015 at 21:02

      Error code 129 means that the reader device sent a NAK back when it was being communicated with via the I2C bus.

      Do check that your connector that connects to the pi has not been offset by 1 pin (I often did this by mistake), and that the connector that joins the SL030 reader is the right orientation (again, Ive done this wrong a few times).

      If it still does not work, please could you tell us what card type you are trying to read, and roughly what type and version of OS you are running on your Raspberry Pi.

      I tested this with NOOBS dated June 2014, as downloaded from the raspberry pi foundation.

      Also, you might try just logging in at the command prompt and running it from the command line, even before running startx, to see if that has any bearing on it working.

      David Whale

      • Wojtek on 15/01/2015 at 20:06

        I’ve double checked the cable and it seems all right to me.
        My tag is RFID Tag SLK05 13.56MHz 1k (RFID-SLK05) and it’s readable by my google Nexus7 (detected as MF1S5037)
        My OS is the latest raspbian (debian7.6), tried without X.
        I’m not sure if it matters, but when I put the tag near the reader the error appears immediately and a red led is on all the time until I remove the tag.
        What else can I do to help diagnose it?

      • Scampi on 19/01/2015 at 23:07


        I am getting the exact same error as Wojtek. Here’s what I’ve done so far;

        I initially tried with the Raspian image directly downloaded from the Pi homepage (2014-12-24-wheezy-raspbian). Then I tried Raspian installed via NOOBS (v1_3_11). I’ve run the script in python3 and 2 without first going into startx and after going in, same error 129 posted above each try. I reseated the cable and double checked I had the red wire on P1 at the Raspberry end and the red wire to VCC on the reader end (which I did). The tags I have tried are both MIFARE Classic 1k (ISO 14443-3A) according to my android phone, one was my security card for work and the other a writeable tag I got from amazon. Again same error every time :( Just to confirm I connected up the reader and the cable before powering the Pi on. The Pi is being powered by an iPhone charger and has a USB keyboard and a bluetooth dongle for my mouse connected only (both of which function as expected but just wondering if there is a possible power issue?), video is via HDMI. I also have a official camera module connected via it’s ribbon connector but I have not enabled it in Raspi-config. Any ideas? Could it be a faulty batch of readers or am I just missing something really obvious (that is definitely a distinct possibility!).

        Thanks so much in advance if you can help!


        • Wojtek on 28/01/2015 at 16:45

          any success? Scampi? Robert? David? Anyone? I’m stuck and have no clue what to do next.

          • admin on 29/01/2015 at 08:41

            Please email me a photo of your setup to support @

  19. Robert on 22/01/2015 at 13:53


    I’m a 3rd or 4th person who getting the same error as Wojtek, Scampi.. I have a latest version of Raspbian image downloaded from the Raspberry Pi homepage. Connection (cable) from RFID module to Pi it’s OK. I’ve also change a cable but result is still same, again and again. I have tried Mifare Classic 1k tag (ISO 14443, type A) and another cards.
    Waiting for a card…
    Card present
    ERROR:readMifare:Cannot read, result=129
    Traceback (most recent call last):
    File “”, line 41, in
    if not rfid.readMifare():
    File “/home/pi/rfid/rfid/”, line 218, in readMifare
    return instance.readMifare()
    File “/home/pi/rfid/rfid/”, line 157, in readMifare
    error(“readMifare:Cannot read, result=” + str(result))
    File “/home/pi/rfid/rfid/”, line 39, in error
    raise ValueError(str)
    ValueError: readMifare:Cannot read, result=129

    Do you have any idea what I can do, how I can solve it?


    • admin on 22/01/2015 at 16:27

      Using a multimeter check the voltage on the Vcc pin of the card reader, it should be about 3.3v
      Does the red LED on the reader flash when you hold a tag near it?

      • Robert on 22/01/2015 at 18:15

        voltage on the VCC pin is 3.31V it’s OK. When I hold a tag near to RFID module, red LED is lights up.

        • admin on 22/01/2015 at 19:31

          3.31v is good and red LED lights up means board is reading the card ok.

          With a multimeter check GPIO4 pin 7 on the Pi. It should be about 3.3v and when a tag is present it should go to zero volt.

          Also worth trying is another different power supply for the Pi. Some cheap mobile phone charger are very noisy.

          • Robert on 22/01/2015 at 20:33

            as you wrote – without a tag on the GPIO4 I measured 3.31V and when a tag is present GPIO4 has a 0V. Same result is with different power supply (not a mobile phone charger).

            Why is this controlled?

  20. Stephen on 05/02/2015 at 14:57

    Hello! It seems like this error became viral and I am getting this too:

    ERROR:readMifare:Cannot read, result=129
    Traceback (most recent call last):
    File “”, line 41, in
    if not rfid.readMifare():
    File “/home/pi/rfid/rfid/”, line 218, in readMifare
    return instance.readMifare()
    File “/home/pi/rfid/rfid/”, line 157, in readMifare
    error(“readMifare:Cannot read, result=” + str(result))
    File “/home/pi/rfid/rfid/”, line 39, in error
    raise ValueError(str)
    ValueError: readMifare:Cannot read, result=129

    I’ve bought the rfid reader almost a month from now, making my project (the rfid reader worked btw), then I got sick for a week and when I’m up to it again, I went ahead and went to finish my project (turn numlock and start my program on boot) but when I tested my program, got the error above. result = 129. Can you help, please? Our defense is coming up and this just have to happen to me.. Why?

    • Stephen on 05/02/2015 at 15:36

      Whoops! In my frustration, I took out all the connections (on the Pi side only) and reconnected them again (hard!). If any of you reading this may have the same error that I had, try reconnecting them first and push them securely.

      PS: Before I uprooted the connections, I am 100% the connection is correct. It was maybe just loose connection with one of the pin & connector.

      • admin on 05/02/2015 at 17:40

        Please email me a photo of your setup to support @

        Also the full list error output including the commands you used.

  21. max on 06/02/2015 at 14:44

    is there any way to do this project and project- (MAX31855 Thermocouple Amplifier with Raspberry Pi) using one raspberry pi or is there any possibility to connect both projects by connecting two rasperry pi each other.

    i need to read the RFID tags as well as temperature in a one display

  22. Pat on 11/02/2015 at 10:57

    Is it possible to connect two SL030 RFID Module to one Raspberry Pi?

    • admin on 11/02/2015 at 15:41

      No, you can not use two SL030 on one Raspberry Pi because the module uses I2C bus and all module have the same address and there will be address conflict.

      • David Whale on 24/02/2015 at 10:47

        I think admin meant “no you can’t do it” because the address is the same on both boards and they would conflict.

        However, the newer I2C driver is a software driver, and it would be possible for me to create a version of this that runs on two different sets of GPIO pins (it does not use the I2C peripheral on the Raspberry Pi).

        If you have access to twitter, connect up with me @whaleygeek and we can exchange email addresses, and I can give you access to the source code of the I2C driver so you can have a go at this yourself (as I am a bit busy at the moment and won;t have time to do it, but it is relatively easy to do in the code if you know how to write C code)


  23. Marco on 03/03/2015 at 16:41

    Dear David,

    I get this error Internal error: Oops: 5 [#1] PREEMPT ARM after the command sudo ./
    I have also lost the eth connection with the Pi after that command.

    What can be?

  24. Shona on 08/03/2015 at 15:52

    I also get the same error has seen by others:

    Waiting for a card…
    Card present
    ERROR:readMifare:Cannot read, result=129
    Traceback (most recent call last):
    File “”, line 41, in
    if not rfid.readMifare():
    File “/home/pi/rfid2/rfid/”, line 218, in readMifare
    return instance.readMifare()
    File “/home/pi/rfid2/rfid/”, line 157, in readMifare
    error(“readMifare:Cannot read, result=” + str(result))
    File “/home/pi/rfid2/rfid/”, line 39, in error
    raise ValueError(str)
    ValueError: readMifare:Cannot read, result=129

    I have sent an email with images of my setup to the All voltages are correct and board is seated properly. Has anyone managed to figure out the problem yet?



    • Shona on 08/03/2015 at 19:10

      As an addition to this, I am using a raspberry pi B vers 1. I have setup V1 of the code and that works fine, so suspect V2 needs amending to work with these models



  25. Tomas Uselis on 12/03/2015 at 05:00

    To all those getting 129, I solved this on one of my pi’s by copying the i2c folder to the same location as the Only problem I have is on one of my pi’s shows all of the i2c addresses assigned at once. Any ideas on how to solve this? Or is it dead?

  26. Rob on 25/03/2015 at 04:06

    Another note on the 129 response.

    I had the same problem and found it was related to baud rate. I am using the new Raspberry Pi 2 Model B; the instructions for changing the baud rate have changed. Found that in this forum post: (all the way at the bottom).

    Add the following to boot/config.txt and reboot

  27. Aritz on 23/04/2015 at 10:45

    Can we use this program for a PRIMO A rfid reader??

  28. Roark on 14/07/2015 at 09:50

    Hi There,

    Firstly, thank you very much for the code and putting together the tutorial.
    I am using a raspberrypi Model B and python 2, also the updated software.

    I am able to run the script and the output is as follows:

    Waiting for a card…
    Card present
    This is not a mifare card
    Waiting for card to be removed…

    This is printed immediately without any card being placed on the device.

    I have checked the wiring and the red wire is on the P1 header pin on the raspi side and the vcc on the reader side, one thing I noticed is that I have one more wire than you going to the ‘out’ pin on the reader side and the 5th pin below ‘p1′ on the raspi.

    Do you know why this may be?
    Any help would be greatly appreciated.


    • Roark on 21/07/2015 at 12:16

      It turns out the SL030 to Raspberry Pi cables out from the SL030 was going to gnd on the gpio, swopped it to the correct pin and it worked.


    • David Whale on 23/07/2015 at 23:03

      Hi Roark,

      I have now managed to borrow a Raspberry Pi 2, and investigated this further.

      Firstly, if your GPIO version is out of date, GPIO does not work properly on a Pi2.

      Try this:

      sudo python
      import RPi.GPIO as GPIO

      If the version returned is less than 0.5.10, GPIO is broken on the Pi2, see here:

      I have looked at the C code inside RPi.GPIO, and it appears the new device tree abstraction was added on the Pi 2, and extra lines are required in the C to detect and use this new scheme for getting access to the GPIO. The underlying C code in the SL030 I2C driver does not do this.

      So, I now know why it is broken on Pi2 (and updated raspbian’s on other models), I just need to fix it and re-test it.


      • David Whale on 23/07/2015 at 23:23

        So, as a minimum, to get GPIO to work from python I had to do this:

        sudo apt-get update
        sudo apt-get upgrade
        sudo apt-get dist-upgrade
        sudo reboot

        sudo python
        import RPi.GPIO as GPIO
        GPIO.setup(3, GPIO.OUT)
        GPIO.setup(2, GPIO.OUT)

        GPIO.output(2, True)
        GPIO.output(2, False)

        GPIO.output(3, True)
        GPIO,output(3, False)

        If I do this, I can now flash LEDs on those two pins, which I could not do before all the updates and upgrades.

        I will look at the weekend about adding the device tree support to the C code so that the SL030 driver works on the new architecture, and that should then fix the problems on Pi2 and the later raspbian distributions, hopefully.


      • Roark on 28/07/2015 at 06:18

        Hi David,

        Thanks very much,
        It turned out that RPI.GPIO was version 0.5.9, I updated and am now able to use the pins as you are.

        So we are that much closer to having the SL030 work on the PI2!
        Did you manage to have a look at the driver for the SL030?


        • David Whale on 30/07/2015 at 11:20

          Hi Roark,

          I have fixed and tested the driver on a RPi2 today, and it works fine!

          The new code is in attachment [1b] at the end of the RFID blog on my blog website.

          Please do try this and let me know if it works for you, but it works fine here on my RPi2 now.

          Many thanks!


  29. David Whale on 30/07/2015 at 11:29

    Raspberry Pi 2 support for the RFID Driver – now available

    Just to announce that today I have released a modified driver for the SL030 on my blog here: in attachment [1b] the driver is modified to also work with RPi2.

    On the Raspberry Pi 2, due to a different processor architecture, the memory address of the GPIO peripheral registers had to move. This was also supported by the addition of the device tree in /proc/device-tree/soc/ranges – the second long word in this binary file (bytes 4 to 7) provide the real memory address of the base of the peripheral registers. Adding on the GPIO offset of 0×200000 to this then gives the correct address of the GPIO registers.

    On the old RPi V1 there is no device tree, so the code just uses the default for the original BCM2835 processor. On the RPi2, the device tree exists, so the address in this will be used instead. The device tree additions broke everything, but this was necessary in order to support a range of future (differently architected) processors in the future.

    Do make sure that if you are using GPIO on the RPi-2 you update everything first, if you expect to use GPIO from python – the older distributions had versions of RPi.GPIO earlier than 0.5.10, which will not work with a RPi2.

    To update your python packages, kernel and everything else, use this sequence:
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    sudo reboot

    Thanks to Ben Croston (author of RPi.GPIO) for a really clean and neat fix to this.

    Please note that this driver specifically avoids the I2C hardware peripheral code of the Raspberry Pi – meaning that all you should have to do is to run up the python code and it should work – zero configuration. The I2C driver embedded in this package is obviously a lot slower than the hardware peripheral, but in many cases (the RFID reader included) speed is not an issue, and install simplicity is *more* important.

    David Whale

  30. Roark on 30/07/2015 at 15:21

    Hi David

    I have tested the new driver on my Pi2 and I can confirm it works!
    Thanks very much for keeping this project alive and getting the driver to support all pi’s

    Great bit of code and as you say, “zero configuration”

    Great work

Leave a Reply

Your email address will not be published. Required fields are marked *