Smarter City: Smart Energy Grid based on Blockchain Technology

—The improvement of the Quality of Life (QoL) and the enhancement of the Quality of Services (QoS) represent the main goal of every city evolutionary process. It is possible making cities smarter promoting innovative solutions by use of Information and Communication Technology (ICT) for collecting and analysing large amounts of data generated by several sources, such as sensor networks, wearable devices, and IoT devices spread among the city. The integration of different technologies and different IT systems, needed to build smart city applications and services, remains the most challenge to overcome. In the Smart City context, this paper intends to investigate the Smart Environment pillar, and in particular the aspect related to the implementation of Smart Energy Grid for citizens in the urban context. The innovative characteristic of the proposed solution consists of using the Blockchain technology to join the Grid, exchanging information, and buy/sell energy between the involved nodes (energy providers and private citizens), using the Blockchain granting ledger.


I. INTRODUCTION
The definition of the Smart City is still a confused and ambiguous concept. Even now, a Smart City is conceived as an idealistic city, where the quality of life for citizens is significantly improved by combining ICT [1], [2], new services and new urban infrastructures, as seen in Fig. 1. The main innovation in the Smart City evolutionary process consists of considering a user-centric vision, and accounting urban issues from the perspective of the citizen's needs, engaging the citizens in the city management. In other words, the Smart City concept may be defined as an integrated system in which human and social capital heavily interact, using technology-based solutions. The application of the Internet of Things (IoT) paradigm to urban scenarios is of special interest to support the smart city vision [3]- [5] [6].
This vision aims to efficiently achieve sustainable and resilient development and a high quality of life on the basis of a multi-stakeholder, municipality-based partnership.
The Italian architect Carlo Ratti confers a very important role to modern city, affirming that this "occupies 2% of the land surface, hosts 50% of the global population and consumes 75% of the total energy, being cause of the 80% of emission of CO 2 " 1 . For all these reasons, it is necessary promoting city transformation processes to obtain a better use of renewable resources, reducing wastes and safeguarding the environment [7], [8], while at the same time promoting the cohesion between citizens that are to be joined to obtain shared benefit in terms of quality of life.
As illustrated in Fig. 2, an Eco-Sustainable vision has to be at the base of any city transformation approach. This vision consists of promoting a respectful urban and industrial development, able to address current needs without compromising the capacity of future generations.

Fig. 2 City Eco-Sustainable Vision
The eco-sustainable approach has to be applied in several aspects and at several layers of the evolutionary process, such as mobility, environment, social services, as well as in the urban requalification.
In order to investigate the Smart Environment pillar of the Smart City evolutionary process, this paper proposes the adoption of the Smart Energy Grid technology to improve the energy distribution capability in an urban context and between citizen houses. In the proposed architecture, the nodes represent the energy exchanging points, and the transactions are provided and regulated by a dedicated Blockchain. The paper, furthermore, describes the mobile application that has been implemented in order to enable the citizens access to the Blockchain network. Following sections describe a definition of the Smart City characteristics in Europe, and an overview on the Smart Energy Grid, giving a detailed vision on the MicroGrid on which the proposed architecture is actually based. The following sections provide an explanation of the main concept of a Blockchain technology, and finally the implementation of a Smarter Energy Grid, based on a dedicated Blockchain network will be illustrated.

A. Smart Cities definition in Europe-State of the Art
More than half of the major European cities have planned and achieved the evolutionary process towards a smarter city, this result emerges from the report commissioned by the European Parliament in order to provide background information and advice on Smart Cities in the European Union (EU) and to explain how existing mechanisms perform [9].
The above-mentioned report not only sketches a detailed map of the major European Smarter Cities, deployed as illustrated in Fig. 3, but provides a set of recommendations to promote the development of new innovative initiatives grouped by five fundamental categories, as shown in Tab. 1 [9].   (see Tab. 2), each characteristic is defined by a number of factors, which are described by a number of indicators. All factors and indicators have been defined in several workshops and European events having as goal the overall target, in other word the Smart City development.
All these studies have helped to develop the current and clearer Smart City definition, that may be considered as based on the six characteristics above-mentioned: a) A city may be defined a Smart City if use innovative connectivity model and high technology-based infrastructure to enhance its economy efficiency, promoting social, urban and cultural development. b) A Smart City must be attractive and friendly towards the new business realities that intend to promote urban progress. c) A Smart City must promote social inclusion, allowing a homogeneous development along the entire city. d) A Smart City must invest in high technology-based instruments and in the educational process finalized to create high skilled profiles. e) The people, in the meanwhile of this evolutionary process, must be encouraged to use modern technologies. f) A Smart City must consider the social and environment sustainability the most important strategy to pursue. [10] II. MATERIAL AND METHOD

A. Introduction to the Smart Energy Grid
This section deals with the main concepts of the Smart Energy Grids technology and focuses on a particular integrated system that allows their implementation: the MicroGrids.
The advanced technologies at the base of power electronics and microelectronics, the availability of high performance computational platforms, developed by use of innovative models [11], and the so-called intelligent algorithms, together with a series of new methodologies to produce and conserve energy (accumulators and renewable sources), have enabled the diffusion of a new concept in the energy field: the Smart Energy Grids (SEGs).
The SEGs are composed by integrated fault-tolerant ICT high technology-based systems able to improve the consumers quality of services, guaranteeing the needs of consumers by minimizing cost, waste of resources and environmental impact.
As said above, the performance of SEGs are strictly related to enabling information technologies, and highperformance telecommunications network for the exchange of data between nodes. These high-level requirements require network automation and smartness and, consequently, a massive use of techniques related to the field of Artificial Intelligence (AI).
The presence of energy renewable resources, although with some limitations, allows for locally distributed energy production.
The concept of MicroGrid, as a particular case of SEGs, has been thus introduced in order to describe a portion of an intelligent network able to maximize the use of renewable energy resources and, at the same time, able to satisfy the energy demand from consumers.
In particular, the MicroGrid does not necessarily have a significant geographical extension. Indeed, it may be considered as a simplex home configuration where there is: a photovoltaic production, a storage device and a series of users such as household appliances.

B. SEGs definition
There are several definitions of Smart Energy Grid (SEG) in literature. In [12] a SEG is defined as the next generation power grid. In the traditional power grids, power is generally carried from a few central generators to a large number of users or customers. In contrast, smart grid uses two-way flows of electricity and information to create an automated and distributed advanced energy delivery network that is clean, safe, secure, reliable, resilient, efficient, and sustainable [12], [13].
SEGs are characterized by a two-way flow of electricity and information and are capable of monitoring everything from power plants to customer preferences to individual appliances. This technology incorporates into the grid the benefits of distributed computing and communications to deliver real-time information and enable the nearinstantaneous balance of supply and demand at the device level [14]. The introducing of communication protocols, electronic devices and other ICT technologies in the power grid imply new features [13]: • The integration heterogeneous electrical generation and storage systems using simplified interconnection processes and universal interoperability standards to support a "plug-andplay" level of convenience.
• The born of new electricity markets ranging from the home energy management system at the consumers' premises to the technologies that allow consumers and third parties to offer their energy resources into the electricity market. • The possibility of real-time monitoring and diagnosing implies a reduction in the business losses currently experienced by consumers due to insufficient power quality. • The improving of load factors, lower system losses, and dramatically improve outage management performance. • The Real-time monitoring of components of the power system enables automated maintenance and outage prevention. In addition, SEGs can play an important role in several contexts as the global warming, the increasing of Energy request, the diffusion of electrical cars and the DER (Distributed Energy Resource). SEGs will solve several problems that actually affects traditional Energy grids Traditional energy grid presents several limitations. It is composed on Power plants, transmission lines, sub-stations for the high to medium voltage energy transformation and the consumer loads that represent passive nodes. The balance of production and consumption is a necessary requirement for stable and reliable power grid operation. Overprovisioning (or under consumption) of electric power induces frequency jumps, while under provisioning implies frequency drops. Excessive frequency deviations result in malfunctioning on both producer and consumer side, and this may induce a chain reaction finally resulting in a blackout, i.e. a grid collapse [15]. Another problem affecting traditional Power grid involves renewable energies. The integration of renewable energy represents a problem for the actual Power grid. Their production has a drastically higher volatility than traditional energy producers, and this, among others, implies the need for increased efforts related to power grid stabilization. If no measures are taken, the increase in volatility will exceed the available control energy [16] .

C. SEGs architecture
SEGs are composed on the following main elements: • Active Network Management (ANM): They are a mix of software, automation and control systems that monitor the grid in real time to ensure it remains within its operating limits [17]. • Dynamic Line Rating (DLR): They enable transmission owners to determinate capacity and apply line rating in real time [18]. • Automatic Voltage Control (AVC): They ensure that voltage and power factor of the specific buses are within the preset values and reduce the power loss of the grid due to unnecessary reactive power flow [19]. • Phasor Measurement Unit (PMU): Electronic devices that measure AC phasors and synchronize these measurements under the control of GPS reference source [20]. , and means to integrate the collected data into software application platforms and interfaces [22].

D. MicroGrid
The MicroGrid concept assumes a cluster of loads and micro-sources operating as a single controllable system that provides both power and heat to its local area.
They can generate power from both renewable and conventional. MicroGrids are controlled through a MicroGrid controller incorporating demand-response so that demand can be matched to available supply in the safest and most optimized manner [23], [24].
The core of MicroGrids is the Microsource corollers. This device must be able to perform several operations: • Control of Real and Reactive Power • Voltage regulation through droop • Frequency droop for power sharing In the last few years, the digital systems allowed such devices to perform an increasing number of more and more complex operation [25]- [27]. This complexity requires hardware increasingly efficient in terms of computational power. Several FPGAs based controllers have been presented in the literature [27]- [29]. In such context is interesting to investigate the possibility to use mixed architecture composed by a microprocessor and a Hardware accelerator [30]- [32], or alternatively, the use of distributed simulation to evaluate the performance of such complex systems [33], [34], [35], [36].

E. Blockchain Technology
A Blockchain is a digital contract that allows a partner to conduct, and invoice, a transaction (eg a sale of electricity) directly (peer-to-peer) with another partner. The peer-to-peer concept requires that all transactions must be stored on a computer that is part of a network composed by suppliers and customers who participate in transactions (see Error! Reference source not found.).
The Blockchain is an emerging ICT technology that offers new opportunities as an example it provides the transparent and user-friendly applications needed for realizing the process of energy consumption [37].
The Blockchain technology has been developed as a verification mechanism for cryptocurrencies but recently many studies exploit this technology to realize many different applications. Blockchain-based systems are basically a combination of a distributed register named "ledger", a decentralized consensus mechanism, and some cryptographic security measures. These systems, in combination with smart contracts [38], may revolutionize the functioning of transaction systems and enable fully decentralized market platforms [39]. The centralized model has worked well for many years, but considering the increase of the amount of the data exchanged during the transaction, there is a risk that the servers becoming bottlenecks and a single point of failure, thereby making them vulnerable to attacks.
An otherwise, the Blockchain is capable of creating a highly secure, independent and distributed platform.
The Blockchain is a peer to peer, distributed ledger system that stores all the transactions taking place within the network.
The main purpose of the servers that are a part of the distributed system is to provide a consensus, using different consensus algorithms, about the state of the Blockchain at any given time and to store a copy of all the transactions taking place. The consensus mechanism is one key concept of the Blockchain, it is able to avoid the dissemination of corrupted information. In a public and permission-less scenario, i.e. a system without access restrictions, the provision of new information needs to be associated with a certain amount of resources. E.g., the proof-of-work (PoW) consensus mechanism requires participating nodes to solve a numerical problem. Thus, it creates (computational) costs for adding new information, i.e. the next block [38].
Thus, less costly consensus mechanisms may provide efficient alternatives. E.g., hash-based user authentication allows agents to vote on the correctness of new information based on their unique identification, also called Proof-of-Identity (PoI) [40].
A Blockchain provides a distributed software architecture that enables agents (human or artificial) to interact without a central governing institution.
However, despite the absence of intermediaries, the Blockchain-based systems always rely on the correctness of the predefined rules, and thus it is crucial to ensure security, reliability and accuracy.
The Blockchain technology is still at an emergent stage and address with a variety of problems (e.g., limited transaction loads), furthermore many issues are still open as the complexity of protocols and the implementations and represents a challenge for researchers, practitioners, and users.
The use of Blockchain technology in energy markets was first introduced in 2014. Existing literature focuses on specific characteristics of Blockchain-based energy markets, such as cryptocurrencies, privacy, and state estimations. Existing implementations are related with some small-scale electricity markets.
Current applications of Blockchain technology can be divided into three broad categories based on their stage of development (i.e. step 1.0, 2.0 and 3.0). Bitcoin 1.0 is the deployment of cryptocurrencies for the applications related to currency transfer, remittance, and digital payment systems. Bitcoin are the best known Blockchain application, however, although more and more users are adopting the cryptocurrency with increasing trading volumes, the Bitcoin transactions in international currency markets are still minimal. Currently, there is no indication that Bitcoin can ever approach the achievement of the size of other international currencies.
The "Blockchain 2.0" consists of enabling "intelligent contract" models. An "intelligent contract" represents a digital protocol that automatically executes the default processes of a transaction without requiring the involvement of a third party (e.g. a bank). An example in SEG is to create a fully automated intelligent contract between an energy producer and a consumer who independently and safely regulates both the offer and the payment. If the customer does not make the payment, the intelligent contract automatically suspends the supply until the payment is received, in case of that the partners had previously agreed to include this mechanism in their contract. This development poses a threat to traditional banking business models, which could risk being excluded from the payment market segment.
Companies and developers can decide to build their applications on public or private Blockchains. On a public Blockchain, the identity of all participants remains anonymous. Bitcoin and Ethereum are examples of this kind of applications.
In private Blockchain systems, instead, all participants are known and identified before having access to them. Some advantages of private Blockchains allow for simplified governance structures and can be managed at lower costs than public applications. Banks and payment service providers are therefore required to use private Blockchains for their existing business models. This, among other reasons, will allow them to maintain a certain degree of control and potential financial income. The new generation Blockchains, called "Blockchain 3.0", are still in development.
The Blockchain 3.0 vision includes the concept of an improved "intelligent contract" in order to create decentralized autonomous organizational units that rely on their own laws and operate with a high degree of autonomy.
The Blockchain 3.0 applications are related to the currency, finance, and markets, particularly in the areas of government, health, science, literacy, culture, and art.
The Blockchain 3.0 era will begin with this two consensus engines: the Tendermint engine made by Jaekwon, the main developer of Cosmos hub and the Graphene engine made by Daniel Larimer, the main developer of EOS, Steem, Bitshare. Recently, researchers investigate the possibility to address the complexities and the continuous expansion of a Blockchain system by the exploitation of the Big Data related technologies. The potentialities of the combination of Big Data and Blockchain are very interesting and representing the future of Blockchain based systems.
One of the most advantage of the introduction of Big Data technologies in Blockchain are related to the improvement of accuracy and security of data. Both of these features are defined as core aspects of the Blockchain model. Sharing of data will become simpler and more frequent as security and originality is ensured by Blockchain implementation.
More recently, automatic decision-making support systems [41], [42], [43], [44], [45], [46], [47] have experimented a rapid development. In this environment, the Blockchain represents a useful instrument to record the activities and decisions by performing the proof-of-work required for adding a confirmed block to the chain. Furthermore, the machines can be used to develop the proofof-work for a mining process. The applying of Machine Learning techniques can be exploited to detect any irregular and illegal activities that might be occurring on the Blockchain, at real time. Hence, Machine Learning and Blockchain should have many synergies and interactive applications. The two systems can work together for data mining and security.
When Big Data-based AI platforms are brought into a Blockchain implementation, the way that the systems work can be continually evaluated by way of a complete and total record of all decisions.
Data harvested from sensors are exploited by AI systems for analytics and decision-making can be monitored in multiple points when the process is put through a Blockchain model.
As said above, this paper explores the Blockchain technology in general and propose an innovative synergy between this emerging technology and the Smart Energy Grid, as better detailed in the following sections.
The management of energy, water and natural gas are increasingly relying on sensor networks, low-level digital control and high-level decision support.
Semantic-enhanced Blockchains can strongly support visions like the Smart Grid, as they provide both resourceoriented discovery processes and a robust ledger for contracts and payments, which are needed in large-scale peer-to-peer decentralized marketplaces.

A. Smart Energy Grid based on Blockchain Technology
In this section, an innovative application of the Blockchain technology will be proposed. As said above, the aim of this paper consists of demonstrating that the Blockchain may play an important role in facilitating communications, transactions and security among the stakeholders that are involved in a Smart Energy Grid, providing an enhanced system called Smarter Energy Grid.
The proposed enhanced solution allows the creation of a decentralized energy market that can significantly shift the balance of expenditure towards energy investments of distributed resources, while creating a potential redistribution of electricity to new energy market stakeholders, differently from the way the electricity is currently distributed and regulated (see Fig. 5). The impacts arising from the use of Blockchain technology within the SEGs are substantial for this field of application.
From the business point of view, the Smarter Energy Grid By will help creating a decentralized energy market, in other words, the most disruptive scenario for the electricity market, where the combination of Blockchain technology and communications enabling technologies will facilitate secure transactions and payments between millions of actors. In this scenario, the inherent nature of the Blockchain system could allow distributed users selling energy without problems to neighborhood consumers. An example of this architecture is shown in Fig. 6. In New York City, the startup called TransActive Grid has created this type of peer-to-peer energy sales network based on Blockchain technology, in which homes with solar panels on their roof are able to sell energy to neighbors on the same road devoid of solar systems.
A non-negligible impact that has to be considered concerns the network structure itself. The possibility of carrying out transactions in the energy markets for every localized peer in the system would probably lead to a greater shift towards technologies that allow distributed networks. These will include smart devices, as well as Internet of Things (IoT) devices, electric vehicles, as well as energy resources such as solar roofs, energy storage and even fuel cells. The effect of this digital transformation will see a positive impact by improving as a natural consequence the reliability and efficiency of the network itself, matching the demand and supply of electricity, regulating the energy price in real time and reducing the costs of transmission and distribution infrastructures.
Technical Architecture The Blockchain technology combined with the use of the Internet of Things (IoT) enabling technology will allow the negotiation of distributed energy transactions. Furthermore, by using wireless or wireline data links distributed over the mesh network, useful real-time services for the consumers will be available, such as information regarding the excess energy consumption. Consumers will be able to automatically respond to their feeding needs. The advantage using a Blockchain-based ledger consists of allowing vendors and consumers energy transactions, while actors do not know the identity of each other.
Considered the above-mentioned assumptions, it is possible to design the establishment of different "Blockchain Smart Grids" enabled on a local or regional basis, as shown in Fig. 7.
To implement this scenario, the authors have designed and deployed a typical architecture, illustrated in Fig. 8, in which several devices and electrical equipment are needed to implement all designed functionalities. As shown, the residential building is equipped with a set of photovoltaic panels, directly connected to a local inverter, which is attached to a solar energy counter able to transmit data outside the building through a WiFi Router. The solar energy meter is also connected to a dedicated energy accumulator (EA), that may be remotely managed through a specifically implemented app called "Blockchain_SEG App", as better described below. In the middle of the architectural configuration a Bidirectional Energy Counter (BEC) is located, managed by the same app and connected to the energy accumulator.
The BEC is able to instantly decide when providing energy to the domestic appliances using the energy stocked in the EA and when instead the energy supply has to be acquired from the MicroGrid. The user may also choose to resell the energy eventually stored in the EA at the current sales-rate, by selecting one of the energy companies enrolled in the shared Trading Platform (TP).
Obviously, the TP may be reached by each user that has joint the Blockchain network.
The successful sale determines the update of the Blockchain ledger, storing the parameters of the successful financial transaction between the user of the MicroGrid and the chosen energy supplier.

B. Blockchain_SEG Application
The app that has been developed to reach the Trading Platform using the ad hoc Blockchain technology, is composed by a set of main functionalities (Fi), such as: • F1 -Activity Monitor -Once logged in, the user will be able to view a set of parameters in real time, such as the instant energy consumption of the domestic equipment; the energy produced by the photovoltaic panels; the energy absorbed by the network (MicroGrid); details on the percentage of energy used (own production and MicroGrid), and a sliding graph containing the trend of defined parameters over time (see Fig. 9).
• F2 -Activity Plant -The "Plant" functionality allows the user to geo-localize the own system within the MicroGrid, obtaining its technical characteristics and allowing to detect, at the same time, the presence of any faults. • F3 -Blockchain -Through the "Blockchain" functionality, the user may visualize the quantity of energy stored with the accumulators and select one of the available Energy supplier in the Trading Platform, obtaining the corresponding daily salesrate; once the Company has been chosen, the user can indicate the quantity of energy to be sold among the MicroGrid and previously visualize the final sale; after defining the revenue of each transaction, the user can authorize the sale transaction, whose parameters will be recorded in the Blockchain ledger. • F4 -Archive -Through the "Archive" functionality the user can consult the daily operating parameters of his system (energy absorbed by the system, taken from the MicroGrid and produced by the plant) and the data of the transactions relating to the sale of energy. This paper has dealt with the proposal of an innovative high technology-based architecture in the Smart Environment Pillar of the Smart City evolutionary process. In particular, the improvement of the Quality of Life (QoL) and the enhancement of the Quality of Services (QoS) for the citizens of a Smarter City has been addressed by this paper, proposing a disruptive synergy between the so-called Smart Energy Grid and the emerging Blockchain technology. Indeed, it has been proved that it possible to make cities smarter promoting innovative solutions by use of Information and Communication Technology (ICT) for collecting and analysing large amounts of data generated by several sources, such as sensor networks, wearable devices, and IoT devices spread among the city.
In this context, this paper has investigated the aspect related to the implementation of SEGs for citizens in the urban context. The disruptive effect deriving from the synergy between SEGs and Blockchain has been proved proposing a complex architecture. Finally, the implementation of a dedicated simple mobile application has been illustrated, that allow the final user to join the grid, exchanging information, and buy/sell energy between the involved nodes (energy providers and private citizens), using the Blockchain granting ledger.