Quantcast
Channel: HomeSeer Message Board
Viewing all articles
Browse latest Browse all 4847

Wiegand How-To

$
0
0
Hi Folks

A very quick post on how I setup a wiegand reader....

Here is where you get the library from:
https://github.com/monkeyboard/Wiega...ry-for-Arduino

This is how you connect the wiegand reader to the arduino



Pin 5 on Arduino is used to toggle the LED on the reader.

Quote:

/************************************************************
*Arduino to Homeseer 3 Plugin API written by Enigma Theatre.*
* V1.0.0.81 *
* *
*******Change the values below only*************************
*/
//Wiegand Library
#include <Wiegand.h>
WIEGAND wg;

const int alarmstate = 5; //Alamstate to Blue Wire
long key = 0; //Set key to 0

//Address of the board.
const byte BoardAdd = 6;

#if ISIP == 1
// Enter a MAC address and IP address for your board below.
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x06};

// The IP address will be dependent on your local network.
IPAddress ip(192,168,11,225); //IP entered in HS config.
const unsigned int localPort = 8905; //port entered in HS config.
IPAddress HomeseerIP(192,168,11,24); //Homeseer IP address
IPAddress ServerIP(EEPROM.read(2),EEPROM.read(3),EEPROM.read(4),EEPROM .read(5));
byte EEpromVersion = EEPROM.read(250);
#endif


//************Do not change anything in Here*****************
int FromHS[10]; // *
boolean IsConnected = false; // *
#if ISIP == 1 // *
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; // *
EthernetUDP Udp; // *
const unsigned int ServerPort = 8888; // *
#endif // *
void(* resetFunc) (void) = 0; // *
//***********************************************************


void setup() {
HSSetup();
//************************
//Add YOUR SETUP HERE;
//************************

pinMode(alarmstate, OUTPUT); //Make the pin an output

wg.begin();
}

void loop() {
#if ISIP == 1
IsUDP();
#endif

//************************
//Add YOUR CODE HERE;
//************************
/* To Send Data to Homeseer use SendToHS(Device,Value)
Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.
Eg.. FromHS[5] would be the data from API Output device 5
All code that is located just below this block will execute regardless of connection status!
You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
*/

/*Execute regardless of connection status*/



/*Execute ONLY when HomeSeer is connected*/
if (IsConnected == true) {

if(wg.available()) {
key=(wg.getCode()); //lets get the decimal value of the key
SendToHS(1,key); // Send the decimal key to HS
}
digitalWrite(alarmstate,FromHS[1]); // LED line on Wiegand Reader
}
}
Here is how I setup the Arduino Board under API mode:



And lastly how I setup the tags against the reader.



Clearly there are a whole bunch of other things you can do on the arduino, add a door strike, exit button and reed switch on the door and write your events accordingly.

Good luck !

Pete

Viewing all articles
Browse latest Browse all 4847