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 |
---|
Connectors: Four sets of connectors are used to connect the keys |
Headers: Using male headers, all pieces can be connected/disconnected easily |
Wiring: Testing the wiring. Ground is daisy-chained to all connectors |
Pi Zero: A Raspberry Pi Zero is used to keep everything compact |
Panel: Mounting the connectors and LEDs to an acrylic panel |
Assembled: The fully assembled electronics |
Hook: Twisting copper wire in a nice loop |
Soldering: Soldering the loop onto the connector |
Enclosure: Stacking and glueing pieces of wood to form an enclosure |
Finish: A bit of sanding and rounding of the edges |
Tadaaaa: The finished result on the cabinet |
Tadaaaa #2: The finished result on the cabinet |
Navigate to the next or previous post using the arrows. |
Top Comments