When the correct code is entered into the lock, the key on the lower right will glow green and the screen will say Open. For educational use that's good. But for an action, such as opening a lock, additional hardware is required.

Optional Solenoid Lock Driver Circuit

The MacroPad has very limited digital input and output, mainly one STEMMA QT/Qwiic I2C connector on the left side of the keypad under the display. There are two signals, SDA and SCL for I2C, along with power and ground. 

The optional lock activation uses the SDA pin as a digital output line, in addition to the ground connection. It's non-standard to how things are to work for a STEMMA QT connection, but this use is electrically and programmatically just fine.

The circuit to take the digital signal and translate that into powering a higher voltage, high current lock/solenoid is shown below.

The SDA and Ground (Blue and Black, respectively) from the STEMMA QT connection are on the left. The digital signal feeds a TIP120 Darlington transistor at it's base through a 2.2K ohm current limiting resistor. The emitter from the transistor is grounded and the collector is connected through the solenoid to power. When the digital signal from the MacroPad SDA goes high, it triggers the transistor like a switch, sending power through the solenoid to ground, making the solenoid retract the bolt.

A 1N4001 diode is used across the solenoid. When the power no longer flows through the solenoid, a collapsing magnetic field will cause a reverse voltage. The reverse voltage flows through the diode and not the transistor, protecting the transistor from the dangerous spike.

Power Supply Requirements

The voltage and current in to the circuit via the jack shown should match the voltage and current requirements of the solenoid you use.

The Adafruit #1512 solenoid uses 9 to 12 volts DC and draws 650mA at 12V, 500 mA at 9V when activated (per the product page). I used a 9 volt, 1 amp supply as the current from the supply should be more than the maximum the solenoid needs (to keep the power supply from reaching it's maximum often, which would lowering its lifespan). Adafruit #63 works great.

If you decide on a 12 volt supply (which will retract the bolt a bit more forcefully), it needs 650 ma. The Adafruit #798 12V 1A supply would do well.

For high power/current needs

For any high power switching, you should consider two solutions:

For higher voltage DC devices, consider a circuit similar to the one above but replace the solenoid with a 9-12V relay. You can connect the relay outputs to a suitable lock and power source.

For wall power (mains, 110/230 volt), a relay with suitable output handling capabilities could be used. The safer alternative is to use a Controllable Four Outlet Power Relay Module version 2 - (Power Switch Tail Alternative). It will take the digital output from the STEMMA QT and switch several outlets (110 volt only).

Do not switch mains/wall power AC devices with wither microcontroller or transistor outputs, it will burn out your electronics and could start fires. Use a suitable isolation device like mentioned above, specifically designed to switch appliances with digital outputs.

This guide was first published on Sep 01, 2021. It was last updated on Jul 15, 2024.

This page (Lock Circuit) was last updated on Mar 08, 2024.

Text editor powered by tinymce.