Share:
Subscribe and receive the latest news directly in your email.

R&D&INew technologies

Internet of Things: A Case Study

The Internet of Things (IoT) is changing our environment to make it much more efficient. In the practical case we describe, we see how, through various techniques, M2M We solved an everyday problem.

Versión para impacientes

En el vídeo se ve cómo el móvil detecta que llegamos a casa y manda abrir la puerta del garaje. Sigue leyendo para ver cómo funciona!

Un caso práctico

María José y Alejandro viven en una casa en las afueras. Todos los días al llegar del trabajo con sus vehículos accionan el mando a distancia del garaje para aparcar. Desde hace algún tiempo estaba siendo necesario estar cada vez más cerca de la puerta para poder activarla. Eso los obligaba a detenerse en mitad de la calle esperando a que la puerta se abriese y congestionando el tráfico. Tras cambiar pilas en los mandos y verificar la antena del receptor de la puerta, se llegó a la conclusión de que se trataba de un problema de interferencias.

Describiendo la solución

La primera aproximación pasaba por cambiar la forma en que se accionaba la puerta. Las opciones eran distintas bandas de radio frecuencia o infrarojos, soluciones todas ellas que podrían verse afectadas por interferencias o corto alcance. Se optó por accionar el mecanismo de la puerta conectando ésta a Internet. Dicha solución sería óptima para resolver el problema del guiado físico añadiendo flexibilidad para dotar de lógica al sistema.

Hardware en la puerta del garaje

En cuanto al hardware, para poder ordenar la apertura y cierre de la puerta, tendríamos que proporcionar una pasarela entre la puerta e Internet. Nuestra opción será integrar en la placa del motor una plataforma que ofrezca lo siguiente:

  • Puertos de entrada y salida (mediante una placa con circuitería para controlar relés optoacoplados).
  • Conectividad TCP/IP.

Optamos por usar una Raspberry Pi. La Raspberry integra en una pequeña placa de 85 x 56 mm toda la funcionalidad requerida. Dispone de un procesador ARM de bajo consumo a 700 MHz. También está dotada de circuitería GPIO que permite interactuar con dispositivos externos enviando señales y capturando datos mediante unos pines soldados en la placa base. Otro aspecto importante de la Raspberry es su bajo consumo. Vamos a tener un dispositivo conectado 24h pero sólo consume 3,5 W/h.

Para la conexión eléctrica se dispuso usar circuitería con relés optoacoplados. Los relés evitarán que los picos de tensión pasen del motor a la placa base de la Raspberry y de ese modo conectamos dispositivos de 220V a nuestra placa de control.

raspberry-y-reles

Software en la puerta

Nuestro dispositivo conectado a la puerta debe estar dotado de un sistema operativo avanzado que nos provea de capacidad de programación en lenguajes de alto nivel. La solución elegida, RaspbianIt is optimal because we can choose between several languages ​​and because it gives the system a task plannerwhich, as we will see later, will be very useful to us.

To allow "talking" to the door, we will use web services RESTThree services have been programmed to open and close the door (POST) and to query the status of the opening and closing limit switches (GET). We have chosen Python for this. The syntax for the services to query the opening and closing status would be as follows:

Opening sensor

http://<dirección ip de la puerta>:8000/sensorA

Closing sensor

http://<dirección ip de la puerta>:8000/sensorC

Solutions to connectivity problems

One of the problems encountered was the occasional loss of connection. The link between the device and the router is established via a USB stick and has remained stable most of the time. However, in certain cases, the connection was lost, making it impossible to manipulate the door. To prevent this, we programmed a small script that checks if the network device is enabled and, if not, reactivates it. To launch the script, we used the operating system's scheduler with the following rule:

*/5 * * * * /usr/local/bin/WiFi_Check

On the device side

A first approach would be to manually operate the door using an app that allows us to open and close it by emulating a remote control. This is a simple and feasible solution, but potentially dangerous because it requires using a smartphone while driving. However, this solution was implemented as a tool to fine-tune the operation of the services, controlling how long a press should last, how to detect the opening and closing limits, and so on.

The solution we've proposed as the definitive one fits the definition of the Internet of Things. Our aim is for the system to be autonomous enough to require only a few minor configuration steps from us, and even though this might require more effort, it should be easy to use.

The solution we've proposed as the definitive one fits the definition of the Internet of Things. Our aim is for the system to be autonomous enough to require only a few minor configuration steps from us, and even though this might require more effort, it should be easy to use.

  1. Knowing that we are coming home.
  2. Interpret that we are arriving and not that we are passing nearby
  3. Saber que pese a ser el mismo camino, volvemos a casa y no partimos de ella.
  4. Discernir si llegamos en un vehículo o a pie.

Para saber que estamos llegando a un punto concreto hemos usado técnicas de Geofencing. El Geofencing o geolocalización por cercas supone un paso adelante en la localización mediante dispositivos móviles sin sacrificar la duración de su batería. Básicamente consiste en definir una zona junto con dos métodos que avisan de la entrada y salida en la misma. Nuestra aplicación, PathAct, permite definir hasta 20 geocercas o rutas posibles de aproximación a un punto. De este modo sabremos que estamos cerca de nuestro destino. Cumplimos la premisa número 1.

Una vez que el sistema detecta que estamos en esa zona, cambia su precisión para dar una ubicación lo más precisa posible. Ahora el problema será saber que estamos junto a la puerta. Si optamos por una comparación con la ubicación de ésta, puede darse el caso que en nuestra trayectoria pasásemos ocasionalmente junto a nuestra casa y se abra la puerta de forma involuntaria. Dejaría de cumplirse la premisa número 2.

Para solucionarlo, hemos definido un camino mediante tres puntos que siguen un orden. Al pasar de forma consecutiva por ellos, primero por el primer punto, después por el segundo y por último por el tercero, sabremos que estamos llegando al destino y no que pasamos junto a él. Esto nos permite cumplir la premisa 2 y al haber seguido el orden, cumplimos también la premisa 3 por la que sabemos que volvemos a casa y no salimos de ella.

Aquí surge un nuevo problema. Sabemos que si pasamos por los puntos en orden, se abre la puerta. ¿Cómo le decimos a la puerta que vamos en un vehículo y no a pie? La solución pasa por definir un tiempo de paso por los puntos y de ese modo, una velocidad que es factible alcanzar en un vehículo pero no caminando. Cumplimos también la premisa 4.

La implementación ha consistido en una aplicación iOS 7 con dos vistas, una para dar de alta las cercas o zonas y otra para marcar los caminos y el tiempo que tardaremos en recorrerlos. Se han aplicado las siguientes reglas de usabilidad para que la aplicación sea fácil de manejar:

  • El diseño trata de ser sencillo y sin información redundante.
  • El sistema ayuda al usuario a comprender, en caso de producirse, los errores que se desencadenan.
  • The elements of the different views are consistent with each other, so the user doesn't have to remember how to use them, but simply use them.
  • The application helps the user avoid errors by validating fields that require it and by automatically filling in as much data as possible.
  • The relationship between the system and the real world is maintained as much as possible, applying the user's language.
  • The application tries to maintain visibility of the system status at all times: the user is informed of what is happening at any time.

In the image below, we can see the two views that make up the application's interface. By clicking "Add Zone," we add a zone to be monitored. The zone is represented by its geographic coordinates and a unique identifier. In this same view, we can see the door's status: open. Indicador puerta abierta, operating Indicador puerta operando or closed Indicador puerta cerrada. We also have a key-shaped button to emulate the remote control. When pressed, we receive audible confirmation that it is working.

vista-1

In this screenshot we have a map to add the three points we must pass through to operate the door, a button to clear the map, and a scroll bar to indicate the time in which we must reach the three points in order to operate it.

vista-2

Access to the gateway itself would have to be done through a dynamic name resolution service. If we accessed it directly using the public IP address range, we would run the risk of it changing, leaving us without access again.

Possible improvements and developments

Simultaneous access: It's possible that two people with the app running might arrive at the same time: one would open the door and the other would close it. By checking the door's status, we can leave it open even if the open command has already been given.

Historical: The web service for opening the door could be modified to keep a historical record of door entries and exits, and the data could be used later.

Security: The door can be monitored while on vacation to detect any unauthorized openings, allowing you to alert the authorities. Photos can also be sent to the device on demand to ensure everything is working properly.

Linked services: Arriving home to an open door is convenient. But even more so is having the heating or cooling on, the food hot, the entryway light on, and so on. The door could communicate with other devices, giving them commands based on sensors installed throughout the house.

In Soltel Group We transform everyday objects into connected elements, applying our experience in BLE, NFC, RFID or WiFi direct technologies.

  • Data acquisition
  • Home automation
  • E-Health
  • Smart cities
Tags:
diygeofencinggeolocationhome projectsInternet de las cosasInternet of the thingsInternet of thingsiOSiotM2MMachine to machinemodRaspberry PiRaspberry relayREST

Other news