This post is about a mini project that I suddenly thought of during the challenge and thought would fit well as part of the larger project The idea was to make a key holder allowing up to four different (sets of) keys. It serves two purposes: a fixed place to hang our keys (we tend to misplace them a lot!) and assuming proper use, could be used as an alternative/additional presence check.

 

 

Mechanism

 

For the key holders, I decided to use stereo jacks and panel mount connectors. By shorting the left and right channel in the jack, a loop is created. On the connector, the left channel connects to ground, the right channel connects to a GPIO pin with internal pull-up resistor. When the jack is not inserted the GPIO is HIGH, when inserted, LOW. There is no differentiator per key at the moment, but could be achieved in a future version in different ways:

  • Rather than just pulling to GND, resistors could be used, resulting in different analog values, each unique per key This will require the use of an ADC.
  • Use a different connector set per key, making it impossible to connect in any other slot.

 

To have everything removable/replaceable, I used male header pins on the connectors and Dupont wires. The ground wire is daisy-chained across all four connectors. This results in a total of five connections to the Raspberry Pi's GPIO header: four GPIO pins and one ground. As a visual aid and indication, every connector is associated to an LED of a certain colour. When the jack is plugged in, the LED is turned off, when removed, turned on. The LEDs are located on a small board which fits straight on the GPIO header, called Blinkt!. Using the python library, the individual LEDs can be controlled.

 

Finally, to turn this key holder in an IoT device, whenever a jack is inserted or removed, an MQTT message is published to the control unit, which can then visualise the status in OpenHAB. From there, rules can be associated to these events. What if the shed was opened while the key was still in place??

 

Enjoy the gallery illustrating the build process and final result, just after a quick explanation of the code!

 

Code

 

The code is straightforward, and using the GPIOZero library for the first time, made it even more simple! But basically, the four GPIO pins are checked in an infinite loop. Depending on the state, the matching LED is set or cleared, and an MQTT message is sent.

 

 

Gallery

 

{gallery} Key Holder

IMG_2222.JPG

Connectors: Four sets of connectors are used to connect the keys

IMG_2224.JPG

Headers: Using male headers, all pieces can be connected/disconnected easily

IMG_2225.JPG

Wiring: Testing the wiring. Ground is daisy-chained to all connectors

IMG_2250.JPG

Pi Zero: A Raspberry Pi Zero is used to keep everything compact

IMG_2251.JPG

Panel: Mounting the connectors and LEDs to an acrylic panel

IMG_2258.JPG

Assembled: The fully assembled electronics

IMG_2298.JPG

Hook: Twisting copper wire in a nice loop

IMG_2299.JPG

Soldering: Soldering the loop onto the connector

IMG_2289.JPG

Enclosure: Stacking and glueing pieces of wood to form an enclosure

IMG_2303.JPG

Finish: A bit of sanding and rounding of the edges

IMG_2308.JPG

Tadaaaa: The finished result on the cabinet

IMG_2306.JPG

Tadaaaa #2: The finished result on the cabinet

 

 


arrow_prev.png

 


Navigate to the next or previous post using the arrows.

arrow_next.png