Skip to content

Instantly share code, notes, and snippets.

@jamesabruce jamesabruce/lock.py
Created Jul 14, 2015

Embed
What would you like to do?
DIY Proximity Lock v.01
#!/usr/bin/python
import bluetooth
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
RELAY = 23
GPIO.setup(RELAY, GPIO.OUT)
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 != None):
print "User present"
GPIO.output(RELAY,1)
else:
print "User out of range"
GPIO.output(RELAY,0)
time.sleep(10)
@toshibochan

This comment has been minimized.

Copy link

toshibochan commented May 9, 2016

Hi thanks for make great codes! I have request. You think you can add proximity? For exemple I want open the door only when I very close. And how I can add more devices to the code? For exemple I want add iPhone and Apple Watch and other people phones.

@vswraith

This comment has been minimized.

Copy link

vswraith commented May 20, 2017

+1 would love to get distance as well

@floripaolo

This comment has been minimized.

Copy link

floripaolo commented Jun 9, 2018

HI! Thanks for this idea! How would you add more than one phone that triggers the relais?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.