KY-04 RS232 specifications

Notice that, on a windows-based machine, all RS-232 functionality of the KY-04 will also be available using the Key4win program.

RS-232 commands

Command Description Remarks
nxxxxxx<cr> New key. xxxxxx is the six-character hexadecimal code of the key, the last 6 characters of the laser-etched number on the key itself. KY-04 confirms addition with an exclamation mark ('!'), or alternatively prints 'F' if the non-volatile memory page is full.
dxxxxxx<cr> Delete key. xxxxxx is the six-character hexadecimal code of the key, the last 6 characters of the laser-etched number on the key itself. KY-04 confirms deletion with an exclamation mark ('!'), or alternatively prints '?' if the key was not found in the non-volatile memory.
s Show all keys in non-volatile memory: one key per line, 6 hexadecimal characters per key.
c! Clear all keys from non-volatile memory, including the master key. The first key held to a contact becomes the new master (The subsequent initialization of the non-volatile memory can take up to 8 seconds). The exclamation mark should be sent within 2 seconds after the 'c'.
o Open lock A for 2 seconds.
b Open lock B for 2 seconds.
r Reset: restarts the system, closes locks A and B, and resets the waiting time incurred for unknown keys.
h! Host mode. After this command all information is still passed over RS-232, but the locks will not be opened by the KY-04 itself. This can still be done using the 'o' and 'b' commands. Host mode can only be ended by issuing the reset command. A system without functioning non-volatile memory automatically starts in host mode. The exclamation mark should be sent within 2 seconds after the 'h'.

RS-232 output specifications

1. Reset

1.1 Version for 24C16 Eeprom:

"KY-04/650+ (C)1997 IDD"

1.2 Version for 24C64 Eeprom:

"KY-04/2600+ (C)1997 IDD"

2. Prompt

2.1 Version with silicon serial number

"xxxxxxxx " where x is a hexadecimal digit

2.2 Version without silicon serial number:

"IDD "

3. Key held to contact

"<01.XXXXXXxxxxxx.xx"
  || |||||||||||| ++-- CRC checksum byte
  || ||||||++++++----- Number of the key, only lower 24 bits are significant
  || ++++++----------- Upper 24 bits, disregarded
  ++------------------ Device code, is 01 for standard Dallas keys
The following will then be output (pseudo code):
  switch (CRC) {
    case CRC_OK:  "+"   Indicate valid CRC checksum
                  if (not in host mode) {
                    if (Eeprom primed) {
                      switch(key) {
                        case master:   "M"   Indicate master key
                                       ">O"  Open lock (for 2 seconds)
                                       if (master key for 10 seconds)
                                         "R"   Eeprom is being "reset" (blanked)
                                         "W"   Wait (for 2 seconds)
                                         ">O"  Open lock (for 0.5 second)
                                      else if (add key)
                                         "N"   Add new key
                                         if (Eeprom full)
                                           "F"   Indicate Eeprom full
                                       else if (delete key)
                                         "D"   Delete key
                                       }

                        case known:    "K"   Indicate known key
                                       if (master before us recently)
                                         "x"   Indicate key might be deleted
                                         ">C"  Close lock
                                       else
                                         ">O"  Open lock (for 2 seconds)
                                       }

                        case unknown:  "U"   Indicate unknown key
                                       if (master before us recently)
                                         "x"   Indicate key might be added
                                         ">C"  Close lock
                                       else
                                         if (same unknown as previous)
                                           "="   Indicate same unknown
                                         else
                                           "W"   Indicate contact blocked for some time (Waiting)
                                         }
                                       }
                      }

                    else {
                      "PW8"   Initialising ("programming") the Eeprom
                      ">O"    Open lock (for half a second)
                    }
                  }

    case CRC_BAD:  "-"   Indicate invalid CRC checksum
  }

  if (this was contact B) {
    "B"
  }
  "<cr><lf>"
  New prompt

4. Lock closes

  ">C"
  if (this was lock B) {
    "B"
  }
  New prompt

RS-232 examples

1. Key detected on contact B

0144a863 <01.00000112c9c7.62+K>OB
0144a863 >CB
0144a863

Explanation:
0144a863 The KY-04 prompt, in this case the serial number of the lock
< Indication of a key held to a contact
01.00000112c9c7.62 The family code of the key (01), the complete serial number of the key (00000112c9c7, of which only the last 6 characters (12c9c7) are significant), and the CRC checksum byte (62)
+ Indicates a positive Cyclic Redundancy Check (CRC)
K The key has been found in the non-volatile memory of the KY-04
> Indication of an action by the KY-04
O Indication that a lock was opened
B Indication that this key was held to contact B and that lock B was opened
0144a863 >CB Indication that lock B was closed (after 2 seconds)
0144a863  New prompt

2. Key added using master key on contact A

0144a863 <01.00000112c9c7.62+M>O Master 12c9c7 detected (M), lock opened (>O)
0144a863 <01.00000038674a.93+Ux>C Unknown key 38674a detected (U), within 2 seconds after master (x), lock closed (>C)
0144a863 <01.00000112c9c7.62+M>ON Master 12c9c7 detected (M), lock opened (>O), new user key added (N)
0144a863 >C Lock closed (>C) after half a second (acknowledge pulse)
0144a863 <01.00000038674a.93+K>OB Known key 38674a detected on contact B, lock B opened
0144a863 >CB Lock B closed after two seconds

Differences with KY-01/KY-03

IDD n123<01.000001655ab2.62+>O
IDD 456!
IDD >C
IDD
Remark: this will not occur during the execution of a command (eg. during the dump of all keys in non-volatile memory).

The main KY-04 page.
The KY-04s wiring scheme.
The KY-04d wiring scheme.
The main KY-series page.

For more information please contact: contact@idd.nl

Copyright2005, Innovative Design Delft  site by ii.nl