All Projects → Galarzaa90 → android-things-rc522

Galarzaa90 / android-things-rc522

Licence: MIT license
Android library to communicate with RFID Module RC522

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to android-things-rc522

Fool
Simple Russian voice assistant based on Android Things and Raspberry Pi 3
Stars: ✭ 26 (-40.91%)
Mutual labels:  android-things, rfid, rfid-rc522
WemosD1 HomeMatic RFID
RFID Reader integration for HomeMatic house automation
Stars: ✭ 18 (-59.09%)
Mutual labels:  rfid, rc522
PN532-HSU
PN532 HSU (UART) library for Python
Stars: ✭ 29 (-34.09%)
Mutual labels:  mifare, rfid
TonUINO
Alternative TonUINO Firmware
Stars: ✭ 112 (+154.55%)
Mutual labels:  mifare, rfid
Mifareclassictool
An Android NFC app for reading, writing, analyzing, etc. MIFARE Classic RFID tags.
Stars: ✭ 2,698 (+6031.82%)
Mutual labels:  mifare, rfid
nfc-reader
A simple library that provides to use rfid card readers.
Stars: ✭ 87 (+97.73%)
Mutual labels:  rfid
androidthings-mqtt-alarm-panel
Android Things Alarm Control Panel for Home Assistant
Stars: ✭ 69 (+56.82%)
Mutual labels:  android-things
FRILLER
FRILLER is a 3D printed compact robot that can change the radius of its wheels to overcome obstacles.
Stars: ✭ 15 (-65.91%)
Mutual labels:  android-things
photobooth
Cloud-connected talking photobooth using TensorFlow
Stars: ✭ 40 (-9.09%)
Mutual labels:  android-things
Sonos RFID Controller
RFID controller for the Sonos music player
Stars: ✭ 17 (-61.36%)
Mutual labels:  rfid
rfid-access-control
Multi-level privilege access control system using RFID tags and passwords. Built with arduino based clients and a django server.
Stars: ✭ 12 (-72.73%)
Mutual labels:  rfid-rc522
sportiduino
Electronic timing system for orienteering and similar outdoor sports events on Arduino
Stars: ✭ 56 (+27.27%)
Mutual labels:  rfid
edison-candle
Production sample using Android Things
Stars: ✭ 42 (-4.55%)
Mutual labels:  android-things
sample-lowpan
Discover and connect to Thread mesh networks on Android Things
Stars: ✭ 28 (-36.36%)
Mutual labels:  android-things
ruby-nfc
NFC library for Ruby programming language
Stars: ✭ 31 (-29.55%)
Mutual labels:  mifare
esp-idf-rc522
C library for interfacing ESP32 with MFRC522 RFID card reader, packaged as ESP-IDF component
Stars: ✭ 60 (+36.36%)
Mutual labels:  rfid
sensorhub-cloud-iot
Sensor-based data collection device publishing to Cloud IoT Core
Stars: ✭ 73 (+65.91%)
Mutual labels:  android-things
MFRC522RFIDPyAuthKeyBruteforcer
Just a simple RFID authentication key brute-force program written in python.
Stars: ✭ 20 (-54.55%)
Mutual labels:  rfid-rc522
esp8266-rfid-banco-de-dados
Projeto com objetivo de autenticar/autorizar usuários a partir de Tags RFID utilizando Banco de Dados
Stars: ✭ 85 (+93.18%)
Mutual labels:  rfid
barnowl
Technology-agnostic middleware for RFID, RTLS and M2M, enabling location-aware physical spaces. We believe in an open Internet of Things.
Stars: ✭ 25 (-43.18%)
Mutual labels:  rfid

Android Things RC522

An Android Things libray to control RFID readers based on the RC522 reader.

Based on pi-rc522 by user ondryaso

Bintray license Android Things

Features

  • Detect MIFARE 1k tags (not tested in other tags)
  • Authenticate, read and write to tags
  • Change authentication keys and access bits (must be done manually)
  • Increment, decrement, transfer and restore for value blocks
  • Easier way of changing keys and access bits

Planned features

  • Helper functions
  • Better error handling

Connections

The connections vary based on the board used.

RST pin is configured programatically.

Raspberry Pi 3

rfid-rc522_bb

RC522 Pin RPi Pin name RPi Pin number
SDA GPIO8, CE0 24
SCK GPIO11, SCKL 23
MOSI GPIO10, MOSI 19
MISO GPIO9, MISO 21
GND GND 6, 9, 20, 25
RST Any GPIO pin --
3.3V 3V3V 1, 17

Installing

This library is available at jCenter. To install add this to your module's build.gradle

dependencies {
    compile 'com.galarzaa.android-things:rc522:1.0.0'

Usage

The use of interruptions is not supported yet.

The RC522 must be polled until a card is found, and then perform any operations you want.

Unfortunately, in Android, the UI thread shouldn't be blocked, so the polling has to be done on a separate thread e.g. AsyncTask, Runnable, etc.

To use the libary, a SpiDevice object must be passed in the constructor, along with a Gpio object for the RST pin.

Polling state

import com.galarzaa.androidthings.Rc522;
public class MainActivty extends AppCompatActivity{
    private Rc522 mRc522;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PeripheralManagerService pioService = new PeripheralManagerService();
        try {
            /* Names based on Raspberry Pi 3 */
            SpiDevice spiDevice = pioService.openSpiDevice("SPI0.0");
            Gpio resetPin = pioService.openGpio("BCM25");
            /* Names based on NXP Pico i.MX7D I/O */
            SpiDevice spiDevice = pioService.openSpiDevice("SPI3.0");
            Gpio resetPin = pioService.openGpio("GPIO5_IO00");
            mRc522 = new Rc522(this, spiDevice, resetPin);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    private void readRFid(){
        while(true){
            boolean success = mRc522.request();
            if(!success){
                continue;
            }
            success = mRc522.antiCollisionDetect();
            if(!success){
                continue;
            }
            byte[] uid = mRc522.getUid();
            mRc522.selectTag(uid);
            break;
        }
        // Factory Key A:
        byte[] key = {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
        // Data that will be written
        byte[] newData = {0x0F,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00};
        // Get the address of the desired block
        byte block = Rc522.getBlockAddress(3, 2);
        //We need to authenticate the card, each sector can have a different key
        boolean result = rc522.authenticateCard(Rc522.AUTH_A, block, key);
        if (!result) {
            //Authentication failed
            return;
        }
        result = rc522.writeBlock(block, newData);
        if(!result){
            //Could not write, key might have permission to read but not write
            return;
        }
        //Buffer to hold read data
        byte[] buffer = new byte[16];
        //Since we're still using the same block, we don't need to authenticate again
        result = rc522.readBlock(block, buffer);
        if(!result){
            //Could not read card
            return;
        }
        //Stop crypto to allow subsequent readings
        rc522.stopCrypto();
            
        
    }
}

Contributing

This library is still in development, suggestions, improvements and fixes are welcome. Please submit a pull request

Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].