Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Build a Smart Auto‑Locking Door Using Your Smartphone’s Bluetooth Proximity

Looking for a reliable, tech‑savvy way to secure your home office or private workshop? This guide walks you through creating a DIY smart lock that automatically detects your presence via Bluetooth and locks the door when you step away.

The Concept

Your smartphone constantly broadcasts a unique Bluetooth identifier when in discovery mode. By monitoring this signal with a Raspberry Pi, we can determine whether the device is within range and trigger a relay to lock or unlock the door accordingly.

What You’ll Need

Getting Started with Bluetooth

First, install the necessary Bluetooth packages on your Pi. You can do this directly on the device or via SSH.

sudo apt-get install bluez python-bluez

Insert the dongle and verify it’s recognized:

hcitool dev

Next, grab a sample Python script to discover nearby devices:

wget https://pybluez.googlecode.com/svn/trunk/examples/simple/inquiry.py
python inquiry.py

If the script reports “0 devices found,” ensure your phone is in discovery mode. On an iPhone, open the Bluetooth settings page to enable it.

Creating the Detection Script

Create a file named detect.py and add the following code. Replace the MAC address with your phone’s identifier.

#!/usr/bin/python
import bluetooth
import time

while True:
    print("Checking "+time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime()))
    result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)
    if result:
        print("User present")
    else:
        print("User out of range")
    time.sleep(10)

Run the script to see real‑time status updates. The 10‑second interval balances responsiveness with power consumption. If battery life is a concern, consider adding a switch that disables the loop while you’re inside.

GPIO Board Modes

Choose a pin numbering scheme that matches your hardware. The “board” mode uses the physical pin numbers, while “BCM” (Broadcom) refers to the GPIO channel numbers. I’ll use BCM in the examples below, which aligns with most breakout boards.

Wiring the Relay

Connect the breakout board to the Pi: 3.3 V and 5 V pins to the relay’s VCC and GND, respectively. Wire GPIO 23 to the relay’s input. Verify the relay’s logic level requirements; many accept 3.3 V signals directly.

To test the relay manually, install wiringPi and configure GPIO 23 as an output:

git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
gpio -g mode 23 out

Confirm the pin status:

gpio -g readall

When the relay clicks, you’re ready to integrate the lock. Keep the lock’s power supply separate from the Pi’s power rails.

Next Steps

Combine the detection script with GPIO control logic to trigger the lock when the phone is out of range. Test thoroughly in a controlled environment before deploying.

Manufacturing process

  1. Inside Bank Vaults: History, Design, and Future of Security
  2. Inductive Proximity Sensor: Circuit Design, Functionality, and Practical Applications
  3. Control an LED via Bluetooth with Arduino – Simple DIY Guide
  4. Smartphone‑Controlled Bluetooth Mouse: Build Your Own Virtual Joystick
  5. Arduino Keypad Door Lock with User-Defined Code
  6. Contact‑Free Faucet with Door‑Activated Control – Safe & Smart COVID‑19 Solution
  7. Build an IR Sensor Project with Arduino UNO – Simple Guide
  8. Secure Arduino‑Based Keyless Door Lock with LCD Display and 4×4 Keypad
  9. Build an Arduino RFID Door Lock – Master RFID Technology with a Step‑by‑Step Guide
  10. Build an Arduino Proximity Sensor: Step‑by‑Step Guide with Components