# An Efficient Interface for the Integration of IoT Devices with Smart Grids
## 4 Architecture
Figure 7 illustrates the use of the methods described in Algorithms 3 and A6 for an application environment using the ESP32 board as the gateway platform. We can see from the algorithms that packets from both protocols have their fields redistributed to the other protocol during mapping. This approach differs from the one used in the works mentioned above, which apply URI mapping. It is worth mentioning that the algorithms presented above (and in Appendix A) do not represent all the constraints imposed by the programming language and the libraries used, which mainly add complexity in the implementation. ## 5 Experimental Results

This section describes the materials and methods used in the development of the integration interface between CoAP and OSGP and presents and discusses the experimental results. ### Evaluation Platforms

To evaluate the proposed solution, we developed two experimental platforms. On the first platform (named PC-based), we implemented a gateway using a desktop computer and emulated two different CoAP clients, one using the Copper plug-in of the Mozilla Firefox browser and another client implemented using the libCoAP library. The test environment that simulated the gateway featured the Debian GNU/Linux 8 (Jessie) 64-bit operating system, Intel(r) Dual-CoreTM 2.5 GHz 64-bit

Figure 7: Sequence diagram for a partial read from the smart meter. processor and 4 GB of main memory. In testing, we measured the time to perform mapping on each communication, and verified and characterized function by function. For testing, we used varying OSGP packet sizes up to 114 bytes (the limit specified by the protocol). For CoAP, we adopted the same packet size in all communications, i.e., 512 bytes. Our goal with this experimental platform was to verify the proposed algorithms and validate the mapping layer using real CoAP clients. In the second platform (named ESP-based), we implemented the gateway using the ESP32 development kit from Espressif Systems (the acronym ESP comes from the name of the company) [36], ESP32 is a single 2.4 GHz Wi-Fi-and-Bluetooth combo chip designed with the TSMC ultra-low-power 40 nm technology. ESP32 is designed for mobile, wearable electronics, and IoT applications. It has a single or two Tensilica Xtensa 32-bit LX6 microprocessor cores with 448 KB ROM, 520 KB SRAM, and 16 KB SRAM. It also includes built-in antenna switches, low-noise receive amplifier, filters, power amplifier, and power-management modules. It is worth noting that ESP32 is open-source. The schematics and the printed circuit board layout are freely available to be used as a reference for developing fully-customized ESP32-based hardware designs. Using the ESP32 platform, we emulated a scenario in which a CoAP client (e.g., a smartphone) sends requests to the gateway in order to obtain information from the OSGP domain, as well as responds messages sent by the emulated OSGP-based device (e.g., a smart meter). To carry out this evaluation, we used the Espressif IoT Development Framework (ESP-IDF) 3.3.1 environment. Our goal with this platform was to assess the performance of a low-cost and low-power embedded gateway and evaluate the feasibility of using the proposed solution in a real-life environment. ### Results

Table 2 summarizes the results obtained from the experiments performed using the PC-based platform, presenting the memory requirements for every packet and the latency of each mapping function. We can observe that the OSGP packets require less memory than the CoAP packets, which has the same size for all the functions. It is worth mentioning that all the tests were performed using packets with a 6-byte payload. Regarding performance, we can observe that the most expensive communication is the one that comprises the mapping of a CoAP PUT request to an OSGP Partial Write request (790 ns), and its corresponding response (470 ns). This worst-case mapping consumes 1260 ms for request and response.