Introduction
Smart-homes are one of the most popular applications in IoT. It is very convenient when you can access your house information (and never wonder again whether the door was left open or the kitchen stove is on), and even have some basic automatic features implemented (temperature auto-set, lights off when they are not needed etc).
We implemented a prototype with these temperature and pressure recording system a few weeks ago (just to test if could have a simple MQTT architecture), with only some basic monitoring features. We want to add persistence to the system (a storing database), an actual interface and some remote capabilities. Also, new interesting devices can be included in the platform: a gas detector or a camera to be accesses when out of the home.
But wait... there is more: for this IoT challenge, we are also proposing a fun version of this IoT smart-house, where current inhabitants are not only treated as part of the system, but will also compete to be the number one.
The original platform is exercise oriented. We will implement first the simplest case: a running kind of competition. Here, each person will use their phones to track the miles they have run during the week, so the person with a higher number will get more points and a higher position in the general ranking. We can add some extra information, to get some variety: use the accelerometer/gyroscope of the phone or some other wearable devices (a wristband or a heart rate monitor for example).
Implementation
Firstly, we set up the smart home environment. The Raspberry Pi 3 will act as the central node of the implementation. It will be working as the main component of a smarthouse as well as the data collector of all the competition participants. Apart from its processing function, a display and interface will also be implemented, so that this central node can be a user’s access point as well.
Briefly, functions implemented by the central node/Raspberry Pi 3:
- Main bridge between platform and user. It will host a Graphical User Interface, with its corresponding functions.
- Smart-home central node, collecting sensors information and showing it on screen.
- Competition central node, collecting data from users and configuring the general ranking. This ranking will also be displayed.
Features to be included in the Pi:
- GUI itself
- Database, to store the incoming data
- Web server, to provide remote access to the service
- Corresponding hosts for the smart-home central node and the competition central node.
Apart from the central node, the platform will include the following components:
- Sensors and a sensor node (Raspberry Pi)
- Wearable devices and a mobile device to manage it (Smart-phone)
Smart-home
We will not only implement the competition game, but also some basic functions of a smarthome: temperature and pressure reading, a door sensor and a simple alarm button. In order to control all these sensors, we can use another Raspberry Pi to work as a sensor node.
In the end, the list of devices in the platform is:
- Central node – Raspberry Pi 3
- Sensors node – Raspberry Pi (with a WiFi dongle)
- Mobile user device – smartphone (with Android OS)
- Temperature sensor – TMP006
Pressure and altitude sensor MPL3115A2MPL3115A2
- Door sensor – usually closed magnetic switch
- Alarm button – usually open switch
There are two levels of communication in this platform:
1)Fetching data - wired connections.
Our proposed sensors will first connect to a “sensor node”, a Raspberry Pi. Depending on the sensors, they will be:
- Directly connecting to a GPIO port of the Pi. Such is the case of the door sensor and the alarm buttons (both of them acting as switches). The hardware implementation provides a 1 or 0 input in the GPIO (whether the switch is open or closed)
- Using the I2C protocol and the corresponding GPIO ports (SDA and SCL).
2) Distribution of data - wireless connections.
We will be using WiFi connection to implement the MQTT message protocol. This protocol is based on a client/ broker architecture. Clients are then divided in publishers (generating data) and subscriber (receiving the data they are interested in). The exchange between publishers and subscribers is done via the broker.
In this system, these elements are represented as:
- Broker - central node: Raspberry Pi 3
- Publisher - sensors node: Raspberry Pi
- Subscriber - user mobile device: Smartphone (in our case, Android). There is a secondary subscriber in the broker too (which will be doing the data recording)
With this structure, we were able to received the sensors data in both the broker and the smartphone in a continuous basis.
A security connection to he broker is still needed. We can crate a certificate authority in the broker, which will be generating certificates for all clients. In order for a connection to be accepted, the request needs to come with the adequate certificate. Distribution of certificates as well as the secure connection itself are the major challenge of this implementation.
As stated before, we will start by adding a data recording system: the main node will also have a database where sensors reading can be stored. In this same node, we can implement a secure web server, to access this stored data even if we are not connected to the home WiFi.
Moreover, we would include some monitoring functions: with a camera at the living room, to be turn on by the user (ideally, when they leave home), we could check what is happening int he house.
Competition game
With a smarthome implemented, we want to increase the reach of the platform. This way, our home users will not feel disconnected even when they leave the apartment. The proposed scenario is built as a runners competition kind of game: using the smart-phone information, our smart home will also define a ranking. They way any user can go up in this ranking is by running/walking more and more miles. As a result, the smart home capabilites will also be extended outside the house itself, to be able to follow our happy runners.
We will have a web server built on the Raspberry Pi(our home central node). Each smartphone device will have an application that:
- Monitors the user's run distance
- Sends that information to home, to the central node.
Furthermore, this central node will implement a simple routine to add the distance and display our inhabitants in decreasing order. This simple routine can further be extended (with some additional code in the phone to) to add some more challenging/original tasks: such as, assigning extra point to people going to certain areas (we will have to include geo location capabilities).
The former running game idea can be applied to other games as well: inside and outside the house. The same central node can run simple game application (for example, a detective kind of solve the mystery short challenge). We can build a simple autonomous (which will use some infrarred sensor to avoid collisions) mini car with the Raspberry Pi 2, that will leave its refuge at certain times and needs to be taken back to its original location. Even outside, the maps functionality can be used to motivate the users to visit new placed in their city, do some tourism... It can be targeted for kids (simpler in house games) or adults (as the runners app itself)
Conclusion
With this project, we want to implement a basic but fully functional smart house. To add an original feature, on top of the sensors reading and monitoring, we proposed a running competition among the habitants of the house.
This way, the main display of the smart home will show some house keeping data (such as temperature or pressure), but also the current status of the competition.
This same structure can also be applied to other types of games: have some games on the central node, enter a “city rally” discovery game ...
Top Comments