Oursky IoT doorlock system.
(drawn using GNU Dia)
Circuit diagrams are drawn with this Circuit Simulator.
Diagrams are saved as txt
files, you can import them under File > Import From Text
.
Connections:
- Release Button: GPIO0/Ground
- Release Signal: GPIO1/Ground
System: ArchLinux ARM
Enable Watchdog:
[~/]$ pacman -S watchdog
[~/]$ systemctl enable watchdog
[~/]$ systemctl start watchdog
# /etc/watchdog.conf
ping = 127.0.0.1
max-load-1 = 24
watchdog-timeout = 10
watchdog-device = /dev/watchdog
realtime = yes
priority = 1
Responsible for interacting with hardware connected to the Pi. Exposes a HTTP API listening on 127.0.0.1:8090
, any requests sent to this socket will trigger an unlock. An optional header X-Source
can be sent to identify the triggering source (e.g. Bluetooth LE). Written in clojure, runs on JVM.
System: ArchLinux ARM
Enable Watchdog:
[~/]$ pacman -S watchdog
[~/]$ systemctl enable watchdog
[~/]$ systemctl start watchdog
# /etc/watchdog.conf
ping = 127.0.0.1
max-load-1 = 24
watchdog-timeout = 10
watchdog-device = /dev/watchdog
realtime = yes
priority = 1
Responsible for interacting with hardware connected to the Pi. Exposes a HTTP API listening on 127.0.0.1:8090
, any requests sent to this socket will trigger an unlock. An optional header X-Source
can be sent to identify the triggering source (e.g. Bluetooth LE). Written in clojure, runs on JVM.
Build Dependencies:
- leiningen
Build:
[~/]$ git clone ...
[~/doorlock/daemon-doorlock]$ lein uberjar
The compiled JAR is now in daemon-doorlock/target/doorlock-<version>-standalone.jar
.
Runtime Dependencies:
- java
- wiringpi-git (AUR)
Install as systemd service:
- copy the compiled JAR to
/home/oursky/doorlock.jar
- copy
doorlock.service
to/etc/systemd/system/
- enable and start the service:
[oursky ~/]$ sudo systemctl enable doorlock
[oursky ~/]$ sudo systemctl start doorlock
Note: If your username is not oursky
, you need to edit doorlock.service
accordingly.
Running this service, the rpi would act as peripheral and advertise. You would need to connect to the device and write a generated time-based token to service 'fff0' characteristic 'fff0' to unlock.
Runtime Dependencies:
- bluez
- pi-bluetooth (AUR)
- nodejs
- npm
Install as systemd service:
- copy
index.js
andpackage.json
to/home/oursky/ble
- copy
[email protected]
to/etc/systemd/system/
- setup, enable and start the service:
[oursky ~/ble]$ npm install
[oursky ~/ble]$ sudo systemctl enable doorlock-ble@<your-secret>
[oursky ~/ble]$ sudo systemctl start doorlock-ble@<your-secret>
Listen for unlock requests from Skygear ...
Allow end users to trigger an unlock from a mobile device. Written using clojurescript on react-native.
Dev Dependencies:
- leiningen
- npm
- re-natal (from npm)
- react-native-cli (from npm)
- android SDK (must set env
ANDROID_HOME
) - android platform tools (adb)
- XCode (with CLI tools)
- rlwrap (optional, for figwheel REPL)
Android Development:
[~/doorlock/opensky/]$ npm install
[~/doorlock/opensky/]$ npm start # start react-native packager
[~/doorlock/opensky/]$ rlwrap lein figwheel android # start figwheel dev server
[~/doorlock/opensky/]$ react-native run-android # deploy app
[~/doorlock/opensky/]$ adb reverse tcp:8081 tcp:8081 # connect react-native
[~/doorlock/opensky/]$ adb reverse tcp:3449 tcp:3449 # connect figwheel