Professional Documents
Culture Documents
REN - R12an0089eu0100 Synergy Wi Fi Esp Wroom 32 - APN - 20180213
REN - R12an0089eu0100 Synergy Wi Fi Esp Wroom 32 - APN - 20180213
REN - R12an0089eu0100 Synergy Wi Fi Esp Wroom 32 - APN - 20180213
Introduction
This document enables the Renesas Synergy Wi-Fi Framework with support for Espressif ESP-WROOM-32 Wi-Fi
module, and provide an application example to demonstrate how to use a generic interface of Synergy Wi-Fi
Framework to configure and provision Wi-Fi modules and perform data transfer with ESP-WROOM-32 networking
stack. By following this approach, the application code is abstracted from the ESP-WROOM-32 driver by the
framework itself even though on-chip networking stack is used.
Document Scope
The following topics are covered in this document:
• Introduction to ESP-WROOM-32 PMOD Module
- Pin assignment and functionality
- Program the module with Espressif official support firmware version 1.0 (ESP-WROOM-32 AT Bin V1.0)
• Overview of the integration between Synergy Wi-Fi Framework and underlying ESP-WROOM-32 driver.
• API Reference: Wi-Fi Framework on ESP-WROOM-32
• Overview of the Wi-Fi Framework operation using on-chip networking stack
• Quick started for Wi-Fi Application example
- SK-S7G2
- TB-S5D5
- DK-S3A7
- TB-S3A6
Target Device and Required Hardware
• Renesas SynergyTM developer kit SK-S7G2 or TB-S5D5 or DK-S3A7 or TB-S3A6
• Renesas ESP-WROOM-32 PMOD module
• Wi-Fi Access Point or Wi-Fi Router
Required Resources
The example application targets Renesas Synergy S3A7 devices. To build and run the application, you need the
following resources.
1. e2 studio ISDE 5.4.0.023 (from Synergy Gallery→Development Tools→e2studio).
2. Synergy Software Package (SSP) 1.3.3 (from Synergy Gallery→Synergy Software Package→Download
Details).
3. Synergy ESP-WROOM-32 Driver Pack (from Synergy Gallery→Partner Showcase→ESP-WROOM-32).
Prerequisites
1. As the user of this application note, you are assumed to have some experience with the Synergy Wi-Fi Framework.
For example, before performing the procedure in this application note, you should follow the procedure in the Wi-
Fi Framework Module Guide (r11an0226eu0100-synergy-wi-fi-framework) to build and run the application
project. By doing so, you will become familiar with the Wi-Fi framework configuration and APIs, and experience
this generic interface for the application.
2. You are expected to go through the Release Note of ESP-WROOM-32 Add-on Component
5. References ............................................................................................................................ 43
1. Introduction of ESP-WROOM-32 PMOD module
The ESP-WROOM-32 PMOD module is designed by Renesas following the PMOD PIN configuration. For the detail
specifications of ESP-WROOM-32, you can the documentations on the Espressif website
(http://espressif.com/en/products/hardware/esp-wroom-32/overview)
1.1 Pin assignment and Schematic of ESP-WROOM-32 PMOD module
ESP-WROOM-32 PMOD module supports both UART and SPI interface on the PMOD connection, and provide GPIO
pin (SELECT pin in the schematic) to MCU to select the communication interface between UART and SPI. As the
Figure 1.1, the analog switch is used to switch the different communication interfaces, and the associated PMOD Pin
assignment is designed for UART mode and SPI mode as below Figure 1.2 and Figure 1.3.
1.2 Program ESP-WROOM-32 PMOD module through ESP Flash Download Tool
ESP-WROOM-32 is an Espressif’s SoC module, which contains Wi-Fi and Bluetooth radio for IoT applications. The
default firmware of the ESP-WROOM-32 PMOD module should support the on-chip networking stack, and enables the
AT commands interface for external device to access. However, there is a programming interface on the PMOD module
if user needs to update the ESP firmware to the version, which is required by Synergy ESP-WROOM-32 Driver. This
section will go through the programming process of the ESP-WROOM-32 PMOD module step by step.
• Step 1: Download the required ESP firmware and ESP Flash Download Tool.
For the ESP-WROOM-32 add-on component release 1.3.3, it requires ESP-WROOM-32 supporting the firmware,
which is “ESP-WROOM-32 AT Bin V1.0”. Therefore, ensure that you download the correct firmware from Espressif
website. (http://espressif.com/en/products/hardware/esp32-devkitc/resources)
- Download the Flash Download Tool through the below place
• Step 3: Set SW1 on the PMOD such that Boot is ON and SPI is OFF.
• Start the ESP Flash Download Tool to download the Bin files.
As shown in Figure 1.7, run the ESP Flash Download Tool on your windows.
Figure 2.4 Wi-Fi module initialization with on-chip networking stack support
2.2.1 The general steps for IP configuration in Station mode are described in the flow
chart that follows
1. After Wi-Fi module is provisioned in Station mode, user application creates an IP interface configuration variable
following the IP Interface configuration structure
Figure 2.7 Wi-Fi module IP configuration in Station mode with on-chip networking stack support
2.2.2 The general steps for IP configuration in AP mode are described in the flow chart
that follows
1. After Wi-Fi module is provisioned in AP mode, user application creates an IP interface configuration variable, and
fills ip_addr_mode with SF_WIFI_IP_ADDR_DHCP.
2. User application calls Wi-Fi on-chip stack ipAddressCfg function to enable the DHCP (It’s required by network
stack on ESP-WROOM-32 running on SoftAP mode)
3. User applications fills ip_addr_mode with SF_WIFI_IP_ADDR_GET, and calls ipAddressCfg function to get
the IP address of ESP-WROOM-32 SoftAP.
4. User application create a starting address of IP range that can be obtained by DHCP server following the IP address
structure
5. User application create an ending address of IP range that can be obtained by DHCP server following the IP
address structure
Figure 2.9 Wi-Fi module IP configuration in AP mode with on-chip networking stack support
2.3 ESP-WROOM-32 Module Operational Overview using BSD Socket API
This section describes the operational overview in using the BSD Socket API to communicate with Wi-Fi module over
the sockets. In order to call the BSD Socket API in the user application, the BSD Socket using On-Chip Stack on Wi-Fi
Framework component should be added through the Synergy Configurator as shown in Figure 2.4. This component
creates the instance of the BSD Socket API Interface for use of the following steps
Figure 2.10 BSD Socket using On-Chip Stack on Wi-Fi Framework Component
2.3.1 The general steps for using BSD Socket API to create a TCP client communication
1. User application calls the BSD Socket API socket function to create a TCP socket and return a socket file
descriptor (Socket FD), which indicates this created socket
2. User application calls the BSD Socket API setsockopt function with the specified Socket FD and required option
name to set this socket to be kept alive.
3. User application calls the BSD Socket API connect function with the specified Socket FD and remote TCP server
information. The remote TCP server IP address and port should be filled up following the below structure.
Figure 2.13 establish TCP Client communication using BSD Socket API
2.3.2 The general steps for using BSD Socket API to create a TCP server
communication
1. User application calls the BSD Socket API socket function to create a TCP socket and return a socket file
descriptor (Socket FD), which indicates this created socket
Figure 2.14 establish TCP Server communication using BSD Socket API
• ssize_t send(int sockfd, const void * p_buf, size_t length, int flags)
Send data to remotes socket. This API takes four arguments.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf In Pointer to data buffer
length In Transmit data length Maximum length is 2048
flags In timeout 0~0xFFFF
• ssize_t sendto(int sockfd, const void * p_buf, size_t length, int flags,
const struct sockaddr * p_dest_addr, socklen_t addrlen)
Send data to a remote socket address. This API takes six arguments.
• ssize_t recvfrom(int sockfd, void * p_buf, size_t length, int flags, struct
sockaddr * p_src_addr, socklen_t * p_addrlen)
Receive data from a remote socket address. This API takes six arguments.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
p_buf Out Pointer to receive data buffer
length In Maximum length of data which Maximum length is 2048
can be received
flags In Time out 0~0xFFFF
p_src_addr In Pointer to remote socket
address which has sent data
p_addrlen Out Length of socket address
structure
• int setsockopt(int sockfd, int level, int optname, const void * p_optval,
socklen_t optlen)
Set socket options. According to the ESP-WROOM-32 Device driver, the supported option name is
SO_KEEPALIVE.
Name Direction Description Option
sockfd In Local socket File Descriptor 0~4
level In Socket API level SOL_SOCKET
optname In Option to be set SO_KEEPALIVE
p_optval In Option value to be set True/False
socklen_t In Length of option value
• int getsockopt(int sockfd, int level, int optname, void * p_optval, socklen_t
* p_optlen)
Get socket options. According to the ESP-WROOM-32 Device driver, the supported option name are
SO_CONNSTATE, SO_TYPE, SO_ERROR. The description of each option name is listed as below.
SO_CONNSTATE: get connection status of specified Socket Descriptor File. Returning optval follows the socket
structure, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)
SO_TYPE: get protocol type of specified Socket Description File. Returning optval follows the enumeration of
protocol type, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)
SO_ERROR: get error code log of specified Socket Descriptor File. Returning optval follows the enumeration of
error code, which is defined by driver (sf_wifi_esp_wroom_32_socket.h)
OR
Figure 4.12 Pin configuration for Chip Enable Pin and RTS Pin
Figure 4.16 Pin configuration for Chip Enable Pin and RTS Pin
4.5 Wi-Fi application using ESP-WROOM-32 on TB-S3A6
For the example project on TB-S3A6 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODA of TB-S3A6. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.
Figure 4.20 Pin configuration for Chip Enable Pin and RTS Pin
4.6 Wi-Fi application using ESP-WROOM-32 on DK-S3A7
For the example project on DK-S3A7 in this App-note, the ESP-WROOM-32 PMOD module is connected with
PMODA of DK-S3A7. In the Synergy Configurator, the Pin configuration and Wi-Fi device driver configuration should
be associated with the hardware setup.
Figure 4.24 Pin configuration for Chip Enable Pin and RTS Pin
4.7 Running the Application example with your PC
Review the following points before proceeding to the operation of this application project:
4.7.2 Open the serial terminal tool and check the available commands
When you run the software, and confirm the COM port enumeration, open the Tera Term or other serial terminal tool.
Figure 4.34 use TCP test tool to create a Client socket connection
Since the socket connection is established, user can transfer the data from Synergy device to the PC. Following the
usage of transmit command, transmit the message “hello PC client”, and you will need to use the Socket Descriptor
File(SockFD) here.
Figure 4.39 accept the socket connection and send the message from PC
Back to the Command Line Interface, enter the echo command with the Socket Descriptor File (SockFD), which you
got from previous message.
Figure 4.40 echo the received data through the client socket connection
Figure 4.44 run a simple HTTP web server on the Synergy Kit
Once you enter the http_server command, you will see the message, which shows “HTTP Server waiting on port 80”,
and the interface will be pended in this moment. Then, you open the browser on the PC, and enter the IP address of
Synergy device. In the meanwhile, Synergy device will accept the connection, and start to transmit the data. After the
web page is displayed as Figure 4.45, you should be able to see the message, which is highlighted in the red box of the
Figure 4.44.
All trademarks and registered trademarks are the property of their respective owners.