Apart from his role as a host for Element14 Presents, Clem Mayer also sells various goods through his online store and either ships them or allows people to swing by his house to pick them up. One downside, as Mayer quickly discovered, is that he has to be home whenever someone is there to retrieve their package, making it quite inconvenient. To solve this problem, he drew inspiration from the parcel lockboxes at his local post office to create his own version that could be unlocked with just a code. Secure Box
One of the most important aspects of this design ended up being how the end user would go about accessing the items within the box. At first, Mayer was thinking of a solution that involved scanning a QR code to access a website, entering some kind of code, and then submitting it in order to unlock the latch. However, this was considered far too complicated and even opened the door for potential hacking. The eventual idea was to simply have a keypad on top with a preset sequence of digits that could be sent in an email. Once entered correctly, the box would open and the items inside could be retrieved.
To implement this design, Mayer started by getting a sturdy metal electronics enclosure that also had a hinge for easy opening/closing. It came with the additional benefit of being IP66-rated, meaning that water and dust couldn't enter. The locking mechanism itself is an off-the-shelf latch that houses an internal 12V solenoid, which releases upon being powered, similar to a car door lock. Finally, the electronics consisted of an Arduino Leonardo microcontroller, a relay for outputting power to the solenoid, a 4x4 grid of pushbutton switches, and six LEDs to signal the current digit and if the code was correct.
The entire circuit revolves around the Arduino Leonardo, and the PCB reflects that with its similar shape and headers underneath. A solid-state relay was included for getting the low-power signal from the MCU's output pin to toggle the higher-powered current for the solenoid. A backup mechanical relay was also added as a backup. The set of 16 buttons were arranged in a matrix to cut the number of pins required from 16 down to 8. Last of all, each of the six LEDs at the top were connected to their own digital pin on the Leonardo.
Coming up with the program for the secure parcel box was fairly straightforward. The current button being pressed is detected by continually polling the rows and columns of the matrix and checking if one is set to low, where it's then mapped to a character. The program's support for dynamic codes necessitated the inclusion of the EEPROM library, as every newly set code is stored in non-volatile memory for later use- even if the system loses power.
Testing the project involved first setting a new code using the master passcode, then punching it back in to unlock the box. As seen in Mayer's video, the box works quite well at keeping the contents secure and safe from the elements, in part due to how external wiring/connections were kept to a minimum.
Box Lock Hackster.io, an Avnet Community © 2022