I need a simple script that outputs ID of presented card in console. I tried a lot of opensource code that based on WiringPi library, e.g. Pidoorman, its forks by Kyle Mallory and E.J. Dyksen, RFID Access Control System by Laserbird from Instructables etc. but no one works correctly.

I'm sure that I connected all right cause that script (fork of Pidoorman wiegand.c by Kyle Mallory) changed its output when card presented:

Read 14 bits (2 bytes): DF31 : 1101111100110001
Read 15 bits (2 bytes): F701 : 1111011100000001
Read 18 bits (3 bytes): DFC001 : 110111111100000000000001
Read 19 bits (3 bytes): EFF001 : 111011111111000000000001
Read 17 bits (3 bytes): DFC300 : 110111111100001100000000
Read 76 bits (10 bytes): 9BBFC4EBDD57BA7E7C0D : 10011011101111111100010011101011110111010101011110111010011111100111110000001101
Read 30 bits (4 bytes): EEFF802E : 11101110111111111000000000101110
Read 14 bits (2 bytes): DF01 : 1101111100000001
Read 15 bits (2 bytes): EF66 : 1110111101100110
Read 15 bits (2 bytes): EF61 : 1110111101100001
Read 14 bits (2 bytes): DF21 : 1101111100100001

But I need something more human-readible and without constant (and wrong) output of pin state.

Any suggestion is much appreciated.


You can reliably read Wiegand devices with my pigpio library.

There is C, C++, and Python example code at http://abyz.me.uk/rpi/pigpio/examples.html

  • Hi Joan, thank you for your suggestion. Could you please briefly describe principles how your software works? I compile and run your test_wiegand.c and I saw constantly repeated messages, something like: bits=33 value=2871350613 bits=35 value=2773790381 bits=49 value=1420481877 etc. It's similar like wiegand.c by Kyle Mallory based on WiringPi library. But I need to output card ID only when it's presented, when contoroller receive interrupt. Or you think that I have some problems with hardware, like unstable voltage or contact chatter? Jul 31 '15 at 8:20
  • The software is normally in an idle state. When activity (falling edge) is detected on the green wire (0) or the white wire (1) the bits are accumulated. When there is no activity on the green or white wire for (a default) 5 ms the code is considered complete and its value and length are printed. The software is then back in the idle state. You appear to be picking up random noise. Have you connected the ground wire? Is something loose? Can you post a close-up photo of your set-up?
    – joan
    Jul 31 '15 at 8:59
  • Here is my schematics i.imgur.com/9EMJQQs.png and photo i.imgur.com/ixk29XO.jpg Jul 31 '15 at 20:06
  • I don't understand the point of the diodes. I've not noticed them in other Wiegand wiring diagrams. Mind you I've only looked at a couple of wiring diagrams. However there does not seem to be a ground between the Wiegand and the Pi. I'd expect a ground wire to come from the Wiegand like the green/white wires and for that ground wire to be connected to the Pi ground.
    – joan
    Jul 31 '15 at 20:28
  • I also don't understand completely for what diode is needed (I assume for stabilizing voltage and current), but some DIY projects like Pidoorman use them. Will try to make a common ground wire between Wiegand and Raspberry tomorrow and tell about result. Aug 2 '15 at 22:31

Check also my C interrupt-driven implementation, using wiringpi at https://bitbucket.org/sivann/wiegand_rpi/src

Check the wiegand_rpi.c simple reader

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.