I need some guidance regarding the Wiegand interface.
I have a facial recognition camera with Wiegand26 output, it's connected to Arduino UNO board pin2,3 and I am getting the correct Wiegand values in the serial monitor,
I have done activating an output (LED,13) by adding some lines, and its working fine,
I am trying to do, instead of one face I want to activate Arduino output with two different faces using facial camera Wiegand signal,
please see the codes and if possible, please reply,
Right now your sketch turns the LED on for 5 seconds whenever it receives data from the camera. It should work for any number of faces identified by the camera. Do you have to register faces? Did you register both faces?
I have registered and stored many faces, and you are right its identify every face and turns the LED ON.
I want this LED to be turned ON when two different faces identified.
in the camera settings, I don't have this option it's called the 4 eyes principle, so I thought I should give it a try. I strongly believe it's possible if I can somehow control Wiegand's data.
You want to turn on the LED when two (or more?) faces are in the picture at the same time? If two faces are present, what does the camera do? In Serial Monitor, turn on the "Show timestamp" option. Then put two people in front of the camera. Does the camera report the same person over and over (same number) or does it alternate between the two (two numbers alternating)? If it alternates, you could write code so if you get two different numbers very close together in time you can assume that two people are in the same frame. The timestamps should tell you how long between two people in the same frame.
I want to turn the led ON when two different person shows their faces one by one within 30-second.
for example, a Face1 identified then Arduino should wait for the 2nd code for 30seconds and within this waiting time if Face1 reads over and over again Arduino should do nothing until Face2 (a different person) with a different number identified.
Case1 same data
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Arduino OUTPUT should not be triggered
Case2 different data
Wiegand HEX = FFFFBF DECIMAL = 16777151, Type W26
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Arduino OUTPUT should be triggered
Case 2 different data
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Wiegand HEX = F6FFBF DECIMAL = 16187327, Type W26
Wiegand HEX = FFFFBF DECIMAL = 16777151, Type W26
Arduino OUTPUT should be trigger because the third entry is the different number.
The camera has two things to check before it authorizes access. 1st face, and 2nd temperature if both are correct then it spits out Weigand data. it takes approximately 4 to 5 seconds to identify.
if we disable the temperature sensor then it reads the closest face first and alternatively the second closest person but we will not use the camera without a temperature sensor.
#include <Wiegand.h>
WIEGAND wg;
const int ledPin = 13;
unsigned long LastCode = 0;
unsigned lonf LastTime = 0;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
wg.begin();
}
void loop()
{
if (wg.available())
{
unsigned long code = wg.getCode();
unsigned long time = millis();
// If this code is different from the previous code and
// the last code was less than 30 seconds ago.
if (LastCode != 0 && code != LastCode && time - LastTime <= 30000ul)
{
Serial.print("Saw 0x");
Serial.print(LastCode, HEX);
Serial.print(" and 0x")
Serial.print(code, HEX);
Serial.println(" within 30 seconds of each other.");
digitalWrite(ledPin, HIGH);
delay (5000);
digitalWrite(ledPin, LOW);
}
LastCode = code;
LastTime = time;
}
}