-
1Step 1
The Servo Motor
These motors turn using PWM signals. Our servo expansion has a pwm-exp function that can be used to generate these pulses. Most deadbolts lock and unlock at 90 degrees so modifications are not usually necessary. If your lock has to turn more than 180 degrees, you may want to modify your motor for continuous rotation.
-
2Step 2
The Motor Casing
You will need a way to attach your motor to your door and `turn the lock. You can make a casing for the motor that can attach to your door and hold the motor in place. A small piece of plastic in the shape of the lock's bar should be attached to the motor.
An easy way to obtain these is to 3D print them. These are the models we are using.
-
3Step 3
Storing lock state using UCI
OpenWRT is installed on the omega so you are able to use UCI to store configurations on the omega. So, we will use this to store the status of the lock. If your lock needs to turn more than 180 degrees, this would prevent the motor from applying a force on already locked/unlocked doors.
-
4Step 4
Controlling your servo through ubus
We will use the ubus to run commands from the app.
To setup a new ubus service, navigate to the rpcd directory on your omega:
cd /usr/libexec/
and create a new ubus service:
cat > onion-lock
then fill it in with the ubus service code, found on our GitHub repo.
For more information about the ubus, please take a look at our ubus tutorial series.please take a look at our ubus tutorial series.
-
5Step 5
Adding ubus Permissions
In order to run ubus commands outside of the terminal, you must first include the functions in the ubus permissions file. Go to the permissions directory:
cd /usr/share/rpcd/acl.d/
In onion-console.json, add your ubus functions under read:ubus: and write:ubus:
-
6Step 6
Create an app
Having an app to request functions is a lot easier and has a better UI than the terminal. There is an app template at /www/apps/ which you can use to build an app. Copy the onion-template folder and give it an app name. Edit the app.json and icon.png files to register it. Set the icon value to “true” for your app to show up on the console.
Our example code for the app is located on GitHub. We are using the Polymer framework to create an HTML element. You may look in the files of other apps to see how your code should be organized.
This is what the UI looks like.
-
7Step 7
Complete!
You are now finished. Attach your motor to your door and test it. Don't forget to reboot your omega!
Simply press the buttons on your app to tell the servo to lock or unlock your door.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.