GithubHelp home page GithubHelp logo

nicoriff / wiegand-ng-multi-bit-wiegand-library-for-arduino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpliew/wiegand-ng-multi-bit-wiegand-library-for-arduino

0.0 0.0 0.0 19 KB

Multi Bit Wiegand Library for Arduino

C++ 100.00%

wiegand-ng-multi-bit-wiegand-library-for-arduino's Introduction

Wiegand NG - Multi Bit Wiegand Library for Arduino

This library is re-written from Wiegand 24 and Wiegand 36 Protocol Library for Arduino because the original library was coded to only detect 8, 26 and 34 bit Wiegand based on this Wiegand RFID Reader.

Wiegand NG supports unlimited bits (maximum memory allocatable by Arduino) and also support third party decoding scheme to be added. The original suggestion came from digitalentropy after submitting an issue on the original library's github page.

Features

  • unlimited bits (maximum memory allocatable by Arduino)
  • third party decoding support
  • customizable pulseGap
  • 3 Wiegand Readers when using Arduino Mega (untested)

Requirements

The following are needed

Installation

Create a folder named Wiegand in Arduino's libraries folder. You will have the following folder structure:

cd arduino/libraries
mkdir WiegandNG
cd WiegandNG
git clone https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino.git .

Arduino Sketch

alt text

Execute Arduino IDE, select Example-->WiegandNG-->WiegandRawTest

Example

#include <WiegandNG.h>

WiegandNG wg;

void PrintBinary(WiegandNG &tempwg) {
	volatile unsigned char *buffer=tempwg.getRawData();
	unsigned int bufferSize = tempwg.getBufferSize();
	unsigned int countedBits = tempwg.getBitCounted();

	unsigned int countedBytes = (countedBits/8);
	if ((countedBits % 8)>0) countedBytes++;
	// unsigned int bitsUsed = countedBytes * 8;
	
	for (unsigned int i=bufferSize-countedBytes; i< bufferSize;i++) {
		unsigned char bufByte=buffer[i];
		for(int x=0; x<8;x++) {
			if ( (((bufferSize-i) *8)-x) <= countedBits) {
				if((bufByte & 0x80)) {
					Serial.print("1");
				}
				else {
					Serial.print("0");
				}
			}
			bufByte<<=1;
		}
	}
	Serial.println();
}

void setup() {
	Serial.begin(9600);

	// for UNO just use wg.begin(), will default to Pin 2 and Pin 3 
	// connected to D0 and D1 respectively
	// initialize Wiegand ND for 48 bit data, every 8 bits take 
	// up 1 byte of Arduino memory
	// as long as there is still memory, user can even capture 
	// 1024 bit Wiegand by calling wg.begin(1024)

	unsigned int pinD0 = 2;
	unsigned int pinD1 = 3;
	unsigned int wiegandbits = 48;
	unsigned int packetGap = 15;			// 25 ms between packet
	
	if(!wg.begin(pinD0, pinD1, wiegandbits, packetGap)) {
		Serial.println("Out of memory!");
	}
	Serial.println("Ready...");
}

void loop() {
	if(wg.available()) {
		wg.pause();			// pause Wiegand pin interrupts
		Serial.print("Bits=");
		Serial.println(wg.getBitCounted()); // display the number of bits counted
		Serial.print("RAW Binary=");
		PrintBinary(wg); // display raw data in binary form, raw data inclusive of PARITY
		wg.clear();	// compulsory to call clear() to enable interrupts for subsequent data
	}
}

Acknowledgement

The library is based on the Wiegand 24 and Wiegand 36 Protocol Library for Arduino and contributions from community listed on the page.

Contributors

zanhecht Fix handling of partial bytes.

Written by JP Liew

Project home: http://www.monkeyboard.org/tutorials/82-protocol/24-wiegand-converter

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

wiegand-ng-multi-bit-wiegand-library-for-arduino's People

Contributors

jpliew avatar per1234 avatar zanhecht 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.