• Keine Ergebnisse gefunden

An ecosystem enabling user-in-the-loop demand control in telecommunication andutility networks

N/A
N/A
Protected

Academic year: 2021

Aktie "An ecosystem enabling user-in-the-loop demand control in telecommunication andutility networks"

Copied!
100
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Masterthesis

Jaume Soler

An ecosystem enabling user-in-the-loop demand

control in telecommunication and utility networks

Fakultät Technik und Informatik Department Informations- und Elektrotechnik

Faculty of Engineering and Computer Science Department of Information and

(2)

Jaume Soler

An ecosystem enabling user-in-the-loop demand

control in telecommunication and utility networks

Masterthesisbased on the study regulations for the Master of Engineering degree programme Master Informations- und Kommunikationstechnik

at the Department of Information and Electrical Engineering of the Faculty of Engineering and Computer Science

of the Hamburg University of Aplied Sciences

Supervising examiner : Prof. Dr. -Ing. Rainer Schoenen Second Examiner : Dr.Ing. Aining Li

(3)

Jaume Soler

Title of the Masterthesis

An ecosystem enabling user-in-the-loop demand control in telecommunication and utility networks

Keywords

Resources, Smart Home, Smart Grid, Gateway, Controller, Sensor, Actuator, Protocol, Device, Server, Consumption, Water, Energy, User-in-the-Loop

Abstract

During the last decades the increment of the demand of scarce resources has incre-ased in a dramatic way. Both water and energy have being exploiting irrationally, in addition with the climate change is leading us to an uncontrolled and unhealthy situa-tion. In this research, a tool for Smart Home environment is presented whose aim is to be a first step to responsible each consumer in a household for its consumption. A whole system with sensors, gateway, actuators, servers etc. is going to be presented. As well as, the User-in-the-Loop paradigm will offer the possibility to take the blame the final user of its actions through a set of feedbacks.

Jaume Soler

Titel der Arbeit

Ein Okosystem zur Bereitstellung der User-in-the-loop Nachfrageregelung in Telekommunikations- und Versorgungsnetzen.

Stichworte

Ressourcen, Smart Home, Smart Grid, Gateway, Steuerung, Sensor, Aktor, Protokoll, Gerat, Server, Verbrauch, Wasser, Energie, User-in-the-Loop

Kurzzusammenfassung

In den letzten Jahrzehnten hat die Zunahme der Nachfrage nach knappen Ressour-cen dramatisch zugenommen. Sowohl Wasser als auch Energie haben sich irrational ausgebeutet, und der Klimawandel fÃ14hrt uns zu einer unkontrollierten und ungesun-den Situation. In dieser Untersuchung wird ein Tool fÃ14r Smart Home-Umgebungen vorgestellt, dessen Ziel es ist, einen ersten Schritt zu unternehmen, um jeden Ver-braucher in einem Haushalt fÃ14r seinen Konsum verantwortlich zu machen. Ein gan-zes System mit Sensoren, Gateway, Aktoren, Servern etc. wird vorgestellt. DarÃ14ber hinaus bietet das User-in-the-Loop-Paradigma die Möglichkeit, den Endnutzer sei-ner Aktionen durch eine Reihe von Feedbacks zu beschuldigen

(4)

Acknowledgment

Foremost, I would like to express my gratitude for my project advisor Prof. Dr. -Ing. Rainer Schoenen. Thanks for giving me the opportunity to make my project and for all the correc-tions and assistances necessary to go forward.

Besides my advisor, thanks to the students of the Faculty of Engineering and Computer Science from the HAW Hamburg for their developed projects, opinions and ideas in the de-velopment of this research.

And last but not least, I would like to thank the support received by the people from Hamburg which made me feel these months as in home. Thanks for everything.

(5)

Contents

List of Tables 7

List of Figures 8

1 Introduction 11

2 Motivation 13

2.1 World point of view . . . 14

2.1.1 Water and energy consumption . . . 14

2.2 Household view . . . 17

2.2.1 Water and energy consumption . . . 17

2.3 Problems with demand of water and energy . . . 19

2.4 Household area consumption . . . 20

2.5 The Smart Grid concept . . . 24

2.5.1 Energy and Water price model . . . 25

3 Smart Home concept 28 3.1 Gateway or Hub . . . 30

3.2 Smart Sensors and Actuators . . . 31

3.3 Communication . . . 36

4 Principle of the User-in-the-loop paradigm 38 4.1 Background . . . 38

4.1.1 Spatial Control . . . 40

4.1.2 Temporal Control . . . 40

4.2 Benefits . . . 41

5 User-in-the-loop in utility networks 42 5.1 Description of the idea . . . 42

5.1.1 Psychology and economical perspective . . . 43

5.1.2 List of feedbacks . . . 44

5.1.3 Example of sensors and actuators . . . 48

(6)

Contents 6

5.2 Authentication, Authorization and Accounting (AAA) . . . 55

5.2.1 Authorization of the user . . . 55

5.2.2 Authentication of the user . . . 56

5.2.3 Accounting the user consumption . . . 59

5.3 Real Case Concept System Design . . . 60

6 Implementation of the whole system 62 6.1 Gateway . . . 62

6.2 Daemon communication . . . 66

6.2.1 TCP/IP Connection . . . 69

6.2.2 UNIX domain socket . . . 70

6.3 Sensor Communication . . . 71

6.4 XML Files . . . 72

6.5 Water and Energy pricing . . . 76

7 Details of implementation 79 7.1 Protocols and diagram . . . 80

7.2 Messages and frames . . . 86

7.2.1 Communication between front-end-device and gateway . . . 86

7.2.2 Communication between sensors and gateway . . . 89

8 Evaluation 91 9 Conclusion 93 9.1 Summary . . . 93

9.2 Outlook . . . 94

(7)

List of Tables

2.1 Simulation of a household water consumption. . . 21

2.2 Simulation of a household energy consumption. . . 22

2.3 Simulated price of Germany and USA cases. . . 23

3.1 Different examples of Hub or Gateway in the market. . . 30

3.2 Summary protocols in Smart Home systems and their main features. . . 36

5.1 List of feedbacks part 1. . . 45

5.2 List of feedbacks part 2. . . 46

5.3 List of feedbacks part 3. . . 47

5.4 List of feedbacks part 4. . . 47

5.5 Table of the different user roles. . . 56

5.6 Some authentication ideas for the system. . . 57

(8)

List of Figures

2.1 Layered analyzed structure. . . 13

2.2 Water and energy consumption in the world. . . 14

2.3 Current and future population in Africa suffering drought. . . 15

2.4 World population growth, 1750-2100. . . 16

2.5 TEP world map. . . 16

2.6 (a) Energy consumption world map. (b) Cents per kWh (2011). . . 17

2.7 Consumption and price of water per country. . . 18

2.8 Global warming map. . . 19

2.9 World electricity production. . . 20

2.10 Whole Smart Grid scheme. . . 25

2.11 Example of a Smart Meter used in Smart Grid systems. . . 26

2.12 Peak zones in a daily dynamic pricing in Spain. . . 27

3.1 Complete scheme of a Smart Home environment. . . 28

3.2 Scheme of sensors inside a Smart Home environment. . . 31

3.3 Process of sensor and actuator with gateway. . . 32

3.4 List of sensors part 1. . . 33

3.5 List of sensors part 2. . . 34

3.6 List of sensors part 3. . . 35

4.1 Close loop applied in User-in-the-Loop paradigm. . . 39

4.2 Graphical User Interface of a UIL implementation suggesting a spatial change. 40 5.1 UIL close loop in a utility network in household. . . 43

5.2 Current and proposed pay-bill model. . . 44

5.3 Smart Thermostat developed by Bent Alexander Haase. . . 50

5.4 Smart Energy Meter developed by Cristian Zara. . . 52

5.5 Smart Flow Meter developed by Cristian Zara. . . 53

5.6 Android Application interface listing a set of devices and its information. . . . 54

5.7 Key ring for RFID authentication. . . 58

5.8 RFID Reader for Windows System. . . 58

5.9 RFID module for Arduino. . . 58

(9)

List of Figures 9

5.11 Cost equation. . . 59

5.12 Complete ecosystem in a real household scheme. . . 60

5.13 Flow process of the system. . . 61

6.1 RFID Access control device and tag. . . 63

6.2 RFID Access control device and tag. . . 64

6.3 Gateway: RPi3. . . 65

6.4 Gateway: RPi3 Screen. . . 65

6.5 List of connections in the socket_server code. . . 66

6.6 (a) Socket connection. (b) Socket connection with server loop. . . 67

6.7 Select() loop in socket_server code. . . 68

6.8 (a) Establishment of a TCP connection. (b) Connection with the master outside server. . . 69

6.9 (a)Creation of UNIX socket. (b) Connection with the master RANET Daemon. 70 6.10 MQTT principle. . . 71 6.11 Devices XML file. . . 73 6.12 Hierarchical XML file. . . 73 6.13 Roles XML file. . . 74 6.14 States XML file. . . 74 6.15 User XML file. . . 74

6.16 XML parser and storage of the data. . . 75

6.17 CGI principle. . . 76

6.18 CGI script for the real-time energy price consulting. . . 77

6.19 Variation of the energy price in Spain from October 2017 to January 2018, updating every minute. . . 78

7.1 Protocol of the device registration. . . 80

7.2 Dialog between device and server for its registration in the system. . . 81

7.3 Dialog between phone and server. . . 82

7.4 Dialog between phone and server for the user registration. . . 83

7.5 Complete dialog of the system for the UIL process. . . 84

7.6 Complete diagram of the project with UIL principle. . . 85

7.7 Method responsible of process the input messages. . . 87

7.8 Method responsible of the automate transmission of messages. . . 88

7.9 Method which reads the binary messages from the sensors. . . 89

7.10 Frame of a sensor transmission. . . 89

7.11 MAC Frame information. . . 90

7.12 Data Frame parts. . . 90

7.13 Commands designed for the sensor data frame. . . 90

(10)

List of Figures 10

8.2 Screenshot of the server broadcasting. . . 92

(11)

1 Introduction

We live in a world with 7.000 million of population which need some essential elements to survive. During all the evolution of the humanity we have learnt how to exploit these resources, more and more. Unfortunately, these resources are not infinite and now we have to try to minimize its consumption and to teach how save it to the future generations.

Water and energy are two examples of these mandatory elements in our lives and the overex-ploitation of them is leading to a very critical situation. Water is the most important substance for us, it is required for our agriculture and ranching, for the energy generation itself and of course, for the substance of our organism. Sorrowfully, it is constantly degraded by factories, uncontrolled use in home environments and the pollution. This is reaching us to an alarming situation because of the so high decreasing of fresh water in our world; moreover, the water polluted is destroying the natural habitat for a lot of plants and animals.

At this high-evolved point of the technological era, it is necessary to think, teach, develop and apply different solutions and technique to learn to save and control in a very intelligent and rational way our more valued resources, from a global to local point of view. From the industries to the final user day-to-day.

The thesis topic wants to follow this necessity and aims at offering a good tool to help the final user to save and control its consumption in a friendly and dynamic way for the Smart Home environment.

The main idea of this project is to apply the paradigm of User-in-the-loop in a whole system for the monitoring and controlling of the energy and water consumption in the households. The system will offer some instructions and notifications for the best usage of the resources to the final user. By doing this the final user will get a feedback about how much it is being consumed and how much it can be saved, in kWh and Euro, depending on the decisions that he makes. The final aim of it, is to be able to reduce the consumption and to take on responsibility and to motivate each member of the home for its usage and its expense.

(12)

1 Introduction 12

During the research will be described all the elements, communication schemes, data stores and different use of cases, among other things which form the whole environment. As well as, it will be defined the different ways that the user will be notified about the house-consuming, resulting in a complete Smart Home feedback system loop.

(13)

2 Motivation

There are some reasons which form the motivation for the developing of a tool for the saving of the energy and water consumption. From the urgent necessity of using the resources in a rational way to the implementation of new concepts such as, Smart Homes and Smart Grid. In the following sections, they are going to be explained and it will be allow to see how with a merge of them it is possible to offer a good and a promising solution for the household’s savings.

The main objective of this chapter is to analyze the consumption from the industry sector to the final customer of water and energy. As well as, it pretends to study and to raise awareness the necessity of change our way-of-doing relative to the usage of resources. In addition, the big role of the Smart Home concept in this kind of research is going to be explained. For this reason, this first contact with the project is layered from a top of down approach; from the factory environment to the device one.

(14)

2 Motivation 14

2.1 World point of view

Since the appearance of the first human proof in the world, water and later on energy have been two of our main survival pieces. These resources have been used for different pur-poses: industry, agriculture, ranching, domestic use etc. For this reason, a large quantity of techniques to exploit them have been developed. This irrational usage added to the ex-ponential growth of population lead to our resources into a dramatic situation. In the follow-ing section, different statistics about the consumption of scarce resources are gofollow-ing to be shown.

2.1.1 Water and energy consumption

As shown in the following figures, the consumption of water and energy is continuously in-creasing from the 90s. The manufacturing and domestic usage will increase by around 50% by 2050. In Figure2.2, it can be seen how in a not so far future the demand of water around the world is reaching the 5500 km3 per year while in the 2000s this value was 2000 km3 lower. This disproportionate usage of water added to the global warming is leading us to a danger situation. According to a NASA research, 21 of the world’s 37 biggest sources of drinking water are on the verge of disappearing.

(a) (b)

Figure 2.2: Water and energy consumption in the world.

(15)

2 Motivation 15

1.216 million of population and this value will be increased to 2.069 by 2050. According to the ONU, just 30% of the population in the Sub-Saharan region have access to a hydric sanitation. This is the reason of death of 115 African each hour due to the non-access to a good sanitation and drinking water. As well as, the water demand in Africa between 2005 and 2030 will increase by 283%, three more times than the rest of the region. As shown in Figure2.3, in Africa there is a very high amount of people suffering serious problems of drought and this problem does not show to be improved by 2050. The storage capacity is about 200 cubic meters per person per year while in North America this value reaches the 6.000 cubic meter. All these factors lead to the continuously decrease of the African quality of life, now and for the next generations.

Figure 2.3: Current and future population in Africa suffering drought.

As with the water case, as Figure2.2shows, the energy consumption growth has increased in a very drastic way in the last 10 years. Even with the economic crisis, the G20 countries have increased them consumption by 5% between 2009-2010. As well as, in the recent years some regions such as, Asia and Oceania have raised its demand very dramatically due to the excessive growth of population.

(16)

2 Motivation 16

According to the figure behind, the world population has changed from 0.9 billion in 1800 to around 7.4 billion in 2015. As well as, our quality of life is completely connected with the energy consumption. The TOE is the "tonne of oil equivalent" and shows the amount of energy released by burning one tonne of cruide oil, approximately 11.630 kWh. This value represented in Figure2.5, shows how in some regions such as India or Pakistan have 0.8 TOE per inhabitant per year, in comparison with the more than 6 TOE per inhabitant per year in the EEUU. Taking this into account, it is reasonable to think that a decreasing of the energy supply around the world will reduce a lot the quality of life in the poor-TOE-regions.

Figure 2.4: World population growth, 1750-2100.

(17)

2 Motivation 17

In conclusion, analysing the values shown in this section, we should to be able to reconsider and to think about the urgent necessity to change our way of thinking and our lifestyles, not only reducing the consumption of our resources but to share them in a fairly and respectful around the world regions.

2.2 Household view

Once known the current consumption situation in a world scale, it is important to analyse how much blame have the people inside their households. This sections shows the amount of resources used inside a home and a brief study about the consumption per device has been developed.

2.2.1 Water and energy consumption

As shown in the figures below, not only the consumption of water and energy depends on the country but the price of them varies too. Regarding energy households consumption, USA, Canada and Australia have the more elevated consumption with values from 12000 to 7000 kWh, respectively. Afterwards comes Europa with an average usage of 3.600 kWh. This is generally because European houses are quite small, the heating is done with gas and the air conditioning is not widespread.

(a) (b)

(18)

2 Motivation 18

In Figure6.9 is shown the price in cents of dollar per kWh depending on the country. This variation is caused by the price of the combustible used for the energy generation, the current governmental and industrial politics and by the local climate in the region. If this figure is overlapped with the previous graph about the energy consumption by household, it is interesting to realise how Canada and USA, the two more consumer countries in the world have the lower energy price, less than 12 cent/kWh, in comparison with Spain, Denmark or Germany whose prices are higher than 30 cent/kWh.

In the same way than the energy, the water consumption depends on the country and its price vary noticeably. Even changing from energy to water, USA and Canada keep leading the ranking of resource consumers and again both countries have the less price for them. In terms of consuming, these countries are followed by hot regions in the south of Europe, such as Spain and Italy. Regarding the price per m3, Germany, Belgium and France pay 4 and 3 times more than USA and Canada.

Figure 2.7: Consumption and price of water per country.

After analysing the household consumption per country both energy and water cases, it can be seen how in general, a higher price on average brings less consumption. At this point, two countries can be taken into account: USA and Germany. These two cases are the example of how the elevated prices in Germany lead to a very less consumption of the resources. On the other hand, USA with the less prices both in water and energy, presents the higher levels of consumption. This can reveal that a modification of the prices could help for the saving of scarce resources.

(19)

2 Motivation 19

2.3 Problems with demand of water and energy

One of the biggest problems that brings the irrational exploitation of resources in the world is their fast and dangerous scarcity. Some examples presented in the previous sections such as the dramatic situation of Africa and its shortage of drinking water, as well as its drought are a warning to realise that something has to be changed. But Africa is not the only region that has this situation, some countries of Asia, South America etc. have to face the same problem.

The uncontrolled usage of water for unnecessary appliances added to the global warming is getting worse this situation. As Figure 2.8 shows the global temperature around the world has increased at least 0.5ÂoC between 1986 and 2005 and trend does not seem to stop, by 2100 the temperature could increase 11ÂoC. This increase of the earth temperature and the

less and less rain could lead to the exploiting of water in a very delicate position.

(20)

2 Motivation 20

A big responsible of the global warming is how the humanity has tried to generate energy during the last century. Nowadays, new eco-friendly techniques and renewable energies are taking part in the panorama. As Figure2.9shows, some types of generation such as eolic or hydraulic are more and more important in the whole amount of energy generation but some very polluted techniques and producers of the greenhouse effect such as coal factories still being the most used.

Figure 2.9: World electricity production.

2.4 Household area consumption

One of the most important things to take into account for the development of this project, is to analyse in which devices the user is wasting more resources. Knowing this will allow us to decide where, how and when can this tool be applied in order to reduce the amount of energy and water used.

According to the waste of a family of 3-4 people per day, the Table 2.1 and 2.2 show in a general way where are the resources destined. Regarding the water consumption, the toilet and the shower are the most critical points; just with a shower, a person can waste between 50 and 75 litters. Applying the conclusions extracted in the previous section, in Table.X it

(21)

2 Motivation 21

is possible to compare the difference of water bill in a day between Germany and USA (the prices are take on August 2015).

Table 2.1: Simulation of a household water consumption.

In the same way, a complete study of the energy consumption has done. In this case, it has taken into account also the amount of hours that each device could be used in a domestic usage. Table2.2provides the enough information to decide how this project can be prepared for the different cases inside a household set up. As well as, a simulated bill of this set up for Germany and USA is presented in the following Table2.3.

As it is shown, the heating and the air conditioning are the most power consumers inside home proportionally to the time that they are used (in this case 4 months). Other appliances such as, TV, microwave or video-game console are not an important part in the total bill. This is a good news because the usage of the most critical appliances, heating, air conditioning, washing machine etc. can be changed and decided for the user with the purpose of reduce the consumption (see chapter 3.).

(22)

2 Motivation 22

(23)

2 Motivation 23

Table 2.3: Simulated price of Germany and USA cases.

The main idea of this project is to be able to reduce these bills applying the concept of User-in-the-loop inside the Smart Home environment not only regarding the money but trying to save our world and its resources which are fewer and fewer. It is in our hands to improve, to learn about the mistakes done and to teach our future generations how it is possible to live in a rational and environmental-respectful way.

(24)

2 Motivation 24

2.5 The Smart Grid concept

The Smart Grid model is an evolution of the electrical grid used until now which includes a variety of operational and energy measures such as, smart meters, smart appliances, renewable energy, energy efficient resources, among other things. This model is organized in Europe by the Smart Grid European Technology Platform and in the USA is described in 42 U.S.C. chapter 152, subchapter IX.

The Smart Grid represents an opportunity to move the energy industry into a new era of reliability, availability and efficiency contributing in economic and environmental health. This concept is not just about utilities and technologies but it gives the possibility to the user to be informed about the resources usage and their cost. The main benefits brought by the Smart Grid model are:

- Efficient transmission of electricity

- Quicker restoration of electricity after power disturbances - Lower power costs for consumers

- Reduced peak demands

- Increased integration of large-scale renewable energy systems - Better integration of customer-owner power generation systems - Improved security

Thanks to the usage of smart meters (Figure2.11) and other mechanisms, the final user is able to see how much electricity, gas, water is using and the addition of the dynamic prices models will bring the opportunity to help for save money by using less resources when they are most expensive.

The idea of Smart Grid consists of millions of pieces and parts, computers, power lines, controllers etc., which together will provide a whole system of smart nodes for the better performance and usage of the resources in the customer’s household. This evolution of the

(25)

2 Motivation 25

Figure 2.10: Whole Smart Grid scheme.

electrical grid is another step to convert all our environment in a smarter way with the aim to have the most eco-friendly way-of-doing.

2.5.1 Energy and Water price model

In the previous sections it is shown how the scarce of water, the necessity of an eco-friendly generation of energy and the implementation of smart devices in our households have mo-tivated to develop this project. However, the smart grid concept and the dynamic price of resources allow us to apply the paradigm of the User-in-the-loop and to inform the user how to save money.

Regarding the water, its price is fixed and is different depending on the country, the region, even varies in close cities. The value of the m3 of water is selected in base mainly on the exploiting conditions, such as: capitation, quality of water, distance to the source, costs, antiquity of installations etc. Nevertheless, the water price does not vary per hour as in the energy case. Some conditions have been implemented in the last years which modify the

(26)

2 Motivation 26

Figure 2.11: Example of a Smart Meter used in Smart Grid systems.

water price "dynamically" in relation to the consumption and the consumption that each home should have.

In comparison, the energy price also depends on the politics of each country, the state of the market, the way of generation, the price of the raw material etc. but in this case a new pricing model has applied. The idea is to divide the pricing model of each hours into different bands: "off-peaks", "mid-peaks"and"on-peak", each one with a different price. This model called TOU (Time-of-use pricing) has been applied with the purpose of spread the peaks of consumption around the whole day and not just in the busy hours, morning and night. Figure

2.12represents the dynamic price ine/kWh in Spain the 16th of January 2018. As it can be seen, the green zone are those with the lower price, this range is form by from 01 h - 07 h. The orange regions represent the "mid-peaks"; 07 h - 08h, from 13 h - 18 h and between 22 h and 01 h. Finally, the more expensive range is in the busied hours, 08 h 13 h and 18 h -22h.

(27)

2 Motivation 27

Figure 2.12: Peak zones in a daily dynamic pricing in Spain.

This interesting model price helps to spread the load of energy in a more flat way erasing the demand peaks. However, it does not necessarily encourage reduced electricity use. For this reason, this research pretends to add the Smart Home concept and some extra concepts in order to push for the saving of the consumption. Thanks to the variaton of prices per hours, it is possible to advise the user how much can he save just postponning some action to another range of hours. For instance, a common situation is the usage of the washing machine whom could be set to a "off-peak" hours instead of using it after work. This kind of cases are going to be explained more detaily in the following chapters.

(28)

3 Smart Home concept

During the previous sections the motivations about the high waste of energy and water have been presented. However, the smart home environment is a basic pillar in the main idea and development of this research.

The concept of Smart Home can be comparable to the evolution from "dumb" cell phones to the current smartphones.From just being able to call and text, smartphones allows us to be connected to the Internet, download files, watch videos, send e-mails etc. They allows us to be inter-connected. Regarding homes the idea is the same. A smart home is set up of appliances and devices which are connected and controlled from a central device. A home automation system is able to control our climate control, locks, lights etc. inside the house or from afar. In summary, the home devices are getting a little bit of intelligence.

(29)

3 Smart Home concept 29

Nowadays, the market offers an infinite list of application for Smart home concept. The most common applications home automation are:

- Lightning control: Smart lightning allows you to control the lights of the house remotely. The user is able to schedule the lightning, decide which rooms should turn on, select the level of light etc.

- Heating and cooling regulation: As sections before mention, heating and cooling are the most consumers of energy in a home. As well as, the generation of energy by coal factories is leading our ecosystem to a very dangerous situation. For this reason, with the smart home concept allows the user to control and automatize the configuration of the heating and cooling depending on the environment temperature, the schedule or even the occupancy of a room.

- Lawn irrigation control: the automatization of the irrigation allows the user to save a lot of money in the water bill and be more respectful with the environment. The system offers the possibility to set up the irrigation depending on some humidity sensors in the ground, with a manual configuration or even based on a weather data.

- Smart Appliances: Smart refrigerators or smart ovens are an example of smart home de-vices. Suggest of recipes based on the food inside the fridge, alert based on the expire date of food, automatically preheat to the correct temperature depending on the recipe selected in a data base etc. These are different options that a smart kitchen can offer to the user.

- Security Systems: In the catalogue of smart home applications, there are a huge vari-ety of home security systems including door and windows sensors, motion detectors, video cameras and recording mechanisms etc.

In order to interconnect all these devices, there are a lot of option for the indoor connectivity of them. The decision about which type of technology use will depend on the proximity of the nodes, the environment features, frequency band desired, the network security requirements or the data rate needed. In the following table are described the most common communica-tion protocols used in smart home applicacommunica-tion and some of their main characteristics.

(30)

3 Smart Home concept 30

3.1 Gateway or Hub

The gateway or hub is a device which connects the multiple devices inside a Smart Home ecosystem and provides a graphical interface as a controller which interacts with smart phones, tablets etc. This central node contains all the protocols, servers and the rest of information for the good performance of the system and is the responsible to process the data collected by the sensors and to manage the actions that will be done by the actuators. Nowadays, in the market it is possible to find a large quantity of smarts gateway:

(31)

3 Smart Home concept 31

3.2 Smart Sensors and Actuators

The responsible to collect the desired data about the environment and to help the central station to take decisions is the Smart Sensor. It is a combination of an analog or digital sensor with a processor, some memory and a network controller. The main functionalities of a smart sensor are:

- Pre-process the collected data

- Notify the data digital signals and communication protocols

- Calibrate their parameters

- Take decisions from the registered conditions

(32)

3 Smart Home concept 32

In addition to the smart sensors there are required some devices that are responsible to execute the different actions decided by the central station in based on the data collected by the sensors. This devices are known as actuators.

(33)

3 Smart Home concept 33

(34)

3 Smart Home concept 34

(35)

3 Smart Home concept 35

(36)

3 Smart Home concept 36

3.3 Communication

In order to interconnect all these devices, there are a lot of option for the indoor connectivity of them. The decision about which type of technology use will depend on the proximity of the nodes, the environment features, frequency band desired, the network security requirements or the data rate needed. In the following table are described the most common communica-tion protocols used in smart home applicacommunica-tion and some of their main characteristics.

Table 3.2: Summary protocols in Smart Home systems and their main features. The main idea of this project is to be able to reduce the consumption of water and en-ergy in the final user home using the concept of User-in-the-loop inside the Smart Home environment. This is not pretended to be only regarding the money but trying to save our world and its resources which are fewer and fewer. These are the reasons which pushed

(37)

3 Smart Home concept 37

to carry out this research because it is in our hands to improve, to learn about the mis-takes done and to teach our future generations how it is possible to live in a rational and environmental-respectful way. In the following section, the design, implementation, details and theory concepts of this project are going to be presented.

(38)

4 Principle of the User-in-the-loop

paradigm

In this chapter, the paradigm of the User-in-the-loop is going to be explained. This con-cept is a result of an academic project after the IMT-Advanced evaluation was done in the WINNER+ (reference) project. UIL is a simple, complete and robust concept for better and greener telecommunication very relative to energy conservation, smart grid and net-works, consumer traning and human consumption behaviour control. This idea proposed by Dr. Raincer Schoenen, Dr. Gurhan Bulu, Amir Mirtaheri, Tamer Baitelmai and Dr. Halim Yanikomeroglu, has been studied since 2010 and poses more than ten of publications.

In the following sections, the background and the main ideas of User-in-the-loop are going to be presented giving a strong base to be able to understand how this powerful paradigm, firstly designed for mobile communications, can be applied in a Smart Home environment for the saving of water and energy.

4.1 Background

The exponential growth of wireless access data rates demand, the limitation of the wireless resources such as, spectrum available, time and space and the flat rate data tariffs are the main motivation of the User-in-the-loop concept. As well as, the wireless cellular networks consume 0.5 % of the world total electricity which is approximately 20 PWh in 2010. Taking this into account, the UIL follows a principle: how much do you care to adjust your data usage to be greener?

(39)

4 Principle of the User-in-the-loop paradigm 39

Figure 4.1: Close loop applied in User-in-the-Loop paradigm.

The UIL model is a closed loop in which the user takes part into the control Figure4.1. The main idea is to extend the past assumption of the user being just a traffic generating and consuming black box. Instead, the system-theoretic will send suggestions and incentives (or penalties) to the user in order to convince him to diverge form the default behaviour. In other words, a user which pretends to use some wireless access point with a very busy feature, will receive a control information in form of suggestions (e.g., a map directions towards a better location, a better time to start his session (out of the busy hour) etc.) with the purpose of the traffic can be shaped. The user’s output is a probability of conforming to the suggestions, ps for the spatial ones and pT in the temporal domain. In order to model a real cell with multiple users, the system is vectorised for m users.

In a case in which the user is suggested to change its location or to postpone its usage, the network can determine the incentive for doing it. This incentive can be financial (discount for real-time traffic) and/or increased data rate.

(40)

4 Principle of the User-in-the-loop paradigm 40

4.1.1 Spatial Control

In the spatial control of the UIL, it is expected that the user sometimes voluntarily changes its current location from point A to B. It is assumed that the average signal quality and the corresponding spectral efficiency will be known for all relevant locations of the network from a database of previous measurements. Figure 4.2 shows an example of display providing the information about where the user should move.

Figure 4.2: Graphical User Interface of a UIL implementation suggesting a spatial change.

4.1.2 Temporal Control

Flat-rates promote heavy-tailed traffic distributions and in the long term there will be a con-gestion problem because physical wireless capacity supply cannot grow adequately with the demand increase. The pricing policy is expected to change to a variety of plans for each traffic category, as same as electricity with the smart grid. In this case, a price has to be calculated in /Mbit and it is valid for all the users who are starting a new transmission at the current time. This idea pretends that the user will generate less traffic when the session price goes up above the normal postponing its session to a lower busied one.

(41)

4 Principle of the User-in-the-loop paradigm 41

4.2 Benefits

The application of the User-in-the-loop concept brings a solution for the saving of limited resources. Firstly, as it is described in this chapter this resources were focused on wireless communications but this paradigm can be applied in other contexts, such as of water and energy consumption. The power tool that UIL gives is the participation of the final user in the final system performance, that means that the user is responsible of decide how to use the resources and how much is willing to pay for being more environmental friendly. In addition to the rational consumption, the user will pay less money due to the feedback about when to use the resources.

In the recent years, the conscience of be more respectful with the ecosystem and the need to protect the scarce resources is growing more and more. As a result the UIL principle can be applied into a Smart Home environment for the savings of water and energy. In the following chapter, the complete scheme of the User-in-the-loop in utility networks is going to explained and how a paradigm a priori thought for a cellular communications could be the first step to improve the performance of the resources in our household.

(42)

5 User-in-the-loop in utility networks

From the very beginning of this document, it is described the necessity in our society to improve the usage of our resources. This context is focused on the consumption of water and energy. As well as, on chapter 4., it is introduced the concept of User-in-the-loop and how it emerged as an innovative solution for the wireless communication efficiency. At this point, it is time to merge all these concepts. During this chapter the main ideas, benefits and the design of the implementation of the User-in-the-loop in utility networks project are going to be presented.

This project is the base of a whole system for Smart Home, some of the following information is based on proposals for the for short and med term, considering that it is "on-going" and it will be continue developed during the 2018.

5.1 Description of the idea

"An ecosystem enabling User-in-the-Loop demand control in telecommunication and utility networks" pretends to offer a tool in the context of water and energy for their rational and efficient consumption through the feedback and the interaction of the human user. The main idea of this project is to allow the final user to decide, to be informed and to be responsible of all the consumption inside its household depending on the dynamic price of water and energy at this moment.

The principle of the closed loop of UIL described in chapter 4., is applied now in a Smart Home environment. Thanks to a set of sensors, actuators, gateway etc. the final user will receive some feedbacks about its consumption in m3, kWh or /euro and will be provided with some information about how could save money before doing a certain action. For instance, setting the thermostat temperature; the user will be informed about how much money this

(43)

5 User-in-the-loop in utility networks 43

action cost by week, month, year... how much money could he save if the temperature is configured some degrees lower or even, how much cheaper would be this action if he postponed it for two hours (a non-peak period).

Figure 5.1: UIL close loop in a utility network in household.

This idea can be useful in different environments not just for a familiar household but for hotels, Airbnb places, rent flats etc. The system gives the opportunity to monitor, control and to limit the consumption of water and energy depending on the user, per room, based on the contracted tariff, age etc. remote and automatically.

5.1.1 Psychology and economical perspective

The principle of this research is the fact that the person who uses the resources has to pay for them. It means that the idea of the parents paying the bill without any responsibility for the kids is erode. Figure5.2represents the current and the model proposed in this project in which at the end of the month each person living in the house should pay for its consumption by bank account. If the kids are too young to have a bank account, a virtual wallet can be applied in order to motivate them to use rationally the resources.

This models defends that the savings in consumption and in consequence in the final bill would be easier if each consumer would pay its part from the young age. As well as, as it is mentioned before, this principle could be a very good solution for hotels and rent flats because the owner could set some pre-defined limitations in consume depending on the tariff, and the customer should pay an extra fee if they want to use more.

The merge of the User-in-the-loop paradigm within a whole Smart Home system will offer benefits not only to the user but to the all society and the future of the next generations. In

(44)

5 User-in-the-loop in utility networks 44

Figure 5.2: Current and proposed pay-bill model.

the context of water and energy, this system will allow the user to use the resources in a rational and environmentally friendly way, besides of a decrease of the final bill.

In order to apply and implement this model, some techniques of Authentication, Authorization and Account (AAA) are going to be used (see section 6.4.).

5.1.2 List of feedbacks

In the following Table5.1 a set of possible feedbacks depending on the appliance are going to be exposed. In this list, there are proposed some actuators such as: speakers in the home which would inform about the consumption, RGB lights, web page or graphical user interface in order to consult the consumption, display in some devices etc. For instance, a thermostat with a RGB Led using Arduino is being developed and it is described in detail in the following chapter. As well as, in the future smoke feedbacks could be applied to advise for a heavily consumption of the stove in the kitchen.

(45)

5 User-in-the-loop in utility networks 45

(46)

5 User-in-the-loop in utility networks 46

(47)

5 User-in-the-loop in utility networks 47

Table 5.3: List of feedbacks part 3.

(48)

5 User-in-the-loop in utility networks 48

5.1.3 Example of sensors and actuators

In the previous section a set of possible feedbacks implemented in the system have been presented. In order to get more information about the environment and to make the system the most smartest possible, it is needed a set of sensors which will be responsible to get information about: temperature, humidity, volume of water, wind etc. This data will be used in addition of the energy price, to keep the user informed about the efficiency of its action. As well as, in a med-term future a motion sensors to analyse how many people are in each room and to be able to decide to turn-off some lights, switch off the heating etc. could be implemented. Obviously, these sensors have to be smart to send the information in real-time to the central server.

Concurrently of this research, other projects about the development of some smart sensors are being carried out. These sensors with actuators will monitor the water, energy and temperature and in the same time will give immediate feedback to the user in order to change his/her behavior. In this section, these examples are going to be presented.

Smart Thermostat: Bent Alexander Haase

The smart Thermostat developed by Bent Alexander Haas is an improved basic thermo-stat. It is able to show a feedback with a OLED screen and with some LEDs depending the temperature and the efficiency of the usage. Its main functionalities are:

- Measure temperature precisely

- Show current and set temperature on OLED screen

- Reliably send data to gateway: RF module

- Reliably receive data from the gateway: RF module

(49)

5 User-in-the-loop in utility networks 49

- Measure humidity

- Easy access to serial debugging pings

- Implement UIL concept using visual signals

The main components forming this prototype are:

- OLED display unit (backside), black tape to avoid short circuiting other components

- ON/OFF LEDs, indicating actuators state

- UIL/RGB LED

- Top: DHT22 tempearture and humidity sensors, Bottom: DS18b20 high precision tempera-ture sensor

- RFM69C, low power 868 MHz RF module

- Voltage regulator 5V DC -> 3.3V DC

- Arduino Pro Mini

(50)

5 User-in-the-loop in utility networks 50

(51)

5 User-in-the-loop in utility networks 51

Smart Energy Meter: Cristian Zara

The energy meter device was developed by Cristian Zara in the project "User-in-the-loop Demand Control Implementation for Controlling of Scarce Resources like Water and Energy". It is able to calculate the amount of power usage in real-time and applying UIL with a RGB Led show the efficiency of the action. Its functionalities are:

- To monitor the consumption of energy

- To calculate the power from the current and the voltage

- To give immediate and relevant feedback to the user during the usage

- To transmit the data usage to the gateway

The main component of the circuits are:

- Arduino Pro-mini microcontroller

- Current and Voltage sensor

- RFM128B transceiver module: communicate the device and the gateway

(52)

5 User-in-the-loop in utility networks 52

(53)

5 User-in-the-loop in utility networks 53

Smart Water Flow Meter: Cristian Zara

The water measurement device is very similar than the previous one. It offers the possibility to calculate the flow of water and shows the amount of consumption and some feedback with the RGB Leds. It was developed by Cristian Zara and have three main functions:

- To monitor the consumption of water the water

- To give immediate and relevant feedback to the user during the water usage

- To transmit the data usage to the gateway

The main component of the circuits are:

- Arduino Pro-mini micro-controller

- Water Sensor

- RFM128B transceiver module: communicate the device and the gateway

- Feedback component: LCD Display and RGB Led

(54)

5 User-in-the-loop in utility networks 54

These three devices are an example of home-made sensors and actuators that could be applied in the system in order to close the loop and show a feedback of consumption to the final user.

5.1.4 Controller: Android Application

As in the previous section is explained, in a Smart Home environment the Gateway generally also works as a controller in which all the information about the sensors, devices, consump-tion, etc. can be consulted. In this project, instead of this, an extra controller has been devel-oped. Some students of Fakultaet Technik und Informatik: Sanchit Bhavsar, Sahitya Mohan Lal, Anthony Omiunu and Ganesh Simha Reddy Pucha have designed and programmed an Android application. Its main functionalities are:

- List of sensors, devices and actuators of the system

- Send and receive request and replies to the Gateway: TCP connection

- Smart Home functionalities: control the end devices from the Android application

(55)

5 User-in-the-loop in utility networks 55

5.2 Authentication, Authorization and Accounting (AAA)

AAA refers to Authentication, Authorization and Accounting which form a family of proto-cols to mediate the network access. Some examples of protoproto-cols are: Radius or Diameter (Reference).

- Authentication: Process in which an entity proves its identity before others. The authentica-tion is obtained through the exchange of credentials between two parts, such as: passwords, tokens, digital certificate etc.

- Authorization: Concession of rights or restrictions to an entity or user in based on its identity. There is a huge list of examples: concessions depending on the hour, the role of the user (admin, root etc.), the location, the current system state etc.

- Accounting: Tracking of the resources consumption of each user. This data can be used for the administration, planning, billing, among other purposes.

The AAA protocol can serve as a base for some new concept for smart home systems. In this case, it is used as an extension of the project about the water and energy consumption. Even this part is still "on-going" for a medium term, the main aspects have been decided.

As in the previous sections is explained, the main principle of the project is to hold each user in a household responsible of its consumption; kids, young, adults, tenant etc. In order to be able to detect who is using a device in each moment and to collect the consumption of each person is required the using of the AAA protocol.

5.2.1 Authorization of the user

The same as all the smart homes environments, there is a gateway or central hub which coordinates all the system and interconnects the total amount of nodes. In this case, as it will be explained in detail in the following chapter, there is a gateway which contains all the information required for the performance of the ecosystem. One of the data stored in this gateway in XML file format, is the information about the users inside the household. Each

(56)

5 User-in-the-loop in utility networks 56

user has to be registered when the system is installed in the household with a role selected. This role says the rights of the user in the whole ecosystem.

Table 5.5: Table of the different user roles.

R - Read information about consumption; W - Create device and users, X - Change permis-sion of other users.

Table5.5 shows the type of users than can be part of the system. The authorization of the user to do something depends on rwx (read, write and execute). Both "root" and "admin" are able to create users, devices, delete etc., even "Root" is thought for the developers. The "master" role represents the adult responsible of the system in the household; parents, owner of a flat, direction of a hotel etc. This user is able to change the permission of the other users such as: permission to use the devices in a room, permission to be able to read the consumption etc. "Normal" role, designed for adult user in a household without the responsibility of the bill, tenants, teenager etc. Finally, "Kid" and "Guest" are completely controlled by the "master", their permission in the home are limited. In the case of "Guest", its concessions could depend on the tariff ordered, the rent etc.

5.2.2 Authentication of the user

In order to collect the consumption of each user inside the system, it is necessary an authen-tication of them each time. For instance, an authenauthen-tication in the gateway when the person comes into the house. At this point, there are some ideas that could be implemented for the system access:

(57)

5 User-in-the-loop in utility networks 57

Table 5.6: Some authentication ideas for the system.

In this table there are exposed some possible solutions for the authentication of the users in the system. A combination of them could be possible, for instance, using a local password for the authentication in the central gateway once the user enter in the home, and the usage of the RFID login for the identification before using some devices. Even this possible solution, the identification of the users in each device in a more friendly and non-invader way is still an issue in course.

(58)

5 User-in-the-loop in utility networks 58

Figure 5.7: Key ring for RFID authentication.

Figure 5.8: RFID Reader for Windows System.

Figure 5.9: RFID module for Arduino.

(59)

5 User-in-the-loop in utility networks 59

5.2.3 Accounting the user consumption

Once the system has the information about the different users and about who is going to use the devices, it is needed to collect the data about the consumption of each one. In order to get the consumption of one action the following formula has to be calculated, where S(t) represents the supply of water and power used by the device, e(t) is the price variation over the time, both energy and water and t and to, are the time interval in which the action is executed.

Figure 5.11: Cost equation.

The previous formula gives the price of a certain action executed in a period of time. The dynamic price of water or energy is real-time obtained by the gateway. The final value is stored and added to the previous ones of the user. At the end of the month, the amount of water and energy consumed per user is going to be payed.

(60)

5 User-in-the-loop in utility networks 60

5.3 Real Case Concept System Design

Figure 5.12: Complete ecosystem in a real household scheme.

The previous image shows the complete ecosystem in a Smart Home environment. The blue circles represent the set of sensors: wind, humidity, temperature etc. These are connected to the central hub or gateway identified by a green circle. It is responsible to receive the information of the sensors and to calculate the cost in real-time of the action that the user is going to execute.

This user has been authenticated via RFID card, in this case. Immediately, the gateway will send some information to the actuators (red circle) depending on the efficiency of the current usage. These actuators are the feedback that the user uses to know the status of its action, for instance, the speaker of the kitchen after switching on the dishwasher: "Too expensive now. The usage in 2 hours will save 26ein a year". Now, the user can decide to postpone the action or continue. As well as, all the information about sensors, actuators and end-devices are possible to be checked by a smart phone application.

(61)

5 User-in-the-loop in utility networks 61

In the following scheme is represented the flow of a complete performance of the system. From the identification of the user to the feedback and the user behavior.

(62)

6 Implementation of the whole system

As it is shown during the previous chapters, in a Smart Home environment a set of devices are required in order to do all the tasks needed properly: communication, data storage, measurements etc. During this chapter the whole ecosystem designed in this project will be described, as well as the main aspects of each part of it.

6.1 Gateway

The most important device of the whole system designed and developed in a Raspberri Pi3 Screen 7". It contains the daemons and the modules which allows the communication between the different devices and the outside server, and has the functionalities in charge of getting the dynamic price of energy and water in real-time. The Gateway functionalities have been generally developed in C even some of them are in Bash. In summary, the main functionalities of the gateway are:

- Interconnection of the nodes: outside server, sensors, actuators, front-end-devices and end-devices. Establish/disconnect communication, request and reply messages etc.

- Distribution of the message between the nodes: TCP/IP, UNIX Stream.

- Contains the daemons used: Smart Home Daemon and RANET Daemon

- Store XML files

(63)

6 Implementation of the whole system 63

Figure 6.1: RFID Access control device and tag.

- Store and identify user information

- Store data of sensors

- Store water and energy consumption

- Store water and energy price: graphs

(64)

6 Implementation of the whole system 64

- Methods to get the current price of water and energy

During the development of the project all the code and protocols have been developed in a local server in order to facilitate the coding and to not affect the performance of the gateway device. In the following figure, a summary of the main functionalities carried out by the gateway are presented, they will be explained in detail in the next sections.

(65)

6 Implementation of the whole system 65

Figure 6.3: Gateway: RPi3.

(66)

6 Implementation of the whole system 66

6.2 Daemon communication

The main modules inside the server of the gateway are the Daemons, Smart Home Daemon and RANET Daemon. Briefly, a daemon is a computer program that runs as a background process. This sections explains the most important aspects of both daemons programmed in C.

In this system, as Figure 6.1 shows, the Smart Home Daemon is in charge of the com-munication between the Smart Phones and the Outside server with the Home gateway. In this daemon, there are all the code required for establish the connection in TCP and UNIX Stream, and the code for the processing of messages received and their replies. Also that, it includes all the methods required for the reading, processing and editing the data stored in the XML files and the local data, for instance, them received form the sensors. In the following pictures, some parts of this code are going to be presented.

In the next Figure, it can be seen the list of all the communications programmed in the Smart Home daemon. Some of them are not used in the ecosystem yet, but will take part in future improvements of the project. The connection with the outside server and with the smart phones, as well as, the RANET with the WiFi module is done via TCP connection in port = 11485.

Figure 6.5: List of connections in the socket_server code.

In the communications done in this environment, in order to connect the front-end-devices with the gateway and to interconnect both daemons it is used a concept called sockets. A network socket is an internal endpoint for sending or receiving data between two nodes. Figure 6.6 shows the basic scheme of a socket connection between a server and a client. The server is listening until a client request arrives, at this point the methods for write() and read() respectively are called. In this type of communication, a common issue is the blocking

(67)

6 Implementation of the whole system 67

of the entrance packets, in order to improve this situation, a socket with the select() loop can be applied.

(a)

(b)

Figure 6.6: (a) Socket connection. (b) Socket connection with server loop.

If a select() loop is used, the performance of the communication changes a bit. In this case, a set of File Descriptors are used to do the different required tasks (read, write, etc.). A File Descriptor or FD, is an abstract indicator used to access a file or a resource, such a network socket. They are a non-negative integer and in C are represented generally as a type int. The select() function indicates which of the specified file descriptors is ready for reading, writing,

(68)

6 Implementation of the whole system 68

etc. If the specified condition is false, the loop blocks until true. There main important things of this kind of socket are:

- fd_set: set of sockets for the the select function for some activity.

- FD_CLR: remove a descriptor from a fd_set.

- FD_ISSET: check if a descriptor is a member of the fd_set.

- FD_SET: add a descriptor to an fd_set.

- FD_ZERO: clear an fd_set.

The first part of the select() loop implemented in the Smart Home Daemon is shown in the Figure6.7, socket_listen_select_loop. It shows the declaration of the connection index as an integer, variable that is used to identify the entrance connection and the fd_set which will be fulfilled with the different FDs.

(69)

6 Implementation of the whole system 69

6.2.1 TCP/IP Connection

The TCP (Transmission Control Protocol) is one of the main protocols of the Internet. Its im-plementation is complemented with the Internet Protocol (IP), for this reason, it is commonly referred to as TCP/IP. TCP protocol operations may be divided into three phases: Listen, Established and Closed.

- Listen: server waits for a connection request from any remote TCP and port.

- Established: client and server represents an open connection, data received can be deliv-ered to the user.

- Closed: client and server connection is dead.

In the following pictures, there is a very small part of the code corresponding to the TCP connection. The first one shows the establishment of an input TCP connection, the other one is the method responsible of the interconnection between the inside server and outsider master server.

(a)

(b)

Figure 6.8: (a) Establishment of a TCP connection. (b) Connection with the master outside server.

(70)

6 Implementation of the whole system 70

6.2.2 UNIX domain socket

A UNIX domain socket is a data communication endpoint for exchanging data between pro-cesses executing on the same host operating server. In this situation, this type of commu-nication is used to communicate both daemons. The difference between UNIX and TCP sockets, is that in the UNIX domain since the nodes are in the same system, it is possible to avoid some checks and operations; which makes its sockets faster and lighter than IP ones. As well as, it is used a stream socket which offers the possibility to transmit all the data in a unique flow and provides well-defined mechanisms for creating and destroying connections and for detecting errors. In the next figures, part of the methods responsible for the creation of UNIX socket and to establish the connection between daemons are exposed. As in the previous case, in order to accept the connection coming from the UNIX socket the required FDs are used.

(a)

(b)

(71)

6 Implementation of the whole system 71

6.3 Sensor Communication

As it can be seen in the previous chapters a very important node in a whole Smart Home system are the sensors. They are going to collect the data and to send it to the gateway in order to have more information about the environment. The manner that the data is going to be sent is a very important issue and depends on the type of sensor.

Table 6.1: Table of sensor type.

Until now the gateway device has been explained and its modules for the communication between devices using TCP and UNIX protocols. As the previous table shows, there are different types of sensors, each one needs an update frequency different, a power sensor needs a faster updating than a temperature one. In this case, the communication between the device and the gateway is provided by a transceiver which is connected via SPI interface to the micro-controller. The connection between the gateway and the sensors is based on the MQTT (Message Queue Telemetry Transport). It main aim is to collect data from many devices and transport them to the IT infrastructure, in this case the gateway. The principle idea of this communication, is the fact that a client is "subscripted" to a MQTT server, so each time that the server "publish" something, the client will receive it.

(72)

6 Implementation of the whole system 72

6.4 XML Files

All the information relevant for the system is stored and created using XML Files. An XML File is a text document which is readable for both human and machine. They allow to keep all the important information in a simple and friendly way. In this project there is a set of XML files:

- Devices XML: file with all the information about all the devices of system (end-devices, front-end, sensors, etc.).

- Users XML: file with all the users in the system and their information.

- Hierarchical XML: file that allows to have a tree structure used to organize in a better way all the devices in the system.

- Roles XML: file with the information of the different roles used for the authorization pro-cess.

- States XML: file which contains the state of all the sensors of the system.

(73)

6 Implementation of the whole system 73

Figure 6.11: Devices XML file.

(74)

6 Implementation of the whole system 74

Figure 6.13: Roles XML file.

Figure 6.14: States XML file.

(75)

6 Implementation of the whole system 75

Even the XML files are stored in the gateway, it is a good option to store their content in a local storage, in this case using arrays. It allows to consult the data of the files in a faster way and more efficiently. As well as, once the data is stored in arrays the methods for searching and editing are simpler. The next picture shows the code for the reading and storing the information of the User XML file.

A situation where the usage of the arrays of data from XML is required occurs when a petition from a front-end-device arrives asking for the state of a sensor. The gateway has to check the proper array looking for the sensor desired and reply with the required information.

(76)

6 Implementation of the whole system 76

6.5 Water and Energy pricing

One of most important conditions of this project, is the principle of the dynamic price of the energy. For this reason, to get the cost in real-time was an issue very important from the very beginning. In this case, a CGI protocol is used to do this task.

CGI (Common Gateway Interface) is a protocol for web server that allows to execute pro-grams running on a server creating web pages dynamically. These propro-grams are known as CGI Scripts.

(77)

6 Implementation of the whole system 77

In order to get the real-time prices of the energy from USA, Germany, Spain and Canada, a CGI script was designed and developed in Bash. This script identify the desired value from different web pages and print it in the corresponding html file. In addition, with the Chrontab tool offered in Linux, it possible to execute this script automatically every minute. Also that, with this value and the current time, different graphs are built with the variation of the energy prices.

Figure 6.18: CGI script for the real-time energy price consulting.

With the storage of the history of the energy price, it is possible to estimate in price in the following hours in order to create a good feedback for the user. When a user wants to execute some action the gateway gets the current energy price and comparing with the prices in the following hours will decide if the efficiency of the usage desired for the user is good, bad or regular.

(78)

6 Implementation of the whole system 78

Figure 6.19: Variation of the energy price in Spain from October 2017 to January 2018, up-dating every minute.

(79)

7 Details of implementation

During this chapter a set of designed protocols are going to be exposed, as well as, a whole diagram of the UIL process in the system is defined.

- Add device in the system

- Add phone in the system

- Add user in the system from the phone

- Protocol of the whole performance

(80)

7 Details of implementation 80

7.1 Protocols and diagram

Adding a device from the Gateway Graphical Interface protocol

(81)

7 Details of implementation 81

Registration of a device protocol

(82)

7 Details of implementation 82

Registration of a front-end-device protocol

Referenzen

ÄHNLICHE DOKUMENTE

In other words, our proposal is to complement the third wave of AI ethics with a stakeholder engagement approach, according to which, whenever conflicts arise between dif-

Il chiarimento delle questioni relative ai diritti di accesso alle opzioni di flessibilità esistenti nelle reti di distribuzione (consumatori, accumulatori, veicoli elettrici,

Per Fernzugriff über die Theben-Cloud mit der LUXORplay App lassen sich sämtliche Funktionen von LUXORliving steuern und Zustände überwachen.. Den Zugriff über die Cloud starten

Hierzu wurden 35 Haushalte mit verschiedenen Aktoren (z. Anwesenheits- sensoren und Echtzeitstromverbrauchsmessung) und einer Energiemanagementsoftware, die auf der

The aim of the Watt d’Or is to increase awareness of these achievements and thus motivate companies, politics and the general public to discover the advantages of innovative.. +

Unsere Funktionseinsätze, wie die Jalousiesteuerung oder das Gira Radio, passen perfekt mit den Gira Designlinien zusammen: Möchten Sie beispielsweise Ihre Gira Schalter und

Aufbewahrungsmöglichkeit für Spritzen & Brausen sowie großer Verstaubox und Fixiermöglichkeit für Gießstäbe. Mit

Come controllare il fare�o led al Internet e controllarlo con Amazon Alexa e Google Assistant.. 72-75