Real-time monitoring of the prototype design of electric system by the ubidots platform

In this paper, a prototype DC electric system was practically designed.  The idea of the proposed system was derived from the microgrid concept. The system contained two houses each have a DC generator and load that consists of four 12V DC lamps.  Each house is controlled fully by Arduino UNO microcontroller to work in Island mode or connected it with the second house or main electric network. House operating mode depends on the power generated by its source and the availability of the main network. Under all operating cases, the minimum price of electricity consumption should satisfy as possible. Information between the houses about the operating mode and the main network state was exchanging wirelessly with the help of the RF-HC12. This information uploaded to the Ubidots platform by the Wi-Fi-ESP8266 included in the Node MCU microcontroller. This platform has several advantages such as capture, visualization, analysis, and management of data.  The system was examined for different cases to verify its working by varying the load in each building. All tested states showed that the houses transfer from one mode to another automatically with high reliability and minimum energy cost. The information about the main grid states and the sources of the houses were monitored and stored at the Ubidots platform.

A smart energy home is a significant part of the smart city. It is playing a substantial role in the proceeding toward the smart grid [8]. It can be considered as a nanogrid since it contains a generation and distribution system. The capability of homes is advanced to export the extra power to the main grid. This interaction between homes and the main grid is leading to improve the performance of the residential neighborhoods because of the possible expectations in reducing the needing to energy consumption which increases the efficiency and reliability of the system [9].
The internet of things (IoT) techniques provided the required management and monitoring functions for smart homes [10]. IoT means a very huge number of physical devices containing sensors and can connect with the internet to assist the exchange the information around the world [9]. IoT allowing to control and monitoring devices remotely across the internet, creating an enhancement in the quality, accuracy, and economic advantages as well as increasing human welfare [11].
IoT cannot achieve its function without middleware software called IoT platform. This software is considered an important part of the IoT system since it fills the gap between the equipment sensors and data networks [12]. There are several IoT platforms used for IoT applications such as Flutter, Kinoma, Kaa, Carriots, Temboo, and Plotly [6]. Each platform gives useful and particular services and features. This paper focuses on building a prototype smart electrical system that can be monitored in realtime using the Ubidots platform. The idea of the proposed system was derived from the concept of the smart grid. The system is consisting of two virtual homes each has its DC source and they can operate in two modes (Island mode and grid-tied mode). The statuses of the main grid and the sources of the two homes can be monitored remotely by laptop or smartphone using the Ubidots platform.
The remaining sections of this paper are structured as follows: Section 2 offers related works. Section 3 describes the block diagram of the proposed system. Section 4 illustrates hardware components while section 5 introduces software requirements. Section 6 offers a practical circuit implementation. Section 7 discusses the cases studied and results. Finally, section 8 offers conclusions and future works suggestions.

RELATED WORK
This section is a survey of some existing literature related to the work introduced in this paper. Since this study concern with the smart microgrid which consist of numerous smart homes, therefore; some studies related with smart home appliances control, management, and monitoring are summarized. Also, papers dealt with the smart microgrid, IoT applications Ubidots platform and MQTT Protocol are introduced.
Ting Zhu et al. [13] suggest an alternative structure whereby neighboring homes share electricity directly, in order to balance local production load demand in a microgrid. It was developed a novel energy sharing method to define which houses will share energy to reduce system losses. Yoon-Sik et al. [14] designed energy optimal management for smart-grid. The priority of supplying energy is from the neighboring energy supplier to the energy requesting user. When there is extra energy from the provider, the smart-grid as being the closest to the requesting user allocates the optimal energy to that user so that it increases his satisfaction. Kesavan et al. [15] used the Ubidots platform to monitor smart home conditions with the help of four sensors (Gas, Flame, Sound, and Temperature sensors). The data sensors send to the Ubidots Platform using the Arduino UNO board with help RFID. The work is designed and implemented to take prompt action by alerting the smartphone of any unusual situation with no effort from a human. Adhikaree et al. [16] suggested IoT application for a multi-agent system for residential DC-microgrid. The system consists of five smart homes that help each other to mitigate the peak load of the microgrid and to reduce the energy cost of the consumed by homes. Furthermore, an efficient communication technique was suggested by applying message queuing telemetry transport (MQTT) protocol via MQTT brokers. The proposed method was implemented and validate using five Raspberry pi controller.
Chenghua et al. [17] designed a hierarchical model construction to define the key parts and techniques involved in peer to peer (P-to-P) electricity commerce. A P-to-P direct energy trading platform was simulated between peers using game theory. The system was tested in low voltage grid-tied microgrid and the results show that energy commerce between P-to-P is fit to enhancement the local balance between generating and consuming power. Moreover, the ability to decrease the drawn energy from the main grid and increase the benefit of P-to-P from energy trading between them. Nachiket et al. [18] designed real-time monitoring and control of grid power information remotely in an efficient and secure manner employing remote cloud server. Also in the paper, the requirements for the grid security against overloaded conditions were stated. The grid parameters such as power, voltage, and current are observed continuously remotely and then control them to prevent overloaded conditions and help to detect the grid failure at the earliest. The work represents the first step towards the future smart grid. Selman [19] designed a monitoring system for a single home and electric network using Ubidots platform. The home operates either in grid-connected mode or in Island mode according to the load conditions of the home and grid. The two operating modes are controlled

BLOCK DIAGRAM OF PRPOSED SYSTEM
The block diagram of the prototype electric system is shown in Figure 1. The description of the system is summarized as follows: − The system is consists of two virtual houses and each contains DC power source (usually renewable sources such as solar panel). − Each house has an Arduino UNO microcontroller that controls its loads and operating mode (Island mode or connect mode with other house or with the main grid). There is an electric connection between the two houses to exchange the power between them directly and also they are connected to the main grid. These two houses can import or export power from/to the main grid according to the generations of the houses and their loads. − A load of each house represents by four 12 VDC lamps each has a power of 10 W. − The two houses are linked wirelessly with each other and with the Node MCU board using RF technique that was connected to every Arduino boards. The information of the houses and the statuses of the main grid is sending to the Internet cloud via the WiFi module that built-in with Node MCU. The data of the system can be opened and monitored from anywhere by using a smartphone.

HARDWARE COMPONENTS 4.1. Arduino microcontroller
The core part of the system design here is Microcontrollers. All sensors and loads are connected with them. Microcontrollers are sending and receiving the data between them using RF-HC12. The Arduino UNO microcontrollers used in this study because they are cheap, operated with many platforms, and have their own integrated development environment (IDE). Arduino UNO board perform the following tasks: − Wireless communication data between the two houses and with the Node MCU using RF module − Real-time transferring data to the LCD display − Automatic control of the operating mode of each home.

ESP8266 node MCU
Node MCU is a firmware board that supports to achieve prototype IoT projects. It has the ability to transfer or receive the data to or from the cloud. It includes ESP8266-WiFi integrated with the ESP12 unit. It supports the Arduino programming language.

Sensors
A voltage sensor (VS) is used to sense the availability or not of the main grid. Here, a voltage divider is used to do that. While the current sensor (CS) is used to measure the load current of the house. ACS712 CS is suitable to measure the load current of each house. It can measure ±20 A current (AC or DC).

Radio frequency (RF) module
RF-HC-12 modules are a multi-channel wireless transceiver module that can create a wireless connection between many Arduino boards through distance about 1 km. It is proper to provide coverage around houses. It jointed with an external antenna.

LCD display
A 20x4-LCD displays have been employed in the system to show the conditions of the grid, house source, and load current.

Relays
There are different sizes of relays and they used according to the load connected with them. Here, an 8-Channel relay is connected to the Arduino Uno board to switch the house loads.

SOFTWARE REQUIRMENTS
The software is divided into two sections. The first relates to the control side. In which, the Arduino board is programmed to collect data about the sensors and manage the loads and operating mode. The second is concerned with the communication side which represent the important part of this study. In this part, the exchange of data between the system parts is managed and uploaded to the internet cloud for monitoring them remotely. The following steps are summarize the software algorithm: a. Before executing the program, initialize all required libraries, such as ESP8266WiFi, Ubidots, ESP8266, and LiquidCrystal_I2C libraries must be set up first. All serials and ports are initialized and the Arduino pins modes are set. Also, Ubidots token, WiFi SSID, and password have been defined. b. The data sensors are defined and processed by Arduino UNO of each home, c. These data are transferred and received via RF to the Node MCU, d. The data is uploaded to the Ubidots platform to monitor and store.
The program continually reads the data for managing and store it for use in the future study of load and generation forecasting for the system. The following subsections illustrated the main software requirements of this system:

Ubidots plateform
Ubidots is the cloud platform of the IoT applications [20]. It provides a simple and secure method for sending and receiving various sensor data to and from IoT devices using the global cloud network in realtime. Ubidots provides a firm platform for hobbyists, innovators, and professionals which enables them to prototype and scale IoT projects for production. Ubidots has many benefits and features such as [19], [21]: a. Useful for capture, visualization, analysis and management of data. b. The Ubidots GUI is simple and easy to use. c. Ubidots offers users and operators access to Apps anywhere there is an Internet connection. d. Data stored in it are secured and protected and only users with permission can reach this data.
To communicate node MCU with Ubidots platform the following main steps should be performed: Step 1 : Setting up an account in Ubidots.
Step 2 : Create a device name.
Step 3 : Setting the variables in Ubidots. In this step, the required variables in the system are created. Take a note of the variables written in the Ubidots are the same ones used with the code written in the microcontroller. In this work, four data values will be uploaded to the Ubidots platform via the node MCU-ESP8266 (namely: The state of the main grid of home-1, The state of generated power of the home-1, The state of the main grid of home-2 and The state of generated power of the home-2).
Step 4 : Authentication where every packet requires a TOKEN. Notice that the Token written in the microcontroller code is the same as the Ubidots account.

Machine to machine (M2M) communication
M2M communication counted as an essential section of the IoT. It represents the independent interaction of a large number of processing and actions without human intervention [19], [20]. The communication system given here employs the two following IoT communication protocols: a. Message queuing telemetry transport (MQTT): MQTT is one of the most common protocols used in IoT applications [22]. The protocol operates over transport control protocol (TCP)/ internet protocol (IP). It provides lossless, ordered, and bi-directional connections and has many additional features that make it perfect for M2M and IoT applications such as small messaging size, require little bandwidth, easy to implement in software and fast transmit data in real-time [23]. b. Using publish/subscribe processes for data exchange between clients and servers. c. Hypertext transfer protocol (HTTP): It is an IoT protocol and represents a secure version of HTTP, which transmits data between the user and the website that is connected to it. It is commonly used and in almost all software applications with a TCP/IP. This protocol is designed to support different devices in the application layer Laptops, and phones, [24]. HTTP provides reliable communication and employed to transfer large quantities of tiny packets. Figure 2 shows the architecture of communication part of proposed system. The data of current and voltage sensors for each home are collected to read by the Arduino UNO microcontroller, and then these data send wirelessly to the Nod MCU via RF (HC-12) module. The data between Arduino and Node MCU are exchanged in a sequential manner over the communication channel [25]. With the help of the WiFi module included in the Node MCU, the data are sent to the MQTT Broker where all data about the sources of the homes and the main grid are collected and stored. The Web server receives updates from the MQTT Broker and writes them to a database. The network users get all data from the Web server.

PRACTICAL CIRCUIT IMPLEMENTATION
For simplicity and to perform the main objective of this study, which include transferring data to the Internet cloud and monitor them in real time using Ubidots platform, a 12 V DC system was designed. Four lamps each have 10 watts power were used in each home to represent the load. The lamps are controlled manually to interpret the change in the load during the day in the system. The transition from the Island mode to the grid-connected mode or to the connection with the second home is fully automatic and illustrated as follow: a. When the generated power of the homes is greater than its load, the homes supply the extra power to the grid or any part in the system needs power. b. When there is a power deficit in one home, and excess energy is available in the other home, the priority of receiving energy is from the home that has excess energy (because the presumption in the suggested system that the cost of energy imported from neighboring home is less than the energy imported from the grid). c. When the generated power in both homes is less than their load, the required energy is provided from the main grid. d. When the main grid is unavailable and the generated power of each home is insufficient to operate all the loads in it, only the necessary loads are operating and the home works in the Island mode. The supplied DC power for each home is obtained from an external DC source. The supplied power is controlled and determined by microcontroller programming according to all cases mentioned above. It is changed programmatically to satisfy the operation of the proposed system under all conditions and to simulate the PV solar power that varies changed according to weather conditions. An image of the final design of the system is depicted in Figure 3, and the complete circuit of the system designed in this work is given in Figure 4.

CASES STUDIED AND RESULTS ANALYSIS
In this section, four cases are studied to test the operation of the prototype system designed in this study. Case 1: Grid available and generated power>load for each home: In this case, both homes generate power greater than their loads (two lamps operate only in each home). Figure 5(a) gives the results that appear on the Ubidots platform which represents home conditions and grid. The generated power of each home where they appeared by fully charged batteries, i.e. there is extra power available in each house. Also, the electric grid is presented clearly. The screen picture of the LCD display is given in Figure 5(b). Table 1 illustrate the meaning of the symbols that appear on the LCDs of each home.  Case 2: Grid available and (Generated1>load1 & Generated2<load2): In this case, Home-1 generates power greater than its loads (only one lamp operates as a load) and Home-2 needs power (three lamps operate). Because the presumption price of energy imported from neighboring home is less than the energy imported from the grid, thus, Home-2 is equipped with the necessary energy from the Home-1. Figure 6(a). Gives the results that appear on the Ubidots platform which represents both homes and grid conditions. The battery of Home-1 is full which represents the extra energy found in this home while the battery of Home-2 is not full which represents the home needs power. Figure 6(b) illustrates the private LCD for the two homes. Table 2 illustrate the meaning of the symbols that appear on the LCDs of each home.  Home-2 received power from Home-1 Signal sending from Home-1 A Home-1 export power to Home-2 feeding of Home-1 loads CELL* Home-1 supply its load and surplus power is sent to the Home-2 feeding of the Home-2 loads CELL*+HOM1 Home-2 loads are fed from its source and from the Home-1 source.

5575
Case 3: Grid unavailable (Island mode): In this case, the main grid is not present because a disturbance and the power generated in each house is present. Here, assuming that each house can only supply its own load and does not have surplus power. Therefore; each home will operate in Island mode and only necessary loads will work for each home according to its generative power (here only one lamp has been assumed to operate in each home to implement this case). Figure 7(a) gives the results that appear on the Ubidots platform which represents the status of the homes and grid. As illustrated from the figure, the battery of each home is available but the grid signal is unavailable. Figure 7(b) gives the LCD display of each home. Table 3 illustrate the meaning of the symbols that appear on the LCDs of each home.  Home-2 received power from Home-1 Signal sending from Home-1 A Home-1 export power to Home-2 feeding of Home-1 loads CELL* Home-1 supply its load and surplus power is sent to the Home-2 feeding of the Home-2 loads CELL*+HOM1 Home-2 loads are fed from its source and from the Home-1 source.
Case 4: Grid available and homes generated unavailable (or homes generated power<load): In this case, power generation in both homes is less than the load and they depend entirely (or partially) on the electrical network for supplying electrical power. Figure 8(a) gives the results that appear on the Ubidots platform which represents the status of the homes and grid. As illustrated from the figure, the battery of each home has no power but the grid power is available. Figure 8(b) shows the detail of the state. The two homes receive power from the grid. Table 4 illustrate the meaning of the symbols that appear on the LCDs of each home.  Home-2 import power from grid Signal sending from Home-1 D Home-1 import power from grid feeding of Home-1 loads GRID Home-1 loads are fed from Grid feeding of the Home-2 loads GRID Home-2 loads are fed from Grid

CONCLUSION
In this paper, a prototype DC electric system was proposed to clear the concept of the microgrid. The work focusses on the remote monitoring of the system data by using the Ubidots platform. The designed model comprises two virtual homes each have 12 V DC source. Four lamps of 10 W were assumed to represent the load for each home. The energy exchange between the two homes and the main grid is controlled by Arduino UNO. To confirm that the implementation of energy management for the system is efficient, different cases were performed by varying the number of lamps that operate in each home to interpret the change in the load during the day. Practical tests for all cases have been implemented and the results show that the system could operate efficiently under all conditions automatically. The management of the energy of the system was performed to reduce the cost of electricity as possible. The data of the grid condition and the home sources are monitored remotely and stored in a secure manner with the help of the Ubidots platform. The designed system in this study is the first step towards designing a practical system that is closer to the real microgrid system so that every house is equipped with solar panels and according to the loads in the house and it works on a system of 220 volts.