Smart Lock: Why Sloth Is A Driver of The IoT Progress

Smart Lock: Why Sloth Is A Driver of The IoT Progress

When you are sitting in your comfy chair in your cool modern office, anything distracting you from your favorite routine is really annoying. Some may call it a sign of sloth, but in fact, it relates to optimization of workflows. Our computers and smartphones provide us with many opportunities to do a lot without leaving our place. Software as such cares about our control over the physical world by just clicking and tapping. Indeed, the digitization advances: what people have had to do with their muscles for centuries in the past, could be done with either a voice command or a text message today thanks to numerous remotely controlled gizmos. And the IoT plays a crucial role in all this for a reason.


Let’s help door locks evolve

Take such a mundane action as opening a door. Nothing radically new has been invented with a basic design of doors over millennia. Neither different shapes nor applied materials can alter the main function of any door - to control every entrance and exit. What has been really changing with regard to the door functionality is the method how to fix doors opened and closed. People invented the door locks of various designs beginning from primitive deadbolts and up to hi-tech electronic locks with face recognition systems. The complexity of each contemporary design of a door lock depends on a particular procedure of entering a room: a bank vault must be more difficult to access than a college campus is.

Quite a logical idea to create a simple IoT solution for an office door lock is to come in mind of the IoT development company sooner or later. When the number of staff counts in dozens, an ordinary card reader in the door lock can play tricks on some forgetful developers who used to leaving their key cards at home from time to time. Since their colleagues are tired to interrupt their work for just assisting in opening an office door, the task to create a relevant IoT solution turns into a true motivation. However, the creative people can always exploit any situation to have fun and to reveal their creativity at the same time. Hence, quite an ordinary development procedure of creating a smart lock application was transformed by Indeema into a funny challenge to be solved through another Hackathon.


Everyone is welcome

One of the biggest advantage of the IoT solutions, when they are represented as tasks for Hackathons, is a diversity of the specialists who can be involved in a collaborative development. In contrast to many other purely software challenges, the IoT always requires hardware specs. In the IoT environment, the hardware components can oftentimes set the tone for the entire project. That’s why the Smart Lock Hackathon could hardly do without hardware engineers. And the hardware specs from various friendly companies were invited by Indeema - the more the better. And they arrived.

Of course, APIs, backend, a website, and a specific software that could serve the selected hardware all were in charge of the programmers who constituted the majority at the Hackathon. In addition, the designers were invited to create an attractive and user-friendly interface. Any IoT solution cannot avoid testing, that’s why testers and QA specs took part in the process. Besides, the other various team members such as sales managers, marketers, and even accountants participated in the event in order to reinforce the brainstorming because the generation of fresh ideas belongs to rather natural imagination than to some particular proficiency. By the way, Hackathon is a special class of the developers’ meetups where everyone can try new things and offer something different with no regard to any specific expertise. In other words, Hackathons were invented to boost creativity whatever forms it may take.


Why Hackathon?

The explosive combination of coffee, sweets, “Red Bull”, and the true drive of contest during the whole 24-hour non-stop session makes any Hackathon an extraordinary event for the developers whose routine should be periodically interrupted in a good way. Strong positive emotions along with an extremely informal atmosphere help people address many problems from a different angle. In addition, Hackathons can eliminate a distance between juniors and seniors, top managers and lower-level staff making the whole team work over a joint task without ordinary subordination. Something remotely similar was practiced in the ancient times when the nobles arranged special parties for their servants once a year. At such events, servants became equal to their masters calling them by names with no titles.

Needless to say that the very psychological emancipation taking place at Hackathons can reveal some creative capabilities that remain hidden when the mundane workflows run. If so, some may ask, why not arrange Hackathons as often as possible? The argument against it lies in the human psychology: we are getting used to anything practiced regularly. Both a stimulating effect and a fresh experience can quickly be offset by the recurrence. Which is why we enjoy holidays that happen only few times a year.


Initial conditions and hardware

An ordinary electromagnetic door lock is used as a standard solution in many office buildings. It is normally closed, and in order to open it, you should use either an RFID card from the external side (the very key card which is frequently left by the developers at home) or a button from the internal side. A simple relay could be connected to the button to make the lock get opened for a while. The relay in its turn should be controlled by a microcontroller (or a micro computer) which sends relevant signals. Raspberry Pi was chosen as the microcontroller which should control the relay after a verification of requests from a client application. The top entity in such a working algorithm is an application working with both iOS and Android operating systems. Hence, the entire smart lock project implies a complex hardware-software IoT solution which integrates various technologies such as web backend, clients for iOS and Android, embedded part in Linux, as well as various frameworks and Raspberry Pi specific libraries.


How the application works

The whole system consists of 3 custom developed applications:

  1. iOS client
  2. Android client
  3. Server

and one third party auth system - Redmine.

In order not to overload the application with redundant functions, only 3 screens were developed for its user interface: the main screen, the login screen, and settings. The smartphone-based remote door opener should be simple, right? The application is a server-client solution which uses the third-party authentication through the Redmine credentials of the company, as security us the most importat. After logging in, an individual API key of a Redmine user can be generated for sending to a server. The server verifies a particular API key figuring out whether it can access the company’s Redmine or not allowing, therefore, to open the door lock or not. The client-side application for iOS, for example, is a simple app written in Swift where 3D Touch is involved to facilitate the access. The feature which prevents an occasional door opening when a user is far from the office provides an additional pop-up table where a user can confirm the intention to open a door. The Android version of the application does not differ from the iOS one with regard to a general functionality. Hence, the final IoT solution provides users with an ability to enter an office with only a couple of taps on their smartphones.


Challenges and nuances of the development

Python was chosen as a programming language of a server part of the application. The choice was motivated by several considerations related to both quite a tight 24-hour period of the Hackathon and the ARM processor of the embedded target platform. The latter is a little bit inferior to x86 processors in terms of compilation and deployment. That’s why Python as an interpreted high-level programming language allowing to edit code on both a target platform and a host one was applied to run the application immediately for testing. Another reason for using Python was its standard library which could be easily extended with modules written in C to access various operation system features along with a call system service. Besides, a Python app runs as a Linux service when the operating system provides various facilities such as executing an app on startup, restarting when an app is crashed, perform an app as a background process etc. Thus, the advantages of Python have provided deploying the app to a target platform without a preliminary compilation of a source code into machine instructions.

Here is a principal scheme for our project.

In addition, the Flask web micro-framework was applied for deploying the Smart Lock application since the framework has minimum dependencies along with minimized requirements from the third party libraries for running server apps.

In terms of some specific means of programming used in the project, the RPi.GPIO library was applied in order to provide control over pin outputs on the target board Raspberry Pi 3. The library provides a straightforward way to manipulate physical pins on the board in only a few lines of code.


Back to sloth

Despite numerous biases, the “natural” human sloth is not always toxic when it comes to a technological progress. Does the Smart Lock application have sloth in its very background? It is questionable since just the dynamic Hackathon has generated such a viable IoT solution. However, the Smart Lock application as a direct result of that all-night-long development session can lead to the longest uninterrupted periods when Indeema developers need not leave their chairs anymore to let their forgetful colleagues in. Besides, there are many other types of physical activity than opening an office door. One thing is certain: the working efficiency of the developers will inevitably grow. Hence, both Hackathons and smart lock IoT solutions are highly recommended. And of course, Indeema is always glad to share the app’s code with every interested IoT professional:  https://github.com/IndeemaSoftware/SmartLock

You can also read about our SmartLock on Hackster.

Tags: IoTSmartLock

Subscribe to start receiving notifications about new posts

and monitoring social networks

<?xml version="1.0" encoding="utf-8"?>