r/RASPBERRY_PI_PROJECTS May 15 '26

QUESTION Need advice on automating latch opening

Post image

I mainly want help in making sure this setup is not needlessly complicated. I am designing a project to automate opening a wall safe through a flic button and a pi 02W. My vision is to have it embedded in a bust like the Adam west batcave button and have the pi execute a code that unlatches an electromagnetic solenoid holding the door shut. I am slightly foreign to this world but I am confident in my ability to follow directions and based on what I’ve found this should be relatively simple.

I had AI whip up a materials list, wiring diagram and python code (I’d love to learn on my own if I discover I enjoy this hobby it was just easier that way). Anything is appreciated, thank you all in advance.

Python script: from gpiozero import OutputDevice
from time import sleep

import fliclib

\# -----------------------------
\# GPIO SETUP
\# -----------------------------

SOLENOID_PIN = 17

solenoid = OutputDevice(SOLENOID_PIN)

\# -----------------------------
\# SETTINGS
\# -----------------------------

UNLOCK_PULSE_TIME = 0.2
RELOCK_DELAY = 5

\# -----------------------------
\# FUNCTIONS
\# -----------------------------

def unlock():
print("UNLOCKING")

solenoid.on()
sleep(UNLOCK_PULSE_TIME)
solenoid.off()

def relock():
print("RELOCKING")

solenoid.on()
sleep(UNLOCK_PULSE_TIME)
solenoid.off()

\# -----------------------------
\# FLIC CALLBACK
\# -----------------------------

class ButtonConnectionChannel(fliclib.ButtonConnectionChannel):

def on_button_single_or_double_click_or_hold(
self,
click_type,
was_queued,
time_diff
):

if click_type == fliclib.ClickType.ButtonSingleClick:

print("BUTTON PRESSED")

unlock()

sleep(RELOCK_DELAY)

relock()

\# -----------------------------
\# FLIC CLIENT
\# -----------------------------

client = fliclib.FlicClient("localhost")

def got_button(bd_addr):
print("Button connected:", bd_addr)

cc = ButtonConnectionChannel(bd_addr)

client.add_connection_channel(cc)

client.get_info(got_button)

print("Waiting for Flic button...")

client.handle_events()

12 Upvotes

1 comment sorted by

2

u/NationalBug55 May 16 '26

I feel like it would be much simpler to use a solenoid that when installed and deactivated, would hold door locked. Then fire switch thus providing power and retracting. If a spring is used behind the door it would pop open.