Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compatibilidad con teclado wiegand.
#1
Buen día hasta el momento me funciona bien la tarjeta estoy emocionado por las ventajas que ofrece , pero me gustaría saber si puede ser compatible con algún teclado wiegand, ví la publicación que tienen con otra tarjeta pero no me funciona , alguna librería para usarla con esta tarjeta y en qué puerto  

GRACIAS
Reply
#2
[Image: KC868-A6-1_05.jpg]
see top GREEN terminal IO1 and IO2 , these two pins can use for Wiegand device.
Reply
#3
Muchas gracias, voy a conectar esos dos pines pero me refería a que código cargar en Arduino ide para poder leer las teclas desde teclado wiegand, agradezco de ante mano. Buen día
Reply
#4
Creo que ya encontré la librería , y funciona excelente , gracias
Reply
#5
Code:
/*
* Example program for reading Wiegand data using ESP32
* Made by KinCony IoT: https://www.kincony.com
*
* This program demonstrates how to read Wiegand data (commonly used in RFID readers) using GPIO pins.
* It is configured for Wiegand 26-bit and 34-bit formats.
*
* You can freely modify and distribute this code under the terms of the MIT license.
*/

#define WIEGAND_D0_PIN 32  // GPIO pin for Wiegand Data 0 (D0)
#define WIEGAND_D1_PIN 33  // GPIO pin for Wiegand Data 1 (D1)

volatile unsigned long cardData = 0;  // Variable to store the card data
volatile unsigned int bitCount = 0;   // Counter for the number of bits received
unsigned long lastWiegandTime = 0;    // Time of the last bit received

#define WIEGAND_TIMEOUT 3000  // 3-second timeout to consider a Wiegand packet complete

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(115200);
 
  // Configure Wiegand pins as inputs
  pinMode(WIEGAND_D0_PIN, INPUT);
  pinMode(WIEGAND_D1_PIN, INPUT);
 
  // Attach interrupts to handle Wiegand signals
  attachInterrupt(digitalPinToInterrupt(WIEGAND_D0_PIN), handleWiegandD0, FALLING);  // Trigger on falling edge for D0
  attachInterrupt(digitalPinToInterrupt(WIEGAND_D1_PIN), handleWiegandD1, FALLING);  // Trigger on falling edge for D1
}

void loop() {
  // Check if the last bit was received more than 3 seconds ago (Wiegand timeout)
  if ((millis() - lastWiegandTime > WIEGAND_TIMEOUT) && bitCount > 0) {
    // If the timeout has occurred and bits were received, process the data
    processWiegandData();
   
    // Reset the bit counter and card data for the next packet
    bitCount = 0;
    cardData = 0;
  }
}

// Interrupt service routine (ISR) for handling Wiegand D0 signal
void IRAM_ATTR handleWiegandD0() {
  bitCount++;            // Increment the bit count
  cardData <<= 1;        // Shift the current data to the left (adding a 0)
  lastWiegandTime = millis();  // Record the time of this bit reception
}

// Interrupt service routine (ISR) for handling Wiegand D1 signal
void IRAM_ATTR handleWiegandD1() {
  bitCount++;            // Increment the bit count
  cardData <<= 1;        // Shift the current data to the left
  cardData |= 1;         // Set the least significant bit to 1 (since this is D1)
  lastWiegandTime = millis();  // Record the time of this bit reception
}

// Function to process the received Wiegand data once a complete packet is received
void processWiegandData() {
  Serial.print("Received Wiegand data: ");
  Serial.print(cardData);
  Serial.print(" with ");
  Serial.print(bitCount);
  Serial.println(" bits.");
 
  // Check if the bit count corresponds to the common Wiegand formats
  if (bitCount == 26) {
    // Wiegand 26-bit format
    Serial.println("Wiegand 26-bit format detected.");
  } else if (bitCount == 34) {
    // Wiegand 34-bit format
    Serial.println("Wiegand 34-bit format detected.");
  } else {
    // Unknown or unsupported format
    Serial.println("Unknown Wiegand format.");
  }
}
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)