# Optimum System for Diagnosing Power Quality in Electrical Microgrids
## 3 Developed Electrical Measurement Network
### Description of the Developed Communication Network  
This subsection details the hardware and software elements that form the communication network. It describes each hardware component used in the development of the network and explains how the communication between these elements is established. In addition, a flowchart outlines the steps from the initial data collection request to the receipt of data on the host computer. Finally, the configuration for multi-node measurements and the mechanism employed to achieve synchronized measurements are presented. Figure 4: The prototype of the SDMD. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Value** \\ \hline Voltage range & 0–400 V \\ Current range & 0–30 A \\ Resolution & 156 \(\mu\)V \\ Supply voltage & 4.5–16 V \\ Communication & RS232 \\ Dimension & 199 \(\times\) 116 mm\({}^{2}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Specifications for the proposed SDMD. The SDMD is programmed to transmit and receive data to and from a single board computer (SBC). It acts as a bridge between the SDMD and the host computer, which is responsible for initiating requests and processing data collected from a microgrid node. As SBC, a Raspberry Pi(r) 4 Model B (Raspberry Pi Foundation, Cambridge, UK) is used. The communication between the SBC and the SDMD is via the RS232 interface. The RS232 is a standard protocol used for serial communication. The serial interface operates in half-duplex mode. In addition, the baud rate is 57,600 bps, and the data are transmitted in a frame of 10 bits (1 start bit, 8 data bits, and 1 stop bit) in hexadecimals. Therefore, it is necessary to convert the data from hexadecimals to decimals for further processing. To achieve this, a computer or another SBC, referred to as the host computer, can be used. The host computer used in the use case is described in Section 2.3. Communication between the SBC and the host computer is wireless. Both are connected to the Internet using an RJ45 cable and share the same local area network (LAN). Using a LAN has several benefits, including data security, reduced interference and noise affecting data transmission, easy and fast communication, and the ability to connect devices to the same network without requiring a physical connection among them. The WebSocket protocol is adopted for establishing real-time bidirectional communication between the server (SBC) and the client (host computer). This protocol is mainly used in web browsers and IoT applications. Once the connection is established, both can transmit messages to each other at any time, even simultaneously. The connection between server and client continues until one of them stops it. In contrast to other protocols like HTTP, the WebSocket protocol does not need to transmit messages via request or response packets. In short, the protocol adopted is one of the most convenient for SBCs due to its easy implementation, lower network bandwidth usage, and high performance in terms of transmitted bytes and required time. The robust, portable, and extensible communication network, which integrates the SDMD, the SBC, and the host computer, is represented in Figure 5.  
After describing the hardware elements and the communication protocols used among them, the steps from the initial data collection request to the receipt of data on the host computer are outlined. The communication process for requesting and collecting data from a microgrid node is illustrated in Figure 6. This process involves a single SDMD, a single SBC, and a host computer, but the number of SDMDs and SBCs can be increased depending on the microgrid nodes, following the same procedure. Figure 5: The developed communications network, including the SDMD, the SBC, and the host computer. The process begins with setting up a WebSocket server on the SBC, defined by an IP address and a port number, and implemented in Python 3.12.1 [51]. Once the server is created, it waits for a connection request from any client.