Adaptive antenna system by ESP32-PICO-D4 and its application to web radio system

Adaptive antenna technique has an important role in the IoT environment in order to establish reliable and stable wireless communication in high congestion situation. Even if knowing antenna characteristics in advance, electromagnetic wave propagation in the non-line-of-sight environment is very complex and unpredictable, therefore, the adjustment the antenna radiation for the optimum signal reception is important for the better wireless link. This article presents a simple but effective adaptive antenna system for Wi-Fi utilizing the function of a highly integrated component, ESP32-PICO-D4. This chip is a system-in-chip containing all components for Wi-Fi and Bluetooth application except for antenna. Together with SP3T RF switch and dielectric antennas and high-resolution audio DAC, completed web-radio system is made in the size of 50 x 50 mm.


Hardware in context 1.1 Introduction
The recent drastic increase of IoT edge device leads to high congestion in the wireless communication. One solution for this issue is an adaptive beamforming. Adaptive beamforming and adaptive antenna techniques already have a long history and its effectiveness are well confirmed, nevertheless, they are rarely adapted for consumer product due to cost and circuit complexity.
Recently, the significant progress of semiconductor integrated circuit technology has enabled RF transceiver for Wi-Fi and Bluetooth in one package and eventually very powerful dual-core processor, flash memory for storage, SRAM for main memory and all peripherals are integrated into single package. The main chip of this article, ESP32-PICO-D4 is one kind of such a highly integrated chip. By using this chip, not only RF transceiver implementation but also fully programmable system is easily realized. This article presents a simple but effective adaptive antenna system for Wi-Fi utilizing programmability of the chip. Together with SP3T RF switch and dielectric antennas and high-resolution audio DAC, completed web-radio system is made in the size of 50 x 50 mm. As demonstrated in this article, the circuit will select one antenna for maximum RSSI to a given access point in the initial boot process and move to start the web radio system. The web radio system is based on two sophisticated codes [9][10] and station preset and selection can be made through a web browser.
The application of the implementation of adaptive antenna selection introduced in this article is not limited a web radio system but also various IoT application is expected.

Comparison to previously published designs
ESP32 series have a lot of users all over the world but the author could not find this type of application, combining with RF SP3T switch in the literature. The adaptive antenna system is widely reported in various articles but the two-chip configuration consisting of the system-on-chip and SP3T switch is the simplest implementation.

Comparison to commercial instruments
The adaptive antenna is not novel technology but rarely applied to consumer product from the viewpoint of cost. ESP32-PICO-D4 is a very recent chip (released on Aug. 2016) and at the moment of submission, just one simple prototyping board (Espressif's genuine board, ESP32-PICO-KIT V3) can be found on the market. The circuit in this article costs just $30 even including audio DAC, which is quite competitive to established commercial products. Fig.1 Block diagram of the whole system Figure 1 shows the whole system block diagram. The main processor is ESP32-PICO-D4, which is a system-in-package component. ESP32-PICO-D4 contains all components required for Wi-Fi and Bluetooth application except for antenna just in 7 x 7 mm package. The programming environment is well organized by Espressif, the manufacturer of ESP32-PICO-D4 and released on GitHub [1]. Table 1 denotes the summary of ESP32-PICO-D4 specifications. Together with RF part, the high-performance main processor is able to support complex applications.  Before embedding antenna part to the whole system, the sole antenna part consisting of an SP3T switch and dielectric antenna is designed and evaluated. Fig. 2 shows the antenna switching part schematic including three antennas and SP3T switch. Three dielectric antennas are 2450AT43B100 by Johanson technology [7]. Fig. 3 illustrates the solo antenna part PCB layout for characteristics evaluation. As shown in Fig. 2, the PCB contains "Dummy Audio Jack" which is not a member of antenna part. The distance between dielectric antenna element (ANT #1) and the audio jack is very close enough to have an impact on the radiation characteristics, therefore, the performance of antenna part is optimized and evaluated with this object.  Figure 4 shows the antenna testing board. In general, the impedance matching circuit should be designed according to each PCB layout [8]. As written in Fig. 2, inductance and capacitance are inserted at the terminal of an antenna element. These inductance and capacitance parameters are determined by measuring reflection coefficient using vector network analyzer for lowest reflection on 2.4 GHz ISM band.   fig. 4 for different antenna selection by the SP3T switch. As shown in fig. 5, this dielectric antenna element has relatively narrow bandwidth with matching section. As it can be seen, antenna performance of antenna 1 and 2 has frequency shift even with the symmetric arrangement as is in Fig. 4. This shift can be attributed to the existence of near-by "dummy audio jack" but this characteristic shift can be utilized for wider frequency operation co-operated by antenna #1 (lower band) and #2 (higher band). The antenna #3 could not be fully optimized for larger return loss but it exhibits -10 dB around 2.4 GHz ISM band.  In each case, the other antenna can complementary cover null radiation. The antenna #3 also covers the other antennas null radiation so very efficient adaptive radiation control can be expected by switching these three antennas depending on the communication condition. This antenna part is integrated into the whole system described in the next session.

Caution for Lipo battery operation
The energy density of Lipo battery far exceeds conventional NiCd or NiMH battery, therefore, short circuit or reverse connection is extremely dangerous. In addition, wrong selection of jumper on this board may lead to the dangerous situation. When on board Lipo charger disabled, never connect Lipo battery to the onboard battery connector. Lipo battery connection with "charger disabled" setting will apply 5 V to Lipo battery, which is beyond the maximum rating of the battery and it is quite dangerous. Fig. 8 Flow chart of the initial boot process of the system, where the optimum antenna element is selected by RSSI value for given SSID.

ESP32-PICO-D4 firmware
The completed system of this article realizes "web-radio" but before starting the web-radio application, antenna selection process is performed as shown in Fig. 8. As far as the author knows, RSSI of the established connection is not available from current Wi-Fi API in esp-idf [1], but during Wi-Fi scanning, RSSI of each SSID can be obtained from API. Therefore, the actual operation of "measure RSSI for given SSID" block of left side in Fig. 8 is performed by the following source code ( line 112 of app_main.c in "main" directory) , where "ssid2" is the SSID obtained during scanning and "ssid" is predefined and to be connected access point's SSID. Internally RSSI of all access points are obtained but only the RSSI in need is stored in ant_rssi[n]. Sweeping number "n" by the number of the antenna (here it is 3), RSSI for each antenna selection is obtained and the best antenna for connection link is determined.
After best antenna selection, web-radio program running on ESP32-PICO-D4 starts. The original source code implementing web-radio on ESP32 was written by MrBuddyCasino [9] and station presetting interface through web browser was implemented by n24bass [10]. The author of this article made an addition of OLED display support and the antenna switching and finding best antenna for communication link. The full source code is linked in this article. Firmware should be complied in Esprssif's programming environment, esp-idf, which can be found in [1]. The total components cost $28.84. PCB can be ordered to prototyping PCB service company less than $5 per board. Total cost of one board is less than $35.

PCB fabrication
By using Autodesk Eagle, the files required by PCB prototyping service company can be generated from the attached Eagle files (ESP32_BEAM.brd and ESP32_BEAM.sch). The minimum separation is 0.5 mm pitch of ESP32-PICO-D4's QFN48 package, which has well margin to all of PCB service.

Soldering process
General stencil-reflow process is enough to complete PCB. Executing "make menuconfig" under correctly installed esp-idf environment will provide the configuration window as shown in Fig. 9. In the submenu of "Web Radio / Bluetooth Speaker", SSID and password of the access point can be configured. After writing SSID/password, simply exit configuration menu and executing "make; make flash" will flash the firmware including all functions (Antenna selection, OLED, web interface, web-radio).

Fig. 10 Station pre-setting through web browser
After the boot process of the board including best antenna selection, web-radio will start. This web interface extension is implemented by n24bass [10] and fundamental part of web-radio is implemented by MrBuddyCasino [9]. As fully explained in Fig. 10, presetting station and its selection can be done through web interface. Not only the web interface but also pushing on-board GPIO 0 switch will change the preset station sequentially.  Fig. 10 (a) to (c) show the antenna switching operation, where RSSI are presented on OLED display by dB scale for each antenna selection case. It is not presented on the OLED display but these RSSI values are measured for the given SSID, corresponding one Wi-Fi access point link status. After switching antenna, the best antenna is determined (in this case, antenna #3) and starting web radio process. By the implementation by n24bass [10], the second line of the display shows the current receiving web radio station URL and the third line shows the IP address of the board, which is delivered by DHCP. The screen is not wide enough to show full information but the n24bass implementation realizes character scrolling to leftward. The full demo movie, from power on to music reception is can be found at https://youtu.be/tu75nzV8ipI