This wiki has been archived and made read-only.
For up-to-date information about TkkrLab and it's projects please visit our main website at



Jump to: navigation, search


  • Drbytes: Coding / electronics
  • Peter / Drbytes: Build lock into the door and install case with electronics etc
  • Aapskarel: Essence of condensed hamster
  • BigRed: Custom made breakout shield for electronics/connectors

We are mentioned on hackaday, well done everyone!


The goal of this project is to be able to enter the space with some sort of electronic key. We decided to use the iButton for this. We have a few reasons for electronic access of which the main reason is that we have a limited set of old metal keys and since all members get a key of the space we're soon running out of them. We cannot copy the keys because they are special keys which only can be ordered which would be too expensive (and also a waist of money since we don't know how long we can stay in our current building). Since we are sharing the building with others we cannot replace the cylinder and use cheap keys so there you have it: We're in need of an electronic access system. Other reasons for en electronic access system are the possibility of logging and revoking keys and of course it is cool to see some leds blinking when using an electronic key:)

Main Features

  • Reads iButtons to unlock the door if the iButton is a valid key
  • A led in the reader indicates with a blinking pattern that a valid key is read, lock opens after a pre defined delay
  • keys are stored in a key file on sd-card with a number (max 255 keys), the status (Admin key/Normal key/Revoked key) and a user name or message
  • button can open door from inside. Button only activates lock if released, so if the button got stuck/shorted door will remain closed
  • logging of system (error) status (Currently logs boot time, persistent NTP failures, persistent (stuck) button press and intrusion detect of case with electronics)
  • optional logfile for logging all key detections (Logs key name/number and if the door is actualy opened after reading the key)
  • IRC connection to our channel (bot): Send a message telling who enters the space. Request lock status and sends a message if an error condition occurs
  • Build in telnet server (also available trough serial interface) with menu options to check logfiles, update and add keys, backup or restore keyfile, check lock status etc. (with automatic logout timer)
  • some menu functions are only available if an admin key is read twice after entering the standard menu
  • keeps system time with DST calculations and syncs with NTP server each 256 seconds, if this fails repeatedly it will be logged.
  • auto logfile truncation if logfiles get larger then a definable size. If logfiles are truncated this will be logged also
  • security/protection:
    • Logging of all invalid and revoked keys (with code and in case of a revoked key with name and number)
    • Log if case with electronics is opened
    • Log when system has rebooted (after power failure or reset)
    • For revoked or invalid keys no visible indication in reader (led stays off). No information for unauthorized persons
    • Disable key read for configurable amount of time to prevent brute force attack
    • ESD hardware protection and current limiting on iButton electronics hopefully protects the microcontroller from being fried
    • Stuck or shorted button (to open lock from inside) will not open the door
    • Admin key codes are hard coded into flash, A dummy code indicating the admin key number is in the key file on the sd-card. Admin key codes are only transferred between the microcontroller and the iButton reader and never to IRC/Telnet/Serial interface or to log files
    • reads and displays temperature from internal temperature sensor in the atmega328 on the arduino (not really necessary but might indicate if someone is trying to hack the electronics with fire)

used parts

  • Arduino uno (controls Reading iButtons/Logging to SD-card/Telnet server/Serial/IRC client/NTP)
  • Ethernet shield (new one with micro SD-card reader)
  • Custom made breakout shield for electronics and connectors
  • Micro sd-card for storing keyfiles and logfiles
  • Electronic lock 002-ML300 with cylinder option so the old metal keys still work (needed for other users and owner of building)
  • Steel case (former case for electronics of alarm system) with salvaged powersupply to supply electronics and lock with 5V and 12V. We conveniently re use the intrusion detect button
  • A push button to open the door from the inside
  • DS1992L iButton reader with integrated led
  • DS1992 2nd iButton reader inside case to make it easier to add keys etc
  • DS1990A iButtons
  • Condensed essence of hamster

Financing for all of this

  • Thanks to the Hxx Foundation for generously sponsoring most of the hardware:)


ToDo list

  • Battery backup in case of power failure
  • Custom made printed circuit board to replace the arduino and shields (so we can use them for new projects:) This is work in progress right now)

pics of door, lock and electronics

Buitendeur1.jpg . Buitendeur2.jpg . Buitendeur3.jpg

Lock mounting and After (iButton reader with led installed in the aluminum frame):
Mounting-lock.jpg . Door-inside-open.jpg . Door-outside-closed.jpg . Door-outside-open.jpg

Case with prototype electronics and button to open door:
Case-electronincs-closed.jpg . Case-electronincs-arduino.jpg . Door-open-button.jpg
July 2012: Final electronics PCB design and result, in use since 25-08-2012:
Lock-O-Matic pcbTop.png . Lock-O-Matic pcbBtm.png . Lock-O-Matic V5.5.jpg. Lock-O-Matic V5.5 in-case.jpg


V5.5 of our lock electronics
Tkkrlab Lock-O-Matic.png


It took some time to fit all of the libraries and code into the available flash size of the arduino. With the arduino optiboot bootloader of 512 bytes only 32256 bytes remain left. Only after rigourous optimizing the code was small enough to fit (and eventually there were some leftover bytes to include measuring of chip temperature and storing the essence of condensed hamster (see above)). The code including all libraries currently consumes about 31800 bytes

Used libraries:

  • OneWire Library Maxim/Dallas Semiconductor's 1-Wire Protocol for reading the iButton
  • SPI library for Ethernet and SD-card (version: arduino 0022 release)
  • Ethernet library (version: arduino 0022 release)
  • Udp library (part of ethernet library, used for sending/receiving NTP packets)
  • SD library (not using the arduino included SD library for SD-Card access but adafruits variant (93916f1) because that one supports more then one open file at a time.
  • ChipTemp library for internal temperature sensor
  • to save some space I replaced digitalRead and DigitalWrite with a faster/less memory consuming option for writing and reading pins from johnraines24 (use the interrupt safe version)

source code File:Lock-O-Matic.tar.bz2

Pics of menu and admin menu (accessible by telnet or serial interface):
Lock-O-Matic default menu and status.jpg . Lock-O-Matic admin menu.jpg

Links to relating projects