Blockchain outlook for deployment of IoT in distribution networks and smart homes

Nowadays, unlike depleting fossil fuel resources, the integration of different types of renewable energy, as distributed generation sources, into power systems is accelerated and the technological development in this area is evolving at a frantic pace. Thus, inappropriate use of them will be irrecoverably detrimental. The power industry will reach a turning point in the pervasiveness of these infinite energy sources by three factors. Climate changes due to greenhouse gas accumulation in the atmosphere; increased demand for energy consumption all over the world, especially after the genesis of Bitcoin and base cryptocurrencies; and establishing a comprehensive perspective for the future of renewable energy. The increase in the pervasiveness of renewable energy sources in small-scale brings up new challenges for the power system operators to manage an abundant number of small-scale generation sources, called microsources. The current structure of banking systems is unable to handle such massive and high-frequency transactions. Thus the incorporation of cryptocurrencies is inevitable. In addition, by utilization of IoT-enabled devices, a large body of data will be produced must be securely transferred, stored, processed, and managed in order to boost the observability, controllability, and the level of autonomy of the smart power systems. Then the appropriate controlling measures must be performed through control signals in order to serve the loads in a stable, uninterruptible, reliable, and secure way. The data acquires from IoT devices must be analyzed using artificial intelligence methods such as big data techniques, data mining, machine learning, etc. with a scant delay or almost real-time. These measures are the controversial issues of modern power systems, which are yet a matter of debate. This study delves into the aforementioned challenges and opportunities, and the corresponding solutions for the incorporation of IoT and blockchain in power systems, particularly in the distribution level and residential section, are addressed. In the last section, the role of IoT in smart buildings and smart homes, especially for energy hubs schemes and the management of residential electric vehicle supply equipment is concisely discussed.


INTRODUCTION
Since recent decades, power systems are experiencing revolutionary changes. Aside from the evergrowing development of technology in various parts of power systems, the insight into the way a power system must be expanded, managed, and operated is changed. The tendency to exploit more renewable clean energy is increased across the globe. This propensity is both in the integration of large-scale plants (such as wind farms and solar parks) and small-scale demand-side generation sources. By integration of such renewable energy sources (RES) in demand-side, the idea of microgrid has emerged. Microgrids are also regarded as a part of active distribution networks, in which the presence of resources and power injection electric vehicles (EV) with vehicle-to-grid capabilities are also taken into account. The power system planners are prone to enable small-scale and distributed sources, particularly those with low or zero air pollution to avoid further installation of large-scale fossil-based generation units. The complexity of power ISSN: 2088-8708  Blockchain outlook for deployment of IoT in distribution networks and smart homes (Heliasadat Hosseinian) 2789 smart devices' performance without any need for a centralized server. This peer to peer data exchange can be generalized among devices, humans, and things to maintain a trusted and fully distributed and decentralized digital infrastructure [27]. The high cost of construction of a new power generation plant, on the one hand, and the role of generating units in the power supply necessitate the construction of new plants and the maintenance of old units, which should be updated carefully and accurately [28]. Deficiency in the provision of sufficient generation capacity of Iran's power plants results in undesirable effects of electricity outages and unreliable supply, which sometimes causes severe damage to the economic, political, and social structures of the country. As a result, any possibility of cost-saving and improving productivity in the operation of energy systems and market development is prominence and worthy of investigation [29]. In this paper, in addition to the introduction of the fundamental background of blockchain and its types, the practical applications of blockchain in distributed generation systems are investigated, and ultimately, the ability to use this innovation in order to solve the challenges that IoT is facing with is examined. The extant researches conducted in this field are basic studies, and the roles of IoT and blockchain in future power grids are well matured and discussed in this study, and the structural applications of them are concisely presented. Besides, the benefits of the utilization of IoT in smart homes and smart buildings for the management of energy in the residential section are proposed.

BLOCKCHAIN'S BASIC CONCEPTS
Fundamentally, blockchain technology is a decentralized database that works on a peer to peer network and uses consensus algorithms for decision making, and network security is preserved by encryption methods. In other words, the data structure is a kind of library that may include digital transactions, data records, commands for controlling actions, or executable signals [30][31][32]. The data of a transaction needs to be verified through certain certifications corresponded with a growing list of encrypted records, which are called blocks, to avoid tampering with the data of digital documents. Each block is corresponded with its previous block to form a chain of records which determines the order of the events and is called blockchain. Most of the base cryptocurrencies, including Bitcoin, are working based on blockchain technology, but this technology can also be used in non-monetary transactions. For example, intelligent contracts-which were first introduced on the Ethereum blockchain-are activated on this platform, and when certain conditions are provided, these contracts are implemented automatically without human intervention [33][34].

Types of the blockchain
General, private, and consortium are three different types of blockchain which are described based on access permission and changelog capabilities.

General blockchain
The general blockchain is considered open source and totally decentralized. In this kind of blockchain, anyone has access to the information and can have a transaction and participate in the consensus process and voting. So far, the use of this kind of blockchain has been more pervasive because the consensus algorithm is a secured algorithm due to being open-source and trusted algorithm [35]. Open source blockchain is also referred to as Openchain and is targeted for enterprise purposes.

Private blockchain
Usually, private blockchain belongs to a specific person or a company which has read and write permission and verifies transactions [36]. This type of blockchain can be public at the proof of ownership. The underlying principles of this model is that in a private blockchain, the transactions are reversible, validators are authenticated, a hacker needs to manipulate 51% of the chain to change a block, thereby there is no risk of attack, transactions are cheaper, privacy has become more secure by restricting the issuance of permissions to read information, and consensus algorithm runs faster. This kind of blockchain is not completely decentralized. Therefore, it is more suitable for internal processes of companies such as database management, inspection, and auditing [37].

Consortium blockchain
This type of blockchain is controlled by specific groups, so only certain nodes in the network have permission to vote in the consensus process. This type of blockchain is somewhat decentralized, and the license can be issued publicly or limited [38][39]. It is also faster and more secure. Thus, it is mostly used in the corporate finance sector.

Proofs
In traditional payment systems, traditional banks are third parties, and they are trusted to keep transactions and financial balance. In contrast, blockchain is a consensus system without any need for centralized trusted authority, and it is distributed and also doesn't require any third party to verify. This matter is regarded as a prominent attribute of blockchain that defends against 51% attack. Considering that each member of the blockchain (each node) can have a copy of the information by itself and has the right to verify the information [40]. The important thing is that information of all members is equal and is constantly being updated. A consensus mechanism is needed in order to achieve this consistent consensus throughout the system. The structure of blockchain features secure be design using specific consensus mechanisms such as proof of work (PoW). There are also some different mechanisms such as proof of authority (PoAu), proof of understanding (PoU), proof-of-burn (PoB), proof-of-capacity (PoC) (also referred to as proof-of-space), proof-of-activity (PoAc), proof of validity proof of elapsed time (PoET), proof of importance (PoI), delegated proof-of-stake (DPoS) (also called proof of stack), and leased proof-of-stake (LPoS) [41].

Proof of work
In proof of work consensus mechanism, miners compete with the power-sharing of their computers to solve a "computer puzzle," which is hard to solve, but the result confirmation should be easy. This puzzle includes nonce determination. The nonce is a random string that is added to data in order to create different hashes. A hash function is a cryptographic tool that produces a specific code, which is called digest or hash value, for each input that can be text or massage. Changes in nonce change the hash in general. Usually, high processing power is used to solve this puzzle [42]. This process is called mining. As the computational power of the grid increases, blocks are created faster. The response to this change, which is defined by a threshold, is called the difficulty of the problem, and it is periodically adjusted in order to control the amount of block production. The first miner, who solves the puzzle will put the answer on the network to be verified by other members, and they receive rewards for finding the answer. The mining operation has two main goals in the process of base cryptocurrency. Verifying the correctness of network transactions and creating new digital coins as the mining rewards are the goals. A lot of energy is needed to handle this measure. This is the fundamental defect of the proof of work method. For instance, bitcoin transactions by 2020 will be as much as today's electricity consumption in Denmark [43].

Proof of stack
In proof of stack system, miners do not compete with each other. On the contrary, they cooperate with each other to keep a validation collection. In this method, anyone who has coins of a particular blockchain (e.g., Ethidium) must lock the coins as the deposit in the blockchain which is called stacks. Then network validators participate in the block creation process. In this system, the next block generator is selected randomly by the system. Therefore, anyone has more stacks has more chance of being selected. This method has an overwhelming advantage according to proof of work method. It doesn't need computerbased computing, and it reduces energy consumption, which ultimately leads to a reduction in the final cost [44]. If anyone thinks about defraud, all their stacks will be seized, and they will be dismissed from the system. Since there is no computational operation in this system, there is no bonus for generating a new block, and only the transaction verification fee is charged. This algorithm is still being upgraded.

Proof of validity
The proof of validity algorithm is based on the principles of the authenticated identities or validators on the blockchain, and they don't need to compete for completing transactions. By using this new algorithm, all participants in a collective agreement are known and valid. The proof of validity algorithm appears very successful in the output, and it is optimized for private networks. Therefore, this mechanism will be incorporated in blockchain unlikely due to its centralized nature.

BLOCKCHAIN'S APPLICATION IN DISTRIBUTED GENERATION
The decentralized structure of blockchain is proportional to the decentralized control approach and business processes at the local level and distributed generation. The operators of the energy sector and the experts in corresponding companies believe that blockchain is capable of solving the challenges of the distributed energy system in the future [45]. One of the fundamental challenges is decentralization and digitization of emerging energy systems which requires investigating, discovering, and accepting new methods and technologies. Transactions in the energy sector are considered different from the financial sector because the delivery of electricity to the customers and subscribers should be considered physically.

2791
These transactions are not only about price and information value but also about energy trading transmitted through the network infrastructure. In this section, some blockchain projects are provided for distributed generation. Most of these projects are developing or tested as prototypes, and they are not yet fully commercialized.

Power ledger
Power Ledger is an energy commerce network that operates peer-to-peer on the major cryptocurrencies and renewable energy exchanges in blockchain in Western Australia. Power Ledger platform provides interoperability between various mechanisms of market management, pricing, and electrical measurement units (kilowatt per hour) through purchased tokens. It also controls the market by two-token ecosystems in two blockchain layers (SParkz and POWR) [14].

PWR company
PWR Company works in peer-to-peer commerce of renewable energies. Household equipment of this company stores energy in long-life batteries instead of immediate energy sell in order to stabilize the network. This project is currently running on the Ethereum platform, but according to the proposed roadmap, in the near future, it will be transferred to its base cryptocurrency (PWRtoken) which is based on energy. A PWRtoken is equal to 1 MW, which can be exchanged in global trading markets [15].

Key2energy
The main idea of Key2Energy is that many apartments offer their self-produced solar energy instead of using power from the grid. This offer is to their tenants at lower prices. Two factors are involved in this process: an attempt to maximize household income by selling produced solar energy in the local market at the best possible cost; trying to minimize the general cost of electricity, such as elevators and the lighting of the stairwells. For smart deals and contracts, the blockchain is used as a marketplace in this kind of structure [15]. In this context, the most prominent question is how to determine the role of operators of the transmission system, distribution system, and distributed generation sources [46]. These employees continue to carry out their duties in the physical infrastructure of the power grids, and they are also responsible because of the stability and sustainability of the system. These operators will receive their wages due to network maintenance and repairments. They keep being responsible for supplying the energy of decentralized energy transactions agreed between parties according to the limitation of the physical systems.

INTERNET OF THINGS BASED ON BLOCKCHAIN IN THE ENERGY FIELD
Internet of things is a sensible and practical way to connect many types of equipment to each other through specific software, sensors, devices, etc. Things include vehicles, home appliances, smartphones, etc. In this technology, all devices, which are connected to a network, are able to operate automatically. These devices are fully automated to maintain special responses based on environmental changes. They can also exchange various data with devices in other networks without any human interference [4]. Blockchain facilitates peer-to-peer digital transactions; thus, potentially they can activate machine to machine (M2M) communications and data exchanges between smart devices. Lots of smart devices will be connected to the internet (20.8 billion devices) by 2020 [10]. Smart devices and data transmission technologies are increasingly being used in the field of energy; power systems included. This incremental process, along with the automation power and massive data analysis, can potentially create a valuable energy chain in the energy sector [47].
A useful analysis of these data increases power system performance and asset detection, which can be led to considerable cost reductions. Digitizing electrical facilities provides an opportunity to improve network performance, billing processes, power supply chain, opportunity to explore new sources of innovation, and new business models. By increasing the number of devices that generate a huge amount of data in high frequency, the traditional centralized approaches will definitely be inefficient. Therefore, local decision making and distribution control can decrease the computational resources requirement, which is needed to optimized future power systems. Due to the decentralized structure, collaborative work, being open-source, and high security of blockchain, its performance can facilitate the use of the internet of things. Automated marketing factors, which are an integral part of smart devices, are able to determine ideal pricing strategies for energy trading through the blockchain platform based on the preferences and willingness of the user. These devices can be programmed to achieve predetermined goals, such as automatically increasing energy efficiency or minimizing energy purchases from the main network. The rules and suggestions made by each device are kept invalid and reliable databases, and certainly, they depend on the kind of registered information; some of them such as the privacy and anonymity of individual domestic and The generation sources are usually far from consumption centers. The loads have no interaction with the upstream grids, and the generation sources are usually installed in large-scale. On the contrary, in smart grids, particularly in modern blockchain-based secure grids, the power system is highly interconnected, and the demand-side virtual power plants satisfy part of demand locally. The loads can be served through local sources, and the energy exchange can be started after verification of the financial transaction. This measure must be done automatically and instantaneously. Thus, the validation of purchasers and sellers must be distinguished through the secure platform of blockchain. A load at a local level may be served by many energy providers in microgrids, virtual power plants, or demand response capacities nearby. Hence, a complicated financial accounting system must exist to handle such a massive number of high-frequency transactions fairly and accurately. This hurdle can be overcome by enjoying the technology of blockchain incorporating cloud computing techniques and IoT-oriented infrastructures.
Future power systems will be highly complicated and interconnected, in which a massive body of data will be generated and must be processed. A massive amount of microtransactions at a local scale for power trade between microsources and end-users must be handled so that the current structure and mechanisms of the banking systems are unable to deal with and process them. In such a condition, the employment of cryptocurrencies is indispensable. The massive body of data produced by IoT instruments and devices necessitates the incorporation of artificial intelligence techniques such as data mining, machine learning, big data analytics through a cloud-based environment for cloud computing. After the advent of power markets and restructuring and deregulation of traditional power systems, the incorporation of IoT in power systems, as the central core of the energy ecosystem, along with modernization, digitalization, and smartization of grids can be counted as the next revolution in power systems. In smart grids, the loads are more elastic, which means they are more responsive and price sensitive. The loads can be informed about the real-time prices through different IoT-based interfaces and can make better decisions, which indicate how should they participate in demand response programs. Figure 2 illustrates the paradigm of a blockchain-based smart grid with the integration of EVs, rooftop solar panels, small-scale wind turbines on a local scale. The loads have also informatic data exchange with the network to acquire real-time data of the grid's electricity price through smart meters. The loads have also remote controlling and intelligent automatic control over many equipment and devices that it helps to maximize the efficiency of the grid's operation and to optimize their consumption through secure informatic interfaces and platforms.

IoE IN SMART BUILDINGS AND SMART HOMES
The concepts of smart buildings and smart homes are viable solutions to perform efficient energy audit measures in demand-side. This matter will be materialized using the internet of energy (IoE) concept to manage various contributors corresponded with different energy consumptions for end-users such as electricity, gas, and heat. IoE is defined as a specific field of IoT that delineates the applications of IoT in the energy sector. The authors in [17] have presented an automated local market for a smart residential building in order to merge blockchain and internet of things in distributed generation.  Figure 2. The structure of a smart grid with the integration of demand-side microsources In this scheme, the roof of the building is covered by solar panels and all the smart home appliances are intelligent and flexible, and they are measured by bidirectional smart power flow meters. In such a building, blockchain can detect the power produced by each device and make it possible to exchange energy between different vendors and customers. In smart commercial buildings, IoE enhances the capability of building management system to boost autonomy and improve the controlling functions and optimize consumption in an efficient way. The connectivity provided by the IoE allows for the integration of automated systems and intelligent devices. Sensors for detecting motion, noise, moisture, temperature, humidity, fire and smoke, carbon dioxide and hazardous gases, security and access control systems all supply data and analytics in real-time.
The fast responsiveness of this system allows buildings to adapt to changing conditions and make real-time alterations that result in increased efficiency and reduced operating costs. Enjoying this information, building managers are able to anticipate the needs and consumption patterns of tenants, their preferences for lighting, heating or ventilation and have supervision on security systems, utility meters or water and waste disposal, to name but a few. Smart homes and buildings are addressed as a subcategory of smart cities. Regard to the proliferation of electric vehicles, particularly with V2G capability, the management of an extensive number of EVs which has highly volatile and stochastic consumption patterns is highly challenging. These are regarded as non-static mobile loads that can absorb or inject power to the grid everywhere in a power system. They can exchange power with the grid through public parking lots or residential EV supply equipment. Due to their highly unpredictable nature, it is recommended to monitor EVs in real-time in order to preserve the stability of the distribution grid. Thus, a cloud network must be accessible in a certain vicinity of the city to cover all EVs which are monitored by an operator enjoying IoT technology. The residential EV supply equipment is also in communication with an energy hub controller, which is responsible for optimizing all kinds of energy consumption and generation in a building or home while proper storage devices for electricity and heat are integrated. The energy hub controller gathers the instantaneous data of all equipment, loads, and the network through smart meters and IoT-based sensors [48]. To sum up, the integration of IoT technology in the residential section brings decisive advantages in terms of efficiency. As it is portrayed in Figure 3, an IoT-equipped smart home encompasses various parts such as a smart door lock system, security system, smart air conditioning, lighting control system, energy management system, appliance control system, smart thermostat, smart bathroom appliance, garage door opener, etc. One of the main parts of these subsystems is correlated with home appliances. Nowadays, home appliance manufacturers are equipping their products with modern devices which enable the device to be monitored and controlled remotely through a central controlling system and can have self-management capability to make decision how to deal with the upstream grid for the absorption of electricity at specific times, which leads to considerable cost reduction and energy saving. For instance, Zigbee protocol can be used in washing machines and dishwashers to start the machine automatically at the hours, when the grid's electricity price is at the lowest level.  Figure 3. The various applications of IoT in a smart home

CONCLUSION
Blockchain technology is a modern innovation that has the ability to be deployed in different sections of power systems, particularly for integrating small-scale distributed generation sources and making them smart to increase the observability, controllability, and the level of autonomy of distribution networks and microgrids. Currently, the most popular point of blockchain in the energy field is its secure environment for establishing peer-to-peer marketplace and bilateral trades. Hence, various scenarios have been proposed in this domain. These scenarios include establishing local energy markets in such a way that residents of neighborhoods exchange energy. In this paper, in addition to investigating the basic concepts of this technology, a variety of consensus algorithms have been investigated, and generally, there is a discussion about the public, private, and consortium blockchain. In the following, some of the existing startups which currently use this infrastructure are introduced in order to produce power through distributed generation and to trade energy. In the last section, in addition to introducing the technology of the internet of things, the collaboration of this technology with blockchain application is studied. Introducing these two technologies are inevitable in the energy field. The world is propelling into a smarter world with more intelligent systems, and the implementation of these infrastructures toward global progress and sustainable development is inevitable. With respect to the novelty of these technologies, future projects in research, simulation, and operation sectors will be more comprehensive and elaborated. For further studies in the future, some startups (SolarCoin, Bankymoon, Electron, PonTon, GridSingularity, these exchange, Dajie, LO3 Energy, NRGcoin, and Share & Charge) are proposed which are all active in the domain of blockchain's applications in the energy section, and can be analysed in detail for the employment for specific goals in power industry.