As the popularity of BLE-Link, one idea of hacking the electromagnetic lock using Ble-link came into my mind, challenging me in both the aspect of hardware building and Android programming. Several applications based on Smart Phone BLE-Link have already entered into the market, most of which can be seen Kick-starter and some other crowd funding platforms.
Step 1: Testing relay control by Arduino
What I planned to hack is the access control which is common in today’s office building. The electromagnetic characteristic of the access control makes it easy to design the actuating part. In fact, it could be transformed to a relay control problem. So the bottom part of the project is simply a control unit controlling the relay. As shown is a test for relay control using Arduino UNO, where the yellow led is to represent the switch-on state of relay.
Step 2: Testing communication between BLE-Links
Okay, next is the key for communication. I used two modules to test the BLE-Link communication, as shown in the picture below. One is Bluno, which is Ble-link built in. The other is the combination of Arduino UNO and Ble-link. The Ble-link usually has two modes including central and peripheral roles, which needs to be programmed with AT commands. For a Smart Phone, it is always plays a central role. Thus the Ble-link connecting the relay is naturally playing a peripheral role.
Step 3: Soldering together
It seems that all the test for hardware had been completed. Yet the size was not satisfied. For this very single use, a miniature version of Arduino, Beetle is totally recommended. Finally, I soldered or connected Beetle, relay and Ble-link together on an empty board, as shown in the pictures.
Step 4: Development of Android APP as a client end
The final step was programming the Android client end for the BLE-Link control, which might be the most challenging part since I had never experienced java or Android programming. The great resource of Android greatly helped my learning and development. I developed my very first version of Smart Lock app based on a resource code, BlunoBasicDemo, from github, also accessible in DFRobot.com. The UI of the app is as shown in the pictures. When you need to open the specified door, you are indicated to connect the BLE-Link device connected to the door with pressing the Scan Button, input the right password and press the Verify Button to unlock it.
Step 5: 3D printed outside
And a cover was best needed. I modeled and 3D printed a simple box for this Smart Lock.
Step 6: Extra update for distance based switch
Until here, it should be enough to control an electromagnetic lock. However, some of the users were complaining about the multi-steps using the app. So I continued to update the app to the 2.0 version, which uses a rough distance sensing to control the lock. Once working, the app using the Ble-link to sense the rssi value with the one connected to the door every 10 seconds. It would try to build connection when in the desired radius, 3 meters round, and send the open-door command accordingly. In other words, all the steps that was once for user click are transformed to be automatic ones. The process is shown in the pictures.
While the relay is switched on, the Ble-link would feedback a message “Turn on Relay” to be shown on the Smart Phone and the relay would keep on for seconds. And then the relay would be switched off and feedback a message “Turn off Relay” to be shown on the Smart Phone.