Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiegand interface #211

Closed
golfvert opened this issue May 3, 2019 · 140 comments
Closed

Wiegand interface #211

golfvert opened this issue May 3, 2019 · 140 comments

Comments

@golfvert
Copy link

golfvert commented May 3, 2019

Describe the problem you have/What new integration you would like
I am using wiegand access. It would be nice to be able to integrate this kind of equipment to ESPHome

Please describe your use case for this integration and alternatives you've tried:
At the moment, I am using a home made script. Having one solution for all would be nice.

Additional context

@OttoWinter
Copy link
Member

I think the RDM6300 uses wiegand - could you try with the rdm6300 integration?

@Zebble
Copy link

Zebble commented May 23, 2019

The RDM6300 seems to use a standard UART protocol. Wiegand is its own beast. It would require some interrupt-driven communication for accuracy, but does seem fairly simple.

There's a good library that can figure out the number of bits in the data automagically. If I had time, I'd port it. Any takers?

https://github.com/paulo-raca/YetAnotherArduinoWiegandLibrary

@nerdosity
Copy link

That would be very good. I have a weigand reader outside, knowing the tag read would be perfect for integrating it into Home Assistant.
Not knowing the tag I have mapped the relay as an ON/OFF, and I will have to put another rfid reader integrated for automations since I want some automation just for my tag and my girlfriend's, not for other tags.

@beikeland
Copy link

beikeland commented Jul 15, 2019

I have a couple of Siemens AR6182-MX readers (w/keypads) that can be configure to use a Wiegand interface, would be interesting to get this hooked up to EspHome.

Tried the YetAnotherArduinoWiegandLibrary and it works on arduino but not ESP8266. Found https://github.com/esprfid/esp-rfid which uses https://github.com/monkeyboard/Wiegand-Protocol-Library-for-Arduino.git but this didn't boot on my NodeMCU board at all. Might poke more later, but in case the links are of interest ☝️

@beikeland
Copy link

This fixes the library used in esp-rfid as linked to above
monkeyboard/Wiegand-Protocol-Library-for-Arduino#38

Unfortunately I need other bitcounts than standard depending on card type and optional pin length so I'll probably do a AR6182-MX library instead of a generic Wiegand.

@nerdosity
Copy link

@beikeland I am using esp-rfid project on my nodeMCU since a couple of weeks, just use version 1.0.2 since latest one has problems with MQTT messages for tags.

@beikeland
Copy link

My primary motivation for looking into using ESPhome was to not rely on MQTT. I've got the library working and sorted out separating Pin, Card and Card+Pin in an Arduino sketch running on a NodeMCU-devkit. So just have to wrap my head around the abstraction needed to write a new component for the Wiegand bus and a sensor or something on top of that, or find that someone beats me to it while trying to understand the ESPhome code:)

@nerdosity
Copy link

I understand that, I just replied to the fact that it wasn't booting on your nodeMCU ;)

@beikeland
Copy link

beikeland commented Jul 18, 2019 via email

@beikeland
Copy link

Still trying to work out how to add the components to ESPHome, maybe one day.
Sharing a gist with the working arduino sketch for esp8266 and AR6182 reader. Reader uses an electric wiegand interface, but custom protocol.
https://gist.github.com/beikeland/145b20b1fc585049ea8951eddfc5732e

@CountParadox
Copy link

I have a bunch of HID Prox readers, would love a component to use them with ESPHome! Currently using them with https://github.com/TomHarkness/homeID

@pricard32
Copy link

Any news on that? I've bought a keypad that use this protocol and would like to wiring it to an ESP32 running ESPHOME

@edwardscaleb9
Copy link

Also interested in using wiegand keypads connected to an ESP8266/ESP32.

@pricard32
Copy link

Can you help me building the plugin ?

@edwardscaleb9
Copy link

I’d be happy to give it a go, but I’m not much of a programmer these days. More of a scripter I’d say.

While I’m thinking about it, one feature I’d like to see is the ability to set codes/card numbers in HomeAssistant (or whatever frontend) and have them cached locally on the ESP.

@CountParadox
Copy link

CountParadox commented Jan 12, 2020 via email

@Zebble
Copy link

Zebble commented Jan 12, 2020 via email

@pricard32
Copy link

I'm not interest of just RFID. I would like the complete wiegand protocol. Either Keypad of RDIF will be pass to HA.

And like @edwardscaleb9 said, it would be great to program the keypas via HA.

I've found online a library for Weigand, but dont have the skills to implement it with ESPHOME.

Someone with those skill would want to help us ?

@gdoerr
Copy link

gdoerr commented Jan 27, 2020

I was able to implement a CustomAPIDevice using code from this Github repo without any issues. The code works as is (I had to drop the IRAM_ATTR on the interrupt handlers in order to get it to link but it's working well for me.

I can post the sample custom device code if anyone is interested.

@pricard32
Copy link

@gdoerr i’m really interested to see how you did it !!

@gdoerr
Copy link

gdoerr commented Jan 27, 2020

Save the code below as wiegand_device.h and include it as a custom component in your YAML file.

custom_component:
  - lambda: |-
       auto wiegand = new WiegandReader(pin0, pin1, "script.to_call");
       return {wiegand};

pin0 should be the GPIO connected to the D0 signal and pin1 is the GPIO connected to the D1 signal. Replace "script.to_call" with the name of the script or service to call. The code entered will be passed as the parameter code.

#include "esphome.h"

/**
 * Wiegand Reader Custom Device
 *
 * Copied from https://github.com/monkeyboard/Wiegand-Protocol-Library-for-Arduino
 * Implemented by Greg Doerr (https://github.com/gdoerr)
 *
 * In my example, hooked to an Olimex ESP32-POE device connected to a Retekess H1EM-W
 * Wiegand keypad. This device calls a service on Home Assistant when a code is available
 *
 * Samples key presses every 200ms and stores the key in a string until:
 *   [1] - the user presses a '#' which sends the code immediately
 *   [2] - the user presses nothing for 2,000ms (inter-digit timer) which then sends the code
 *   [3] - the user presses a '*' which sends the '*' immediately
 */
class WiegandReader : public PollingComponent, public CustomAPIDevice {

public:
    WiegandReader(int pinD0, int pinD1, std::string serviceName)
        : PollingComponent(200),
        pinD0(pinD0), pinD1(pinD1),
        serviceName(serviceName) {
    }

    /**
     * Initial setup
     */
    void setup() override {
        _lastWiegand = 0;
        _cardTempHigh = 0;
        _cardTemp = 0;
        _code = 0;
        _wiegandType = 0;
        _bitCount = 0;

        // Configure the input pins
        pinMode(pinD0, INPUT);
        pinMode(pinD1, INPUT);

        // Attach the interrupts
        attachInterrupt(digitalPinToInterrupt(pinD0), ReadD0, FALLING);  // Hardware interrupt - high to low pulse
        attachInterrupt(digitalPinToInterrupt(pinD1), ReadD1, FALLING);  // Hardware interrupt - high to low pulse
    }

    void update() override {
        // See if we have a valid code
        noInterrupts();
        bool rc = DoWiegandConversion();
        interrupts();

        if(rc) {
            if(_code < 10) {
                // We have a digit, make it ASCII for convenience
                keyCodes += (_code + 0x30);
            } else if(_code == 11) {
                // The user pressed '#', send the accumulated code and reset for the next string
                callHAService(keyCodes);
                keyCodes = "";
            } else if(_code == 10) {
                // The user pressed '*', clear the code and send the asterisk
                callHAService("*");
                keyCodes = "";
            }
            // Capture the last time we received a code
            lastCode = millis();
        } else {
            if(keyCodes.length() > 0) {
                // We have a keyCode, see if the interdigit timer expired
                if(millis() - lastCode > 2000) {
                    // The interdigit timer expired, send the code and reset for the next string
                    callHAService(keyCodes);
                    keyCodes = "";
                }
            }
        }
    }

private:
    static volatile unsigned long _cardTempHigh;
    static volatile unsigned long _cardTemp;
    static volatile unsigned long _lastWiegand;
    static volatile int _bitCount;
    static int _wiegandType;
    static unsigned long _code;

    unsigned long lastCode = 0;
    std::string keyCodes = "";

    int pinD0;
    int pinD1;
    std::string serviceName;

    /**
     * Calls a Home Assistant service with the key code
     * @param keyCode
     */
    void callHAService(std::string keyCode) {
        call_homeassistant_service(serviceName.c_str(), {
                {"code", keyCode.c_str()}
        });
    }

    /**
     * D0 Interrupt Handler
     */
    static void ReadD0() {
        _bitCount++;				// Increment bit count for Interrupt connected to D0
        if(_bitCount > 31) { 		// If bit count more than 31, process high bits
            _cardTempHigh |= ((0x80000000 & _cardTemp)>>31);	//	shift value to high bits
            _cardTempHigh <<= 1;
            _cardTemp <<=1;
        } else
            _cardTemp <<= 1;		// D0 represent binary 0, so just left shift card data

        _lastWiegand = millis();	// Keep track of last wiegand bit received
    }

    /**
     * D1 Interrupt Handler
     */
    static void ReadD1() {
        _bitCount ++;				// Increment bit count for Interrupt connected to D1

        if(_bitCount > 31) {		// If bit count more than 31, process high bits
            _cardTempHigh |= ((0x80000000 & _cardTemp)>>31);	// shift value to high bits
            _cardTempHigh <<= 1;
            _cardTemp |= 1;
            _cardTemp <<=1;
        } else {
            _cardTemp |= 1;			// D1 represent binary 1, so OR card data with 1 then
            _cardTemp <<= 1;		// left shift card data
        }
        _lastWiegand = millis();	// Keep track of last wiegand bit received
    }

    /**
     * Extract the Card ID from the received bit stream
     * @param codehigh
     * @param codelow
     * @param bitlength
     * @return
     */
    unsigned long getCardId(volatile unsigned long *codehigh, volatile unsigned long *codelow, char bitlength) {
        if (bitlength==26)								// EM tag
            return (*codelow & 0x1FFFFFE) >>1;

        if (bitlength==34)								// Mifare
        {
            *codehigh = *codehigh & 0x03;				// only need the 2 LSB of the codehigh
            *codehigh <<= 30;							// shift 2 LSB to MSB
            *codelow >>=1;
            return *codehigh | *codelow;
        }
        return *codelow;								// EM tag or Mifare without parity bits
    }

    /**
     * Convert the received bitstream
     * @return
     */
    bool DoWiegandConversion () {
        unsigned long cardID;
        unsigned long sysTick = millis();

        if ((sysTick - _lastWiegand) > 25)								// if no more signal coming through after 25ms
        {
            if ((_bitCount==24) || (_bitCount==26) || (_bitCount==32) || (_bitCount==34) || (_bitCount==8) || (_bitCount==4)) { 	// bitCount for keypress=4 or 8, Wiegand 26=24 or 26, Wiegand 34=32 or 34
                _cardTemp >>= 1;			// shift right 1 bit to get back the real value - interrupt done 1 left shift in advance
                if (_bitCount>32)			// bit count more than 32 bits, shift high bits right to make adjustment
                    _cardTempHigh >>= 1;

                if (_bitCount==8) { 		// keypress wiegand with integrity
                    // 8-bit Wiegand keyboard data, high nibble is the "NOT" of low nibble
                    // eg if key 1 pressed, data=E1 in binary 11100001 , high nibble=1110 , low nibble = 0001
                    char highNibble = (_cardTemp & 0xf0) >>4;
                    char lowNibble = (_cardTemp & 0x0f);
                    _wiegandType=_bitCount;
                    _bitCount=0;
                    _cardTemp=0;
                    _cardTempHigh=0;

                    if (lowNibble == (~highNibble & 0x0f)) {	// check if low nibble matches the "NOT" of high nibble.
                        _code = (int)lowNibble;
                        return true;
                    } else {
                        _lastWiegand=sysTick;
                        _bitCount=0;
                        _cardTemp=0;
                        _cardTempHigh=0;
                        return false;
                    }

                    // TODO: Handle validation failure case!
                } else if (4 == _bitCount) {
                    // 4-bit Wiegand codes have no data integrity check so we just
                    // read the LOW nibble.
                    _code = (int)(_cardTemp & 0x0000000F);

                    _wiegandType = _bitCount;
                    _bitCount = 0;
                    _cardTemp = 0;
                    _cardTempHigh = 0;

                    return true;
                } else { 		// wiegand 26 or wiegand 34
                    cardID = getCardId (&_cardTempHigh, &_cardTemp, _bitCount);
                    _wiegandType=_bitCount;
                    _bitCount=0;
                    _cardTemp=0;
                    _cardTempHigh=0;
                    _code=cardID;
                    return true;
                }
            } else {
                // well time over 25 ms and bitCount !=8 , !=26, !=34 , must be noise or nothing then.
                _lastWiegand=sysTick;
                _bitCount=0;
                _cardTemp=0;
                _cardTempHigh=0;
                return false;
            }
        } else
            return false;
    }
};

volatile unsigned long WiegandReader::_cardTempHigh = 0;
volatile unsigned long WiegandReader::_cardTemp = 0;
volatile unsigned long WiegandReader::_lastWiegand = 0;
volatile int WiegandReader::_bitCount = 0;
unsigned long WiegandReader::_code = 0;
int WiegandReader::_wiegandType = 0;

@pricard32
Copy link

Wow @gdoerr , that's a greate job you did! Thanks !
Since i'm pretty new to this, and i've buy the exact same keypad as you, can you help me with something more.
I'll like to push the data into a text_sensor: can you explain me what I have to that to the yaml and .h file?

Thanks again!

@pricard32
Copy link

And i'm using a ESP-32 for now, can I use any GPIO pin ?

@gdoerr
Copy link

gdoerr commented Jan 27, 2020

You'd have to restructure the Wiegand class into a TextSensor. I don't recommend this because you're not interested in state, you really want the event which is why I call a service. You should be able to find the example code on esphome to implement a custom text sensor.

You should be able to use any GPIO pins on the ESP32 but the order is important...swap D0 and D1 if your're getting weird results.

Good Luck!

@pricard32
Copy link

What would you recommend to write in the script to call to received as a event ?

@gdoerr
Copy link

gdoerr commented Jan 27, 2020

You can use either a yaml script or a python script.

I use a python script to validate the code sequences against a dedicated outlook.com calendar to control access to my garage.

@pricard32
Copy link

Or maybe only share your how implentation, that's help me reverse engineering and understand or to implement it for my use.

@pricard32
Copy link

I've tried to change the class declaration from CustomApiDevice to TextSensor and add PublishState(keyCode) to CallHaService without success

@gdoerr
Copy link

gdoerr commented Jan 28, 2020

@pricard32 Rather than mucking up this feature request thread with a specific problem, perhaps you can post your question on Stack Overflow which is better suited and then post a link to the problem here.

I'm happy to help but you'll need to provide more information than you tried something without success. When you ask the question, be sure and post exactly what you tried and what errors you're getting. Otherwise it's difficult to help you without writing the software for you...

@gio-dot
Copy link

gio-dot commented Jan 8, 2022

@pashdown I've been trying to integrate an HID reader, but it doesn't seem to read/decode quite as easily. Could you share a bit of your Wiegand code here? Thank you in advance! I understand some bits compose the "facility ID" and the remainder the "tag ID" but haven't worked on it for some time. :(

I used @avwuff 's code mentioned above https://github.com/avwuff/esphome-wiegand. It returns a Home Assistant decimal tag for either RFID or NFC cards. I don't really care what portion of the bits are what, as long as it is consistent and unique for each card. I use the Signo 40.

It would be nice to have this officially merged into esphome. Seems like there is a lot of confusion about what works and what doesn't. The above mentioned code has been very stable for me.

I'm yet looking for a version that can work on esp32. Tried versions posted above but nothing work on esp32cam...

@stefan-golinschi
Copy link

@keith721 @cheisig
Hi guys, I can confirm that the patch I posted works. I rebuilt esphome(rev. 3d71e2e1890a94d0ca) with the wiegand component built-in and everything is fine.

As @keith721 suggested, there are some compilation issues only if you use the wiegand component as external, because the version of the esphome that would use the external component is more recent than the component itself, thus the compilation issues. The component is slightly outdated and needs to be fixed using the modifications that @keith721 suggested.

@cheisig, If you want to give it a try, you should use my fork (stefan-golinschi/esphome dev branch) which contains the wiegand component modifications onto the esphome rev.: 3d71e2e1890a94d0caee3dda2403184b98fdbfde. So, in order to use the component, you should use an older version of esphome(ie. revision 3d71e2e1890a94d0caee3dda2403).

@nerdosity
Copy link

@OttoWinter this seems quite stable, how can we apply for an official integration?

@mgiako
Copy link

mgiako commented Apr 8, 2022

Hi, I used code from @avwuff https://github.com/avwuff/esphome-wiegand and found that the number it extracts is quite different than expected.
I have some 26bit tags from work (we use HID readers) and I found that if I read my tag that I know has a facility code 104 and card id 123, I obtain the number "6871403".
Another of my tags has the same facility code (of course) and card id 378, the number I obtain is "6871658".
I have found that I have to subtract 583 to first 3 digit to obtain the facility code (104), and subtract 1280 from the last 4 digit to obtain the card ID (123)

6871403:    687-583=104  1403-1280=123 

6871658:    687-583=104   1658-1280=378

I don't understand why this correction is needed.
I'd like to change the original code to get the correct number, but I'm not good at it.
I then corrected the value by using a variable in the automation that reads the badge:

  - alias: RfidRead
    id: RfidRead
    variables:
      ID: >-
        {% set badgefac = int(trigger.event.data.tag_id[:3])-583 %} 
        {% set badgeid = int(trigger.event.data.tag_id[-4:])-1280 %} 
        {% set totbadge = badgefac|string + badgeid|string %}
        {{ totbadge }}
      badges:
        "104123":
          utente: Dad
        "104378":
          utente: Mum
    trigger: 
      - platform: event
        event_type: tag_scanned
    action:
      - condition: template
        value_template: "{{ ID|string in badges }}"  
      - service: notify.notify
        data_template:
          message: "{{ badges[ID|string].utente }} used the badge"                

      - the other service you'll need

I hope it will be useful to someone.
But even more I hope someone help me to get the correct values directly from esphome,

@gio-dot
Copy link

gio-dot commented Apr 8, 2022

@keith721 @cheisig Hi guys, I can confirm that the patch I posted works. I rebuilt esphome(rev. 3d71e2e1890a94d0ca) with the wiegand component built-in and everything is fine.

As @keith721 suggested, there are some compilation issues only if you use the wiegand component as external, because the version of the esphome that would use the external component is more recent than the component itself, thus the compilation issues. The component is slightly outdated and needs to be fixed using the modifications that @keith721 suggested.

@cheisig, If you want to give it a try, you should use my fork (stefan-golinschi/esphome dev branch) which contains the wiegand component modifications onto the esphome rev.: 3d71e2e1890a94d0caee3dda2403184b98fdbfde. So, in order to use the component, you should use an older version of esphome(ie. revision 3d71e2e1890a94d0caee3dda2403).

Does it work on esp32?

@patricktd
Copy link

Hi Guys!

Any update?

@gio-dot
Copy link

gio-dot commented May 1, 2022

Hi Guys!

Any update?

Mmmmh i think that we will never see officially Wiegand in Esphome...
image

@lednicazar
Copy link

It's a pitty, I've this implemented in home assistant with ESPHome over a esp8266 working great, but the official implementation will work even better for sure.
Also I'm interested to port this to esp32

@nerdosity
Copy link

+1, for me the integration (after patching it) worked great.

@AlexandreUSA
Copy link

@gio-dot, @lednicazar and @nerdosity, thanks for letting us know that you were able to get the Wiegand integration to work with Home Assistant. After reading all the posts here and many more online, I am ready to try this out. I am pretty novice with this type of integration and I would like to get a little bit more details on the steps to get it to work. I do have a simple garage door control with an ESP8266 and relay board working and I also have my alarm system connected via an ESP32. Both of them with ESPhome. However, I am a little lost when it comes to h files and scripts with parameters. My goal is to read the code entered at the keypad, compare it to a list of approved code, and then open the garage door.

Could you post your implementation steps? Which version the wiegand_device.h did you use? ESP32 or ESP8266? Could you also show an example of a script that uses the code provided by Wiegand?

I have a couple keypads coming in for testing: the Retekess T-AC03 and the T-AC04. Both should be compatible with Wiegand 26-bit. Let me know what you use so if I can not be successful with these, I can order your keypad brand.

Thanks again to all

@nerdosity
Copy link

nerdosity commented May 11, 2022

Hi, I'm using an Amazon one, the one with the metal body and the internal embedded inside resin.
It's the third year it survive staying completely outside, under rain and direct sun, 40 EUR well spent.

I connected it to an ESP8266 and refleshed it with this:

esphome:
  includes:
    - wiegand_device.h
  name: rfid-cancello
  platform: ESP8266
  board: nodemcuv2

wifi:
  networks:
  - ssid: 'REDACTED'
    password: 'REDACTED'
  manual_ip:
    gateway: 192.168.1.254
    subnet: 255.255.255.0
    static_ip: 192.168.1.217
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: 'ESP8266 RFID'
    password: 'REDACTED'

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
- platform: custom
  lambda: |-
    auto wiegand = new WiegandReader(D1, D2);
    App.register_component(wiegand);
    return {wiegand};
  sensors:
    name: "Card ID"
    on_value:
      then:
        - homeassistant.tag_scanned: !lambda |-
            char buf[16];
            sprintf(buf, "%.0f", x);
            std::string s = buf;
            return s;        
            
binary_sensor:
  - platform: status
    name: 'Stato connessione ESP8266 RFID'          

Apart from the Italian bits, you should be able to use it.
I patched it manually using cheisig reference.

Then it built and flashed perfectly.

@AlexandreUSA
Copy link

@nerdosity Thank you!. Could you provide additional information on the manual patching ? I am confused with what appears to be two methods:

One with 3 files (stefan-golinschi/esphome@c4e283e) and some patching to do

esphome/components/wiegand/init.py,
esphome/components/wiegand/wiegand.h.
esphome/components/wiegand/wiegand.cpp

and another one with one file:

esphome/custom_components/wiegand_device.h

What is the current recommendation. Where should I get the files from as it seems to have numerous repositories and forks with similar code.

@AlexandreUSA
Copy link

Getting closer.
Method 1: I place the three files from Stefan-golinschi. I got bunch of errors. I patched the files with the explanation of cheisig, all of them went away except one that was not mentioned by Cheisig and it is related to my yaml file. I can't find a way to get rid off it.

/config/esphome/garagedoors.yaml: In lambda function: /config/esphome/garagedoors.yaml:26:26: error: expected type-specifier before 'WiegandReader' 26 | auto wiegand = new WiegandReader(D5, D6); | ^~~~~~~~~~~~~ /config/esphome/garagedoors.yaml:28:22: error: could not convert '{wiegand}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::sensor::Sensor*>' 28 | return {wiegand}; | ^ | | | <brace-enclosed initializer list> *** [/data/garagedoors/.pioenvs/garagedoors/src/main.cpp.o] Error 1 ========================== [FAILED] Took 8.82 seconds ==========================

Method 2: Using the wiegand_device.h file only. I can compile and upload. All good. I am able to read the digit submitted at the keypad, but only 1 digit at a time. I could not find out how to get the 4-digit code submitted. Each digit shows as individual tag in HA.

@AlexandreUSA
Copy link

AlexandreUSA commented May 14, 2022

Ok, I got it to work using the one file method.

I modified the files (.ymal and .h) to handle keypad entries and RFID tags and correct issues with alpha numeric values or code starting with 0.

See my repository if you are interested by a simple method.

@HGupta2018
Copy link

Ok, I got it to work using the one file method.

I modified the files (.ymal and .h) to handle keypad entries and RFID tags and correct issues with alpha numeric values or code starting with 0.

See my repository if you are interested by a simple method.

I'm pretty new to all this, but want to do the same thing as you. But I am a novice and need a bit of hand holding. I have home assistant working and have an ESP8266 board and an keypad that outputs wiegand over two wires. Can you walk me through the steps? Thanks!

@stefan-golinschi
Copy link

stefan-golinschi commented Aug 28, 2022

@HGupta2018, you should take into account that most Wiegand readers use 12v logic, so you will need to use a level shifter between the esp8266 and the reader.
To test what worked for me, you should recompile esphome from my github page (the one that contains the Wiegand patches).
I plan to update the Wiegand component to be compatible with the latest esphome.

Edit:
I have updated the wiegand component and now its compatible with the latest esphome. I have compiled esphome using an Ubuntu 22.04 container.
I now tested the component with a wiegand reader and everything works as expected.

https://github.com/stefan-golinschi/esphome/tree/dev

@ssieb
Copy link
Member

ssieb commented Aug 28, 2022

The readers I've used have maximum 5V output on the data pins, so you don't need a level shifter. Check what yours puts out before worrying about that.

@skylord123
Copy link

The readers I've used have maximum 5V output on the data pins, so you don't need a level shifter. Check what yours puts out before worrying about that.

Same. The one I used didn't require a level shifter. The power supply used for the keypad was garbage though and caused my data lines to go wonky (keypad would get spammed with key presses whenever data lines were connected). Had to replace with my own 12v power supply. Sort of sucked because the Chinese power supply handled opening the drop locks. Had to buy a relay and do all that manually.

@HGupta2018
Copy link

The readers I've used have maximum 5V output on the data pins, so you don't need a level shifter. Check what yours puts out before worrying about that.

great to know. I will measure before I start.

I know it has to be a basic question, but how do I get the wiegand_device.h file onto the ESPhome?

@ssieb
Copy link
Member

ssieb commented Sep 22, 2022

@autox86
Copy link

autox86 commented Sep 22, 2022 via email

@ssieb
Copy link
Member

ssieb commented Sep 22, 2022

There's a README for each component that describes how to configure it and the top-level of the repo describes how to include the components.

@reidprojects
Copy link

@ssieb that's great ! I'll definitely give it a try.

Do you have any plan to try to make it an official component?

@ssieb
Copy link
Member

ssieb commented Sep 22, 2022

I have "plans", but it requires getting around to writing documentation pages for the components.

@balazs111
Copy link

Thank you @ssieb.
Your wiegand component is really useful.

@nagyrobi
Copy link
Member

nagyrobi commented Jun 3, 2023

Implemented: https://esphome.io/components/wiegand.html

@nagyrobi nagyrobi closed this as completed Jun 3, 2023
@pashdown
Copy link

pashdown commented Jun 3, 2023

Wow! At long last! Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.