Skip to content

ESP-IDF🔗

Introduction🔗

Espressif provides the IoT Development Framework (ESP-IDF) for software development. This includes a multitude of examples that you can use as starting point for the software development.

Software, general information, and instructions are provided by Espressif on e.g. following web pages:

Warning

The PAN9520 is a radio certified module. There are conditions on hardware and software which must be met for the modular approval to be valid.

For detailed information please refer to PAN9520 Module Integration Guide at

This guide shows you how to set up and run a simple UDP server on the PAN9520 evaluation board and how to communicate with it.

Overview🔗

In general you can find information on starting the software development with the Espressif IoT Development Framework (ESP-IDF) for the PAN9520 in the official ESP32-S2 documentation from Espressif.

Also the PAN9520 evaluation board is very similar to the ESP32-S2-Kaluga-Kit, so you can find detailed information in the official ESP32-S2-Kaluga-Kit documentation.

Installation🔗

For any development you have to install Visual Studio Code and the official Espressif Visual Studio Code extension as explained in ESP-IDF with Visual Studio Code.

Step-by-Step🔗

The following requirements must be met:

  • You have setup the development environment as explained in Installation.

Espressif provides a tutorial that explains the Basic use of the extension and shows you how to setup up your first project.

However, the following sections summarize the contents of the tutorial and explain the bare minimum of what is necessary to get the UDP server sample application up and running.

Project Setup🔗

Press F1 to show all commands and choose the ESP-IDF: Show Example Projects action.

  1. Confirm the location of your installation in the Select framework to use input prompt by pressing Enter.

  2. The ESP-IDF Examples input prompt appears. Scroll down to the protocols / sockets section by pressing the Down key repeatedly and choose the udp_server example by pressing Enter.

  3. A new project configuration window opens. Press on the Create project using example udp_server button at the very top.

  4. A Select Folder input prompt opens. Choose an appropriate directory location for the new project, for example c:\esp\projects\udp_server .

Directory Location Name Restriction

Please note that spaces and special characters are not allowed in the name of the directory.

Configuration🔗

Press F1 to show all commands and choose the ESP-IDF: Set Espressif device target action.

  1. Confirm the location of the project in the Pick Workspace Folder to which settings should be applied input prompt.

  2. An input prompt appears. Choose ESP32S2 .

  3. The Enter OpenOCD configuration File Path List input prompt appears. Choose ESP32-S2-KALUGA-1 .

Now press F1 to show all commands and choose the ESP-IDF: SDK configuration editor (menuconfig) action.

  1. The SDK Configuration editor window opens. Choose the Example Connection Configuration section.

  2. Change the WiFi SSID and WiFi password in the Example Connection Configuration section to the SSID and password of a Wi-Fi network that is available.

  3. Change the WiFi Scan auth mode threshold in the WiFi Scan threshold section to the setting that is matching the setting of the Wi-Fi network, for example WPA WPA2 PSK .

  4. Use the Save button at the top of the window to save the new configuration.

Build🔗

Press F1 to show all commands and choose the ESP-IDF: Build your project action.

  1. The project build action takes a while, please be patient.

  2. From the View menu you can choose Terminal to make a terminal window visible that shows the verbose build output.

Program🔗

You can program the PAN9520 evaluation board using 3 different methods:

  1. JTAG

  2. Serial port

  3. USB (after download mode has been activated)

Here, you will use the serial port method.

The following requirements must be met:

  • You have installed a terminal application to interact with the evaluation board.

Note

If you do not have any terminal application yet, you can try Termite.

First you have to discover the serial port that belongs to the PAN9520 evaluation board.

  1. Connect the evaluation board to your computer. You must use USB Debug/Serial connector 7.

  2. Open a terminal application and open the serial port that belongs to the evaluation board. Choose the well-known 115200,8,N,1 configuration. If you don't know the right serial port, start with the first one that is available.

  3. Now press the SW1/IO0 boot button 2, keep it pressed, then additionally also press the reset button 9. You should see a boot message similar to this:

    ESP-ROM:esp32s2-rc4-20191025
    Build:Oct 25 2019
    rst:0x1 (POWERON),boot:0x0 (DOWNLOAD(USB/UART0/1/SPI))
    waiting for download
    

  4. If you cannot see the boot message in the output of the terminal application, please cycle through the available serial ports and try again until you discover the correct serial port.

  5. If you discovered the correct serial port, please close the terminal application so that the serial port is free again and you can use it for programming.

Press F1 to show all commands and choose the ESP-IDF: Select port to use (COM, tty, usbserial) action.

  1. An input prompt appears. Choose the previously discovered matching serial port and press Enter.

  2. The Pick Workspace Folder to which idf.port should be applied input prompt appears. Confirm the project directory by pressing Enter.

Afterward, press F1 to show all commands and choose the ESP-IDF: Flash (UART) your project action.

  1. The application is programmed to the PAN9520. You can monitor the progress of the programming operation in the terminal window.

Usage🔗

When the programming has finished, open the terminal application again. Use the already known serial port and configuration.

  1. Push the reset button 9 and you can observe how the application boots.
    ESP-ROM:esp32s2-rc4-20191025
    Build:Oct 25 2019
    rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
    SPIWP:0xee
    mode:DIO, clock div:1
    load:0x3ffe6100,len:0x1770
    load:0x4004c000,len:0xa80
    load:0x40050000,len:0x2e58
    entry 0x4004c210
    boot: ESP-IDF v4.4.3-dirty 2nd stage bootloader
    [...]
    

If the Wi-Fi configuration is correct, the application automatically connects to the Wi-Fi network and then retrieves an IP address:

  1. You can observe the progress of the application in the terminal application.
    [...]
    (18350) example_connect: Connected to example_connect: sta
    (18360) example_connect: - IPv4 address: 192.168.187.90
    (18380) example: Socket created
    (18380) example: Socket bound, port 3333
    (18380) example: Waiting for data
    [...]
    
    In this example the IPv4 address of the application is 192.168.187.90.

If your computer is connected to the same network as the PAN9520 evaluation board, then you can verify that the device is actually reachable.

  1. Open a Powershell terminal and use the ping command to try and reach the PAN9520 evaluation board.

    ping 192.168.187.90
    

  2. The following output indicates that your computer can reach the device.

    Pinging 192.168.187.90 with 32 bytes of data:
    Reply from 192.168.187.90: bytes=32 time=109ms TTL=255
    [...]
    

  3. If you see the following output, then there is a connectivity problem.

    Pinging 192.168.187.90 with 32 bytes of data:
    Request timed out.
    [...]
    

Note

If there is a connectivity problem, then one reason may be that both of the devices are connected to a corporate Wi-Fi or a guest Wi-Fi network where client isolation is enabled. This means that devices can only communicate with the Internet, but not with each other.

In this case, please choose another Wi-Fi network or alternatively use a hot spot from a mobile phone instead.

Communication🔗

Additionally, you can try to communicate from your computer to the PAN9520 evaluation board with little effort.

The following idea is taken from https://www.msxfaq.de/code/powershell/psudp.htm.

IPv4 Address

Please note that you have to replace the IPv4 address from this example with the address that your device is actually using.

  1. Open a Powershell terminal, then enter the following commands.

    $udpClient = new-Object system.Net.Sockets.Udpclient(0)
    $byteBuffer = [System.Text.Encoding]::ASCII.GetBytes("Hello, world")
    $udpClient.Send($byteBuffer, $byteBuffer.length, "192.168.187.90", "3333")
    

  2. The string "Hello, world" is transferred from the computer to the device. You can observe the reception in the terminal window:

    (268700) example: Received 12 bytes from 192.168.187.97:
    (268710) example: Hello, world
    

Opposite Direction🔗

Instead of an UDP server you can also set up an UDP client and visualize the communication. When acting as a client, the PAN9520 evaluation board sends data to your computer instead of receiving it.

The whole procedure is very similar to the one described in Step-by-Step so only the differences are explained.

IPv4 Address

If you do not set the IPv4 address correctly the sample application will not be able to transfer the data correctly.

  1. In step Project Setup in the ESP-IDF Examples input prompt, choose the udp_client example instead.

  2. In step Configuration in the ESP-IDF: SDK configuration editor (menuconfig) action, you also have to go to the Example Configuration and configure the IPv4 Address to match the IPv4 address of the system.

  3. Afterward, you can execute the steps Build and Program in a similar fashion.

Communication🔗

When acting as a client, the PAN9520 evaluation board sends data to your computer. You have to run a small server application to be able to receive and visualize that data.

The following idea is taken from https://www.msxfaq.de/code/powershell/psudp.htm.

  1. Open a Powershell terminal, then enter the following commands.
    $udpClient = New-Object system.Net.Sockets.Udpclient(3333)
    $RemoteIpEndPoint = New-Object System.Net.IPEndPoint([system.net.IPAddress]::Parse("0.0.0.0"), 3333);
    
    while ($true) {
      $data=$udpclient.receive([ref]$RemoteIpEndPoint)
      write-host "Received " ([string]::join("",([System.Text.Encoding]::ASCII.GetChars($data))))
    }
    

Firewall

Starting a server like this may trigger the Windows or corporate firewall of your system. It depends on the user rights if you can allow this activity or not. If not, and incoming traffic is blocked, you can't continue with this demo at this point.

Usage🔗

Open the terminal application again.

  1. Push the reset button 9 and you can observe how the application boots and how it connects to Wi-Fi, retrieves an IPv4 address and then sends a pre-configured message to the configured IP address.

    [...]
    (6355) example_connect: Connected to example_connect: sta
    (6365) example_connect: - IPv4 address: 192.168.187.90
    (6375) example: Socket created, sending to 192.168.187.97:3333
    (6385) example: Message sent
    [...]
    

  2. If all went well, you can observe the reception of the message in the Powershell terminal window.

    [...]
    Received  Message from ESP32
    [...]
    

Debugging🔗

The FTDI FT2232 chip on the PAN9520 evaluation board is a dual port converter, which can be either configured as a serial port or as a JTAG debug interface suitable for debugging an application.

The configuration depends on which driver is loaded when you connect the evaluation board to your computer.

If you want to debug an application using the JTAG debug interface you have to do the following:

  1. You have to re-configure the driver association of the FTDI FT2232 chip using the Zadig tool as explained in the Configure ESP32-S2-Kaluga-1 JTAG Interface documentation.

  2. Afterward, you can read about debugging using Visual Studio Code in the nicely written Debugging tutorial.

  3. In short: Press F1 to show all commands and choose the ESP-IDF: Select OpenOCD Board Configuration action. The Enter OpenOCD Configuration File Path List input prompt appears. Choose ESP32-S2-KALUGA-1 .

  4. Afterward, press F5 to start the debug session using the built-in debug capabilities of Visual Studio Code. You can also directly execute the command from the Run menu.

For more details, you can examine the previously mentioned documentation.

You can now also program the PAN9520 evaluation board using the JTAG debug interface, which is faster and also more convenient, because you can use the terminal window to observe the output of the serial port directly after programming.

  1. You can press F1 to show all commands and then choose the ESP-IDF: Flash (with JTAG) action to program an application using the JTAG debug interface.