GithubHelp home page GithubHelp logo

pn532-lib's Introduction

pn532-lib

PN532 NFC Library for Raspberry Pi, STM32, Arduino

image

How to use?

For Raspberry Pi

Using SPI

  1. Set I0I1:
  • I0 --> LOW
  • I1 --> HIGH
  1. Hardware Connection:
  • SCK --> SCK
  • MISO --> MISO
  • MOSI/SDA/TX --> MOSI
  • NSS/SCL/RX --> D4 (GPIO 4 of BCM pinout) Optional:
  • RSTPDN --> D20 (for hardware reset)
  1. Modify the PN532 Init lines for SPI in example/raspberrypi/rpi_get_uid.c:
PN532_SPI_Init(&pn532);
//PN532_I2C_Init(&pn532);
//PN532_UART_Init(&pn532);
  1. Compile with make:
cd examples/raspberrypi && make
  1. Run the demo with:
./rpi_get_uid.exe

Using I2C

  1. Set I0I1:
  • I0 --> HIGH
  • I1 --> LOW
  1. Hardware Connection:
  • MOSI/SDA/TX --> SDA
  • NSS/SCL/RX --> SCL Optional:
  • P32 --> D16 (for hardware request)
  • RSTPDN --> D20 (for hardware reset)
  1. Modify the PN532 Init lines for I2C in example/raspberrypi/rpi_get_uid.c:
//PN532_SPI_Init(&pn532);
PN532_I2C_Init(&pn532);
//PN532_UART_Init(&pn532);
  1. Compile with make:
cd examples/raspberrypi && make
  1. Run the demo with:
./rpi_get_uid.exe

Using UART

  1. Set I0I1:
  • I0 --> LOW
  • I1 --> LOW
  1. Hardware Connection:
  • MOSI/SDA/TX --> RX
  • NSS/SCL/RX --> TX Optional:
  • RSTPDN --> D20 (for hardware reset)
  1. Modify the PN532 Init lines for UART in example/raspberrypi/rpi_get_uid.c:
//PN532_SPI_Init(&pn532);
//PN532_I2C_Init(&pn532);
PN532_UART_Init(&pn532);
  1. Compile with make:
cd examples/raspberrypi && make
  1. Run the demo with:
./rpi_get_uid.exe

For Arduino UNO

Please first copy the files pn532.c, pn532.h, pn532_uno.cpp and pn532_uno.h to the libraries directory, which can be set up by Arduino IDE --> preference.

Then you should also connect the serial port from your UNO to a PC for Serial Monitor.

  • Baudrate: 115200.

Using SPI

  1. Set I0I1:
  • I0 --> LOW
  • I1 --> HIGH
  1. Hardware Connection:
  • SCK --> Arduino D13
  • MISO --> ArduinoD12
  • MOSI --> Arduino D11
  • NSS --> Arduino D4
  1. Open examples\arduino\uno_get_uid\ uno_get_uid.ino with Arduino IDE then change the PN532 Init lines for SPI:
PN532_SPI_Init(&pn532);
//PN532_I2C_Init(&pn532);
  1. Compile and upload the demo to your Arduino UNO board:
examples\arduino\uno_get_uid\ uno_get_uid.ino

Using I2C

  1. Set I0I1:
  • I0 --> HIGH
  • I1 --> LOW
  1. Hardware Connection:
  • SCL --> ArduinoA5
  • SDA --> ArduinoA4
  1. Open examples\arduino\uno_get_uid\uno_get_uid.ino with Arduino IDE then change the PN532 Init lines for I2C:
//PN532_SPI_Init(&pn532);
PN532_I2C_Init(&pn532);
  1. Compile and upload the demo to your Arduino UNO board:
examples\arduino\uno_get_uid\uno_get_uid.ino

For STM32

The demos are build on STM32F103CBT6, but you can port them with STM32CubeMX.

  1. Set I0I1:
  • I0 --> LOW
  • I1 --> HIGH
  1. Hardware connection:
  • SCK --> PA5
  • MISO --> PA6
  • MOSI --> PA7
  • NSS --> PA4
  • PA9 --> RX
  • PA10 --> TX
  1. Extract: pn532-lib\examples\stm32\stm32.7z
  2. Open the project MDK-ARM\pn532_stm32.uvprojx with Keil V5
  3. Build and download the project to your STM32 board.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.