Raspberry Pi and NFC ACR122u – English version

Hello everybody!

In this post I’ll show you, how to do a presence control using the ACR122u reader and the Raspberry Pi B+ 2, programing with javascript, Nodejs soquet.io and MYSQL.


Imagem de Amostra do You Tube








After Terminal opening, the first step is check if all thing are updated on our Raspberry

~$ sudo apt-get update

~$ sudo apt-get upgrade

Installing Node.js via package manager:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

For more information on how to install Node.js visit the official site nodejs.org.

to check that everything was installed correctly enter the code below:

~$ node -v

v0 . 12 . 9 

~$ npm -v

2 . 14 . 9

You’ll have something like this.

First you need install libudev-dev:

sudo apt-get install libudev-dev

Then you need to install libusb, this should do the trick:

sudo apt-get install libusb-dev

apt-get install libpcsclite1 libpcsclite-dev
npm install pcsclite
apt-get install pcscd

Now we need to install NFC Tools:

wget https://bintray.com/artifact/download/nfc-tools/sources/libnfc-1.7.1.tar.bz2

tar xjf libnfc-1.7.1.tar.bz2

cd libnfc-1.7.1

./configure –prefix=/usr –sysconfdir=/etc


./configure –with-drivers=all –prefix=/usr –sysconfdir=/etc


sudo make install

sudo apt-get install libtool

sudo apt-get install libsystemd-dev

sudo apt-get install libpcsclite1

sudo apt-get install flex

git clone git://anonscm.debian.org/pcsclite/PCSC.git

Now will install the dependencias of ACR122u reader:

— Install the ACS Driver —
make a dowload on oficial web site of ACR122u here.

unzip the file

~$ cd acsccid-x.y.z // to access the folder

~$  ./configure

~$ make

~$ make install

The installation can spend some minutes

Now you need to configure the file libccid_info.plist on cd /etc directory

~$ cd

~$ cd /etc

~$ sudo nano libccid_info.plist

Change the following line in the file:




Ctrl + x and press y to save!

~$ cd // to return on root folder (/home/pi..)

To verify that everything worked out so far, write:

~$ sudo nfc-list // comment: see result below

nfc-list uses libnfc 1.7.1
NFC device: ACS / ACR122U PICC Interface opened

~$ sudo nfc-scan-device -v // comment: see result below

nfc-scan-device uses libnfc 1.7.1
1 NFC device(s) found:
– ACS / ACR122U PICC Interface:
chip: PN532 v1.6
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)

I believe that everything must have worked here! In case of problems leave a comment we will solve the problem.

Acabamos a primeira fase do nosso projeto onde temos:

  • The Raspberry with the OS installed and running;
  • The ACR122u reader configured and running.

Now create a folder by typing:

~$ cd // to ensure that the root folder

~$ mkdir rfid // to create the folder

~$ cd rfid // to enter the folder

Let’s start by installing the dependencies to our project …

~$ npm install express

~$ npm install pcsclite

~$ npm install socket.io

~$ npm install mysql

  • Ready believe we installed all dependencies, but if they encounter problems tell me to review the post.

Continuing with our project created in mysql database databesname the tables using the settings below:

`evento` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`qty` int(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

 `nome` varchar(100) DEFAULT NULL,
 `foto` varchar(100) DEFAULT NULL,
 `rfid` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
 `dept` varchar(20) NOT NULL,
 `turno` varchar(10) NOT NULL,
 `divi` varchar(1) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
 `Qty` int(1) NOT NULL DEFAULT '1',
 `fone` varchar(30) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
 `email` varchar(50) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `coutbyid` AS select `ck`.`evento` AS `evento`,count(`ck`.`qty`) AS `count(``qty``)` from `ck` group by `ck`.`evento`;
 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `grupo` AS select `event`.`rfid` AS `rfid`,`event`.`foto` AS `foto`,`event`.`nome` AS `nome`,`event`.`turno` AS `turno`,`event`.`divi` AS `divi`,`event`.`dept` AS `dept`,`coutbyid`.`count(``qty``)` AS `count(``qty``)` from (`event` join `coutbyid` on((`event`.`rfid` = `coutbyid`.`evento`))) order by `event`.`nome`; 

Clone the files on GitHub:

sudo apt-get clone https://github.com/PabloBInotto/A-PRESENCE-CONTROL.git


sudo npm install

Let’s test it all worked out:

1º open the terminal in raspberry;

2º  Start new.js middleware that will be responsible for reading and writing of RFID tags in the code mysql:

~$ cd rfid

~$ node new

3º In another terminal to start the HTTP server of the node:

~$ cd rfid

~$ node sv-http

4º Open your browser and access the html we created last, the page that will display that is present or absent. In vavegador Type in: http://localhost:8000


If all right gave up page will be displayed!!


Place raspberry in Kiosk mode and automatically start the sv-http server and has open the page to display our presence control:

First we have to install the chromium

~$ sudo apt-get install chromium x11-xserver-utils unclutter

Now let’s edit the file auto start

~$ sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

The file should look like the following lines:

@xscreensaver -no-splash

@xset s off
@xset -dpms
@xset s noblank

@lxterminal –command “node /home/pi/rfid/sv-http.js”

@sed -i ‘s/”exited_cleanly”: false/”exited_cleanly”: true/’ ~/.config/chromium/Default/Preferences
@chromium –noerrdialogs –kiosk http://www.page-to.display

Ctrl + C  – y  – enter

Now let’s make the raspberry connect without using keyboard and mouse

~$ sudo nano /etc/rc.local

su -l pi -c startx // deu certo

Add line before exit 0

Ctrl + C  – y  – enter

Let’s stop here.

  • The post goes on to the next update we will make a page for more dynamic record, without having to enter the rfid each new account. The way that this is not good.

I hope you enjoyed and that everything has worked out so far. Any problems leave a comment that soon I will answer!

Should they improve what was done let me know !!

Big hug to all 🙂

44 comentários em “Raspberry Pi and NFC ACR122u – English version”

  1. Hi!

    After doing all the steps and writing “dust Nfc-scan-device -v” everything seemed to work fine because I get the same result as you do and the terminal says that there is one device found, etc.

    The problem is that although the raspberry recognizes the device the led light doesn’t turn on and the NFC reader doesn’t start reading the tags.

    Do you know why is this happening ?

    1. Hello Guilbermo!
      Do You are using the nodejs to read the tag?

      For example:

      The nodejs I start nfc reader in this part of code bellow.

      reader.on(‘error’, function(err) {
      console.log(‘Error(‘, reader.name, ‘):’, err.message);

      You can see the full code at github


  2. Thanks on your marvelous posting! I quite enjoyed
    reading it, you’re a great author.I will remember to bookmark your blog
    and will often come back someday. I want to encourage one to continue your great writing,
    have a nice afternoon!

  3. Freeⅼancing can alѕo rеsult in ɑ giant “plus” relating to your
    income. As a sսbstitute of having to settle for thee precise
    wage that is prοvided by the one legislaation agency tһatt уou just work,
    you have goot quitе a lot of leeway in setting your personal pay rates.
    This issue ccan resault inn significantly more money for you.

  4. Heya are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started
    and create my own. Do you need any html coding knowledge to make your own blog?

    Any help would be greatly appreciated!

  5. А motivating discussion іs worth comment.
    I do believe tһat you should publish more аbout this subject mattеr,
    it might not bе a taboo matter but typically people ɗon’t talk about such subjectѕ.
    To the next! All tһe best!!

  6. Hi there! This blog post could not be written much better!
    Reading through this article reminds me of my previous roommate!
    He constantly kept talking about this. I am going to send
    this information to him. Fairly certain he will have a great read.
    Many thanks for sharing!

  7. what are the following lines? i have raspberry pi3 and don’t have libccid_info.plist, thanks
    works correcty but sometimes dont’ read the card

    ~$ sudo nano libccid_info.plist

    Change the following line in the file:




    1. Please install dependencies first:

      sudo apt-get install libpcsclite1
      sudo apt-get install libpcsclite-dev
      sudo apt-get install pcscd
      sudo apt-get install pcsctools
      sudo apt-get install libusb-0.1-4
      sudo apt-get install libusb-dev
      sudo apt-get install libusb-1.0.0-dev

      install –> https://pcsclite.alioth.debian.org/ccid.html
      Note: Follow the instalation guide

      after this steps I believe you will find the libccid_info.plist file into /etc directory at the line 54 of file you will see ifDriverOptions

      I hope be help you!

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *