Energy Blockchain for Public Energy Communities

: This paper suggests an application of blockchain as an energy open data ledger, designed to save and track data regarding the energy footprint of public buildings and public energy communities. The developed platform permits writing energy production and consumption of public buildings using blockchain-enabled smart meters. Once authenticated on the blockchain, this data can be made available to the public domain for techno-economic analyses for either research studies and internal or third parties audits, increasing, in this way, the perceived transparency of the public institutions. A further feature of the platform, starting on the previously disclosed raw data, allows calculating, validating, and sharing sustainability indicators of public buildings and facilities, allowing the tracking of their improvements in sustainability goals. The paper also provides the preliminary results of a ﬁeld-test experimentation of the proposed platform on a group of public buildings, highlighting the possible beneﬁts of its widespread exploitation.


Motivation
The public institution's transparency in pursuing policies coherent with their sustainable development goals can be highly increased if the energy consumption and/or production of these buildings or facilities is automatically and publicly shared on a secure and reliable platforms [1], allowing, on the other hand, to verify the results of the investments made in that direction. In addition, this data-set can be monitored by citizens and shareholders, which can identify critical issues and suggest possible improvements. These analyses can help understanding the use of public money, monitoring and assessing global progress in the quest for sustainable, affordable, reliable, and modern energy services in the public sector. Moreover, the availability of such data can be used for research or testing purposes, for internal or third parties audits of sustainable targets. Another possible great advantage connected to this approach is that the sustainability evaluation and planning algorithms can be published and certified on the blockchain by the developers and building owners and/or operators. After doing this, it is possible to automatically calculate and publish data on the blockchain itself, making them available to stakeholders and decision-makers to continuously track economic and environmental indicators along the time.
In this context, the Authors would propose an application of blockchain as an energy open data ledger platform which, starting from disclosed raw energy production and consumption data of public institutions, allows calculating, validating, and sharing sustain-ability indicators of public buildings and facilities, as well as tracking their improvements in sustainability goals.

State of the Art
In recent years, many advancements have been made in using the blockchain as enabling technology for the development of smart energy grids and local energy communities (LECs) [2][3][4][5]. Indeed, the availability of a completely independent and trusted third party allowed the sharing of certified information among the participants, enabling the possibility to reach a peer to peer (P2P) consensus on the optimal use of local resources [6][7][8]. These advancements are of particular interest when coupled with smart grid management and control technologies, which can provide fast and autonomous systems able to manage the operation of electricity systems. For example, in Reference [5,9], the authors highlight the effective increasingly use of blockchain architectures in more and more use cases related to P2P distributed energy trading in smart grids.
Blockchain represents a tool able to address the current needs of the decarbonization, decentralization and digitalization of the power sector, with a strong push towards enhancing the role of final consumers. The potential application of blockchain technology in future energy systems can be divided into two main categories of problems: (i) electrical energy and services trading in power markets; and (ii) renewable energy certification and active user tracing (demand response applications and flexibility services offered by prosumers) [10,11].
Blockchain technology is a set of shared and distributed data structures, or ledgers, capable of securely and automatically storing digital transactions without the need for a central authority. Thanks to its evolution compared to the first applications in the field of cryptocurrencies [12], its potential in many sectors is now recognized, particularly where it can be used in conjunction with other technologies, such as artificial intelligence, the Internet of Things (IoT), and advanced sensors and smart metering devices. In fact, while many of the processes related to power exchanges can also be carried out with first generation measurement devices and traditional centralized IT systems, the transition to the blockchain is necessary for the complete performance monitoring in future electrical systems. In particular, the use of the blockchain is unavoidable for managing and sharing real time data with the users of the electricity system (distribution system operators, traders, producers, and final customers), to ensure complete traceability of operations and verification of the requirements required for the provision of energy services.
Definitely, blockchain-based platforms are of particular interest to small locally managed grids where the existence of a human led control center is hardly sustainable from an economic point of view. This is the case of LECs, formed by a small group of users, which would benefit from high-level automation of network management to develop local energy markets (LEMs) and P2P energy trading optimizations [6,[13][14][15][16].
Despite the great advantages connected to the implementation of distributed ledger technologies, there are still different issues that act as a barrier to their practical application. One of the main difficulties is privacy concerns since the users' consuming (or producing) habits cannot be removed from the blockchain once written. Although different promising efforts have been made in this field, the effective impossibility to remove this data from the ledger still pose significant concerns to the effective feasibility of the process, especially in relation to the new legislative norms in terms of personal data protection [9,[17][18][19][20][21].
Anyway, the privacy concerns arising for residential users do not apply to public buildings and facilities. Contrarily, the public disclosure of this data can become a great advantage for both the society and public institutions [1,22,23].

Contribution of This Paper
In the presented paper, a blockchain-based ICT platform which will enable the access of public institutions, citizens, and stakeholders to the energy related environmental and economic Key Performance Indexes (KPIs) of the Public Sector is proposed.
The proposed platform is composed by blockchain-enabled Smart Meters (BSM) which will work as nodes of an ad-hoc blockchain. This blockchain will be a public distributed ledger for open data regarding consumption and production data of LECs public buildings. The availability of this raw data will enable the possibility to analyze this data and publish quantitative evaluations and KPIs regarding the current usage and management of existing resources. This will make it possible to track the environmental indicators of every building part of the project during time, improving their transparency and allowing the evaluation of the efforts of each institution in improving its carbon footprint.
The proposed research has been applied to a group of public buildings, located in an Italian municipality, and arranged to operated as an LEC. The tested public buildings were equipped with BSM able to register their consumption and production on a distributed ledger platform. On the base of the energy data readings, the sustainability of the buildings is analyzed and evaluated permitting to define the possible improvement in the building management.
The results show that the availability of a decentralized platform for sharing open data in public-based LECs can improve public institutions' transparency and energy sustainability. This, in turn, can be used to investigate and find better solutions to public LECs deployment, enabling strong positive feedback between private, public, and research sectors.

Materials and Methods
This paper focuses on defining a framework of data transparent LEC of public buildings and facilities [24]. The proposed framework is based on the installation in the LEC buildings of BSMs, which can store registered energy consumption and/or production on the public ledger. The public ledger is then used as a public and open database [12,25]. On top of this open data, different scenarios are studied to optimize and manage the installed resources to maximize self-consumption and reduce emissions.

Validated Sensor Power/Energy Values Readings as Open Data on Distributed Ledgers
The proposed platform wants to exploit IoT and blockchain technologies for finding a solution to the existing societal, environmental, and ethical issues which arise from the current limited open data and transparency efforts made by public administrations.
In particular, this paper wants to propose a direct application of distributed ledgers for enabling open data of public institutions. The existing projects in this field show several difficulties which have been only partially solved by the existing technologies [5,22], such as: The availability of certified open data has always been a central point for the improvement in research and transparency; nevertheless, few repositories of this type exist, and none of them are maintained and populated enough. The centralization of the control of these repositories, being it public or private, can be seen as one of the main reasons of this, since their value tend to decrease if the interest and support of the maintaining party decreases (or terminate, in case of public grants).

2.
Commonly, the available open data is given in aggregated form, mainly provided and analyzed by the providing institution and does not exist on a public platform in which it is possible to analyze the raw data in a common format, as well as peer review the performed evaluations.

3.
The data is not provided in real time, and it is very hard to obtain data which is certified as completely reliable and provided in a common standard data type, and 4.
the upload of open data is completely voluntarily and not automatic, since the data should be acquired, evaluated, and reshaped before sharing it on the existing repositories. This effort can be very difficult to perform since not all institutions have the resources to properly perform such tasks.
In this context, the proposed platform wish to solve this issues creating a decentralized platform not relying on a central managing authority, able to provide certified (by the certi-fied meters) raw data in standardized formats. In addition, the same platform will enable the calculation of elaborated data coming from the raw one, provided by recognizable trusted parties, published on the blockchain and subject to peer review. Finally, the upload of the raw data will be made in a completely automated way from the installed smart meters, overcoming the need of an internal effort in the institutions, and simplifying the sharing of the information.
The BSMs, smart meters enriched with a blockchain enabler module, will work as distributed nodes of a multi-channel platform built for metering and acquiring energy and power and, finally, storing the readings on a distributed ledger. These BSMs combine "classic" smart metering capabilities and the ability to store and share consumption (and production) power/energy readings with the possibility to write this information on a decentralized, trustful and immutable blockchain platform [6,26].
They can either work as a full or light node, depending on the available connection and bandwidth (more details about this choice are given in Section 3.2) [25].
The availability of reliable BSMs in each building of the LEC allowed the sharing of production and consumption data of the public buildings in which they are installed. Once certified and timestamped on a distributed ledger, this data can be made freely available to the interested audience, aiming to verify and control public good use [12,25,27].
In the proposed approach, BSMs will have a double role: smart meters for the metering of users' production and consumption, and blockchain nodes. The BSMs, distributed among the participating institutions, will work as blockchain nodes, ensuring the decentralization of the process. In addition, having access to the blockchain, they will be able to save the readings of their sensors on the distributed ledger. A scheme of this vision in given in Figure 1.

LEC Sustainability KPIs
The schematic of the proposed platform is given in Figure 2. One of the main advantages of the proposed platform is using the publicly disclosed data for performing evaluations of the respective institution sustainability. In particular, KPI calculations algorithms can be made available and saved on the blockchain as open-source code. These algorithms can be used by the community and directly applied to the production and con-sumption data already existing on the platform. In this way, it is possible to automatically calculate and share these results participating in a public institution in nearly real-time. In addition, the resulting KPIs can be shared back to the blockchain. Since the algorithms are open, these calculations can be verified again by the community and shareholders, creating entrusting feedback that leads to community proposed and validated analysis of the public institution behavior in terms of energetic and environmental sustainability.   Some basic KPIs, commonly adopted in the specific application context, have been applied to the data obtained from the test site readings available in the blockchain to introduce this possibility [28,29]. The proposed KPIs are the total cost for the system and the total carbon emissions. C(t), the total system cost at time interval t is calculated with Equation (1). Here, B i (t) is the cost of energy bought from the grid by building i. S i (t) is the gain obtained by building i from the selling energy to the grid. PV a i (t) and ES a i (t) are the amortization costs of the PV sources and of the energy storage systems installed on each building i. The amortization costs of each device i have been included in a simple formulation, since they were not the core of the research. For this particular case, these costs have been calculated on a linear base assuming a fixed device lifetime, and the (constant, daily) amortization costs have been added on daily basis on top of the computed costs. These amortization costs, for each device i and for a time interval ∆t, namely A i (∆t) have been calculated as shown in Equation (2), where I i is the initial investment, and LT i is its expected lifetime. All the quantities are calculated for the selected time interval t.

Public buildings
E(t), the total emissions of CO 2 of the system, are calculated with Equation (3). The emission factor EF has been chosen to be equal to 444.4 g CO 2 /kWh, as calculated by the Italian Institute for environmental Protection and Research in Reference [30].
where E b,j (t) represents the energy bought from the grid ([kWh]) at time t from the building j, while set I represents the building set, in which are considered the library, the sports club, the City hall, a primary school and a police building. These KPIs have been initially calculated for the current situation. From an energetic point of view, each building is managed independently from the others, despite their geographical and electrical proximity. In this setup, each building buys energy at retail price and sells it at wholesale price. If a building has the ability to sell energy in the hours of higher production from renewable and low value in the market, and needs to buy it back in hours when the price is higher, significant diseconomies occur, as shown in Figure 3.  As a second scenario, the public buildings federate into an LEC, where over and under generation are settled among the LEC participants. In this case, the possibility of exchanging energy among LEC participants allows matching over generation and under producing buildings, avoiding losing money by asynchronously buying and selling energy with the grid. In fact, the system energy costs, in this case, are equal to zero, as shown in Figure 3. In public buildings, the balance of this cost is effectively zero for all the participants, considering all the buildings of Public ownership. In the third scenario, the LEC behavior has been tested supposing the existence of a battery based energy storage system (BESS). The BESS is managed on the base of Equation (4), under the constraints in Equation (5). In the equations, π G and π GE are the energy purchasing and selling price, whilst E G is the energy bought from the grid and E GE is the energy exported to the grid. SOC(t) and P S (t) are the state of charge and the BESS power output at time t. SOC min and SOC max are the minimum and maximum states of charge of the BESS. P S nom is the BESS nominal power. Finally, η is the BESS efficiency.

LEC Description
The analyzed LEC is composed of five different public buildings in the municipality of Carloforte, that is located in the Isola di S. Pietro (Sardinia), as shown in Figure 4. The whole island is 51.1 km 2 large, and hosts the city with 6190 people on the eastern coast of the island, as shown in Figure 4. The public buildings taken into consideration are the local community core buildings, which are the city hall, the primary school, the police building, the sports club, and the library. The buildings show the typical consumption pattern of public buildings, with increased and almost stable consumption in the daylight hours and small and flat consumption during the night. All the buildings are situated on the same feeder, and they have the ability to produce energy through photovoltaic systems (PV). This, especially in summer and in this geographical position, means that the time interval of maximum consumption is highly correlated with the PV production window. The current installed power capacity in the buildings is reported in Table 1.

Implementation Report
The BSMs have been installed at the Point of Common Coupling (PCC) of each building to monitor both the production and the consumption. The blockchain enabling module has been connected to the building internet cabled connection, which generally offers enough bandwidth for exchanging the necessary data.
The benchmarking performed in this paper has been made by making use of prototypes of Bithiatec PRO Smart Meters with the hardware and firmware programmed as BSMs. A picture of the equipment is shown in Figure 5. These BSMs are designed to continuously save bidirectional (incoming, outcoming) data of active and reactive power and phase angle measurements, both in single and three-phase mode. The measurements are

On-Site Installation
The on-site implementation of the BSMs showed some installation problems which were hard to identify on the laboratory testing. The experienced communication issues and failures, especially in one of the test sites, suggested the need for a backup connection procedure, not needed on laboratory testing. For this reason, a backup GSM connection was implemented in the devices that created further issues in the data lifecycle management.
In particular, each blockchain component has been initially designed for working as a blockchain full node [25]. This means that each device stored all the blockchain data in its memory, thus exchanging a high amount of data with the blockchain P2P network. This approach ensured better data security and reliability. However, the GSM connection does not provide enough bandwidth to sustain this approach, so the architecture has been changed to switch to a light node approach when working with a GSM connection [31]. The light nodes do not have the total blockchain saved on their memory, so it was impossible to validate the state of the network in total security. In addition, the light nodes exchange only the proofs of the transactions in the Merkle tree form [31], which is, at least in principle, less secure. On the other hand, the exchange of the Merkle tree data requires far less bandwidth and local memory.
Thus, the architecture of the BSMs has been changed so that it could switch between full and light node when the available connection was cabled or GSM, respectively. This change in architecture allowed reaching better QoS and stability.
The distributed ledger used for test purposes is a private test version to avoid the definition of a public ledger at this point in the project with the intention to identify a safe and cost-effective solution among the available public chains.
As a first result, the smart meter measurements, extracted from the blockchain and related to the measurement campaign of 15 July 2020 are shown in Figure 6. The smart meter can register measured data with 1s step but was programmed to record and save data every 15 min, and, as depicted in Figure 6, the power generation shows the typical profile of PV generator, which increase its production during the middle hours of the day, particularly in summer. Although the power generation of the whole energy community has a profile well aligned with the typical production profiles, the power consumption is extremely variable and barely predictable due to the nature of the analyzed buildings.

LEC Analysis and Management
The availability of transparent data related to the energy consumption and production data of public buildings permits economical and environmental analyses, which can be performed by research institutions or stakeholders. The application of the methodologies described in Section 2.2 to the Carloforte dataset can be seen as an example of the opportunities created by the approach suggested in this paper. In order to calculate the KPIs, lifetime and installation costs of PV generators have been considered 20 years and 1500 /kWp, respectively. In addition, BESS lifetime and installation costs have been set as 5 years and 300 /kWp and 200 /kWp.
As a first result, the KPIs regarding current energy supply costs and emissions of the public buildings have been calculated for the whole year on the base of the raw readings data extracted from the blockchain register. In order to understand the impact of the existing renewable sources, the KPIs have been saved on the blockchain and compared with a benchmark scenario without renewable generation. These results are shown in Table 2. Furthermore, the economic and environmental impact of the individual buildings with the current installed capacity has been compared with the same indicators in the presence of an LEC. This has been done by comparing the respective KPIs defined in Equations (1) and (3) for the different tested scenarios. The results as saved on the blockchain, are shown in Figure 7. As shown, the existing PV production sources are already causing an emission reduction of 16.37% and an economic gain of 20.28% with respect to the absence of renewable energy scenario. However, if the buildings federate into an LEC, this profit would reach a value of 27.24% and an emission reduction of 27.09%.

LEC Planning Results
Another feature of the proposed platform is the exploitation of the open data available in the blockchain for the planning of possible improvements in management approaches or infrastructure upgrades. As an example, the proposed KPIs have been calculated by varying the PV installed capacity in each building, in the case of no-LEC management and LEC management, as described in Section 2.2. The proposed KPI calculation methods have been shared on the blockchain. In addition, an automated calculation has been performed and written on the blockchain.
The results, shown in Figure 8 show that 30 kWp cumulative installed PV capacity would provide a compromise between initial costs and sales earnings. In particular, as referred in Equation (1) with the purpose of maximizing self-consumption and profit for the whole community, such configuration allows getting a cost reduction of 22.67% with respect to the current no LEC scenario. Even better, the cost reduction can increase to 32.72% when the buildings are federated into an LEC. The optimized size for each building are reported in Table 3.  The KPIs show further improvements with the introduction of a BESS, as described in Section 2.2. The results are depicted in Figures 9 and 10. The best results, shared and retrievable by potentially everyone on the blockchain, take into account both KPIs. They have been observed for installed capacities between 45 kWp and 75 kWp, with a power to capacity ratio of 2. Within this interval, the smart LEC management would yield a cost reduction from 60% to 80%, when installing BESS sizes of 2 kW/4 kWh. Moreover, this configuration highlights an emission reduction between 50% and 60%, with respect to the current scenario.

Discussion and Conclusions
The results show how the disclosure of production and consumption data of public buildings can be used for enhancing the transparency and sustainability of their respective institutions by means of a blockchain-based platform. Once identified, the tested sites have been equipped with BSMs able to write their readings on a blockchain-based certified and immutable ledger. In order to provide an idea of the possible outcomes of the proposed approach, the disclosed data has been analyzed in order to identify KPIs regarding the current economic and environmental sustainability of the system and to identify and suggest possible improvements. As a first suggested improvement, it has been found that the creation of an LEC of the considered buildings will decrease the system economic costs by 27% approximately, and emissions by 27.09%. Moreover, the availability of public data allowed for the performance of simple planning scenarios, which proved that it would be possible to reduce the annual energy costs of the LEC by 22.67%, by increasing the installed PV capacity. This, in turn, would also reduce the LEC emissions by 32.72%. Finally, it has been proven that the installation of community energy storage, together with the increase of the capacity, will further decrease the sum of CAPEX and OPEX by 70% on average with respect to the current situation.
An interesting feature of the proposed framework comes from the fact that, in principle, the ledger can be made public, and everyone can access the disclosed data, analyze it, and propose infrastructure improvements. Even better, the proposed optimization algorithms can be published on the blockchain, making them available in an open-source fashion. In this way, once validated by the community, they can be used for performing automated evaluations of the data disclosed by the buildings. These evaluations, in turn, can be published on the blockchain and possibly get verified by other peers, which can reproduce the calculations and validate the results. In this way, it is possible to obtain a constant evaluation of the good public performances in terms of performances in sustainability and green economy. This will allow the stakeholders to understand the efforts made by public institutions in improving their sustainability, stimulating at the same time discussion and research efforts around their behavior. In addition, it will highly increase the institutions' transparency and will make it much easy to evaluate the impact of public sustainability incentives.
At the current state of the research project, the blockchain has been kept private since too few nodes (the public building smart meters) were providing computational power for securing the chain. For this reason, reading and writing to the existing data are only available for the certified entities. In the next future, when more institutions will participate to the research, and more and more nodes will be added, it will be possible to safely turn the blockchain to the public domain, making it accessible to every willing institution and stakeholder without the need for external permissions. In addition, the authors wants to notice that extending the area of application of this solution, both in terms of number of participating institutions and data types, will for sure meet technical difficulties in terms of scalability and applicability of the solutions. From this point of view, there is a strong likelihood that the possible application of new blockchain solutions, such as sidechains and sharding, can be a possible solution for these issues [32,33].