GithubHelp home page GithubHelp logo

lemoncandy42 / nfc_pn532_spi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carglglz/nfc_pn532_spi

0.0 0.0 0.0 25 KB

Partial Port of Adafruit CircuitPython to Micropython of PN532 NFC/RFID control library (SPI)

License: MIT License

Python 100.00%

nfc_pn532_spi's Introduction

MicroPython - PN532 NFC/RFID DRIVER (SPI)

MicroPython SPI driver for the PN532 NFC/RFID Breakout and PN532 NFC/RFID Shield (port from CircuitPython driver )

Example:

import NFC_PN532 as nfc
from machine import Pin, SPI

# SPI
spi_dev = SPI(1, baudrate=1000000)
cs = Pin(5, Pin.OUT)
cs.on()

# SENSOR INIT
pn532 = nfc.PN532(spi_dev,cs)
ic, ver, rev, support = pn532.get_firmware_version()
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))

# Configure PN532 to communicate with MiFare cards
pn532.SAM_configuration()

# FUNCTION TO READ 
def read_nfc(dev, tmot):
    """Accepts a device and a timeout in millisecs """
    print('Reading...')
    uid = dev.read_passive_target(timeout=tmot)
    if uid is None:
        print('CARD NOT FOUND')
    else:
        numbers = [i for i in uid]
        string_ID = '{}-{}-{}-{}'.format(*numbers)
        print('Found card with UID:', [hex(i) for i in uid])
        print('Number_id: {}'.format(string_ID))


read_nfc(pn532, 500)
Reading...
Found card with UID: ['0x0', '0xa', '0x33', '0xc0']
Number_id: 0-10-51-192

Datasheet:

PN532

User Manual:

PN532 User Manual

nfc_pn532_spi's People

Contributors

carglglz avatar dracode avatar

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.