Wiegand sending codes to domoticz

  • Trying to get a Wiegand 26 reader to send the tagcode to domoticz.
    Being not a wizard in coding, I think I got something wrong. I need to send the cardCode to domoticz to use in events, but the code appears in domoticz as "lux".
    Does anyone out there knows how to correct the program (much obliged)

    #include <MySensor.h>
    #include <SPI.h>
    #define ID 0
    MySensor gw;
    MyMessage msg(ID, S_CUSTOM);
    #define MAX_BITS 100                 // max number of bits 
    unsigned char bitCount;              // number of bits currently captured
    unsigned long facilityCode=0;        // decoded facility code
    unsigned long cardCode=0;            // decoded card code
    void ISR_INT0()
      flagDone = 0;
      weigand_counter = WEIGAND_WAIT_TIME;  
    void ISR_INT1()
      databits[bitCount] = 1;
      flagDone = 0;
      weigand_counter = WEIGAND_WAIT_TIME;  
    void setup()
      gw.sendSketchInfo("Wiegand", "1.0");
      gw.present(ID, S_CUSTOM); 
      pinMode(13, OUTPUT);  // LED
      Serial.println("RFID Readers");
      attachInterrupt(0, ISR_INT0, FALLING);  
      attachInterrupt(1, ISR_INT1, FALLING);
      weigand_counter = WEIGAND_WAIT_TIME;
    void loop()
      if (!flagDone) {
        if (--weigand_counter == 0)
          flagDone = 1;	
      if (bitCount > 0 && flagDone) {
        unsigned char i;
        Serial.print("Read ");
        Serial.print(" bits. ");
        if (bitCount == 26)
                // facility code = bits 2 to 9
             facilityCode <<=1;
             facilityCode |= databits[i];
          // card code = bits 10 to 23
             cardCode <<=1;
             cardCode |= databits[i];
        else {
              Serial.println("Unable to decode."); 
         // cleanup and get ready for the next card
         bitCount = 0;
         facilityCode = 0;
         cardCode = 0;
           databits[i] = 0;
    void printBits()
          // I really hope you can figure out what this function does
          Serial.print("FC = ");
          Serial.print(", CC = ");

  • @finch666


    I'm trying to do the same. Did you succeed ?

    Kind regards

  • Hi mscory,

    It's been a while, but as far as I remember I was able to see the values as text in domoticz, but was not able to use those in events.

  • Hero Member

    @finch666 domoticz does not support S_Custom in the way you use it. Try V_TEXT. (similar is discussed in a recent thread, I'm on a phone right now, hard to include the link.)

  • I believe I understood what you mean but I didn't find the message you referred to.

    My goal is to replace my old wired alarm with Domoticz and PiFace2 keeping my wired sensor (safer). I still have to find a way to arm/disarm the system. Up to now I didn't find such a device. If I can decypher Wiegand message I'll probably be able to use an access control device used for magnetic lock.

    Thank you to both of you

    Kind regards

  • Mod