Easy set-up of NFC on Raspberry Pi

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Easy set-up of NFC on Raspberry Pi

Easy set-up of NFC on Raspberry Pi

This document describes step-by-step how to run NFC on Raspberry Pi platform.

Hardware setup:

You need:

   - Raspberry Pi (any model) : https://www.raspberrypi.org/products/:

 pastedImage_9.jpg

 

   - OM5578(PN7150 demokit) in RPi configuration (or OM5577(PN7120 demokit)

pastedImage_1.jpg      pastedImage_11.jpg

 

Then simply assemble boards together, stacking OM5578RPI (or OM5577RPI) to Raspberry Pi expansion connector:

    pastedImage_4.jpg

 

Software setup:

 

Use Raspbian  (https://www.raspberrypi.org/software/operating-systems/) or any other Linux distribution (guidelines to set up Linux environment on raspberry pi: https://www.raspberrypi.org/documentation/installation/installing-images/).

Step by step procedure:

  • Enable i2c support:

       On Raspbian:

  1. Run "sudo raspi-config"

  2. Use the down arrow to select "5 Interfacing Options"

  3. Arrow down to "P5 I2C"

  4. Select "yes" when it asks you to enable I2C

  5. Also select "yes" if it asks about automatically loading the kernel module

  6. Use the right arrow to select the <Finish> button

  7. Select "yes" when it asks to reboot

    pastedImage_34.png

      The system will reboot. when it comes back up, log in and enter the following command "ls /dev/*i2c*".

      The Pi should respond with "/dev/i2c-1" which represents the user-mode I2C interface.

 

  • Install necessary tools:

        On Raspbian execute the command:

   sudo apt-get install autoconf automake libtool git

  • Clone Linux libnfc-nci library repository:

        Execute the command:

   git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git

  • Configure the library:

        Execute the commands:

   cd linux_libnfc-nci

   ./bootstrap

   ./configure --enable-alt

  • Build and install the library:

        Execute the commands:

   make

      sudo make install

   export LD_LIBRARY_PATH=/usr/local/lib

  • Run demo application (built and installed together with the library during previous step):

        To simply display all data collected from remote NFC device (Peer, reader/writer or card), run the demo application in poll mode executing the command:

   nfcDemoApp poll

pastedImage_73.png

        For more details about the demo application modes execute command:

   nfcDemoApp --help

 

One step further:

  • Set environment variable to reference library installation:

        Execute command:

export LD_LIBRARY_PATH=/usr/local/lib

        You may wan't to make this setting permanent by adding it to your .bashrc file for instance :

echo "export LD_LIBRARY_PATH=/usr/local/lib" >> .bashrc

  • Write your own application:

        Several simple examples demonstrating use of the linux_libnfc-nci library for different use cases (Reader, Peer to peer, Host Card Emulation) are given as reference: https://github.com/NXPNFCLinux/linux_libnfc-nci_examples

       - Simply clone the repository

   git clone https://github.com/NXPNFCLinux/linux_libnfc-nci_examples.git

       - Browse to the targeted example:

   cd linux_libnfc-nci_examples/xxx_example

       - Build the example:

   make

       - Run the example

   ./xxx_example

 

Additional information:

  • Another Platform ?

       Using UDOO NEO (with OM5577 or OM5578 in Arduino configuration) ?

          -> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 2, before building the library

       Using BeagleBone Black (with OM5577 or OM5578 in BBB configuration) ?

          -> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 2, before building the library

       Using other Linux platform or others OM5578/OM5577 demokits configuration ?

          -> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 0 and defining I2C_BUS, PIN_INT and PIN_ENABLE flags according to the HW connection, before building the library

Labels (1)
No ratings
Version history
Last update:
‎09-02-2021 12:39 AM
Updated by: