ATK-UART2ETH serial port to Ethernet module communication

ATK-UART2ETH serial port to Ethernet module communication



Preface

Nowadays, LWIP is used in a wide range of fields. Some microcontrollers do not have an Ethernet interface, so the LWIP function cannot be used. However, an external Ethernet module can be connected to realize this function. It is also very convenient to use.


Chapter 1 Basic knowledge of module network

DHCP: An optional function of a router or switch, used to allocate IP addresses for access to the LAN. The operating computer does not have the DHCP function, so you need to manually set the IP address. Communicate with the target IP.

Module IP: It is equivalent to the identification of the device in the network. The network communicates with each other by IP address. In the LAN, routing will filter some non-LAN IPs.
For example: the computer IP is 192.168.1.123 and the module IP is 192.168.30.100. Since the subnet mask is 255.255.255.0 and the first three digits of the address do not match exactly, the two devices will not be able to pass through. TCP communication.

Subnet mask: Not used alone, used in conjunction with the IP address. It is used to shield a part of the IP address to distinguish the network identifier and the host identifier, and indicate that the IP address is On a LAN or on a WAN.
This value is usually 255.255.255.0, which means that the first three digits of the IP address must be the same as the local one, otherwise communication will fail: for example, the computer IP is 192.168.1.123 and the module IP is 192.168.30.100 due to the subnet mask. The code is 255.255.255.0. The first three digits of the address do not match exactly. The two devices will not be able to communicate through TCP

Gateway: A device that provides access to the local network, usually a router or switch; the IP address is usually 192.168.1.1 or 192.168.0.1.

MAC address: The hardware address of the network device, which is different for each device and has a specific meaning. That is, the module is factory configured with a unique MAC address.

DNS: A function used to convert domain names into actual IP addresses. The DNS server provides this resolution function. For example, Atomic Cloud: CLOUD.ALIENTEK.COM, the address after DNS resolution is: 47.98.186.15

1.1 IP acquisition method

Get IP Method 1:
Win+R to open the run box, enter the CMD command, enter the command execution interface, send ipconfig and press Enter:

Insert image description here

Get IP Method 2:
On the computer, click [Settings]->Open [Network and Internet]->Open [Change Adapter Options] under Advanced Network Settings-> Right-click and select Ethernet [Properties] -> Double-click [Interner Protocol Version 4 (TCP/IPv4)].
Note: When configuring a static IP, the computer IP can be configured at will: as shown below:

Insert image description here

Insert image description here

Chapter 2 Communication between a single module and the computer network debugging assistant

Use the host computer and computer network debugging assistant provided by the module for two-way communication. Optional TCP (client/server) or UDP communication protocol.

2.1 Module wiring

Wiring reference comparison table:

USB-TTL module Ethernet module interface
5V 5V
GND GND
RXD TXD
TXD RXD

The network port of the Ethernet module can be directly connected to the network port of the computer, or it can be connected to a router, switch, etc.

2.2 Static IP communication

Using the static IP method, the module network port can be directly connected to the computer network port.

2.2.1 Host computer configuration

Step one:
Check whether the serial port and module are connected successfully
First open the module configuration software and select the corresponding serial port and baud rate: a>
The module’s default factory serial port parameters are: baud rate 115200, stop bit 1, data bit 8, parity bit NONE. Then open the serial port status button, and then click the Read Parameters button to view the configuration information.

Insert image description here

The parameters read are as shown in the figure below:
If the parameters can be read normally, it means that the module connection is successful.

Insert image description here

Step 2:
Select the NET label of the host computer to configure the module network parameters:
If the selected device cannot be recognized, you can click Refresh Device. Select or reopen the host computer software to recognize and display normally. If there are multiple devices, you can pull down to select the corresponding Ethernet device.

Insert image description here

After the network status is successfully connected, you can click to read the parameters, which is the same as the previous method of reading serial port parameters.

2.2.2 TCP client test

1. Basic settings:

  1. Select Static IP for IP address type.
  2. The module IP can be set at will, but you need to ensure that the module IP and gateway are in the same network segment 192.168.1.xx.
  3. The subnet mask and gateway are the IP information obtained previously, and can be filled in accordingly.
  4. Just keep the default port configuration.
  5. The module name can be default or customized.
  6. The MAC address and DNS parameters can be kept as default.
  7. Check command echo.

2. Port settings:

  1. These parameters of the serial port can be kept as default or customized. Usually the baud rate is 115200.
  2. The packaging time and packaging length can be customized to select appropriate values ​​or keep the default values.
  3. Select TCP client as working mode.
  4. The target IP is the computer IP address obtained above, just fill it in accordingly.
  5. It is not necessary to check the specified local port. It has little effect and can be seen by the network debugging assistant.
  6. The remote port can be customized, that is, the port of the network debugging assistant.

Note: "Local port" and "remote port" are relative to the module.

The detailed configuration is as shown below:

Insert image description here

After configuring all parameters, click Save Parameters (to read whether the parameters are set successfully), then click to close the serial port status, and then click the TEST label of the host computer to configure network communication:

Insert image description here

2.2.2.1 Network assistant communication test

1. Use the host computer’s own network debugging assistant to communicate:

Insert image description here

Note here: The module mode selection issue is relative to the module. It is not like other network debugging assistants where one is the client and the other is the server.

2. Use the network debugging assistant to communicate:
Open the network debugging assistant:

Insert image description here

Select the corresponding communication protocol method and configure the module as a client. Then the network assistant here should select the server's communication method. The 8080 after 5 is the optional designated local port in the previous configuration. It doesn't matter whether it is present or not.

Host computer connection serial port:

Insert image description here

After clicking the serial port connection successfully, the serial port receiving area will return a True prompt.
After the connection is successful, the module host computer and the network debugging assistant will send and receive information:

Insert image description here

3. Use the network debugging assistant to communicate:

Insert image description here

2.2.3 TCP server test

1. Basic settings:

  1. Select Static IP for IP address type.
  2. The module IP can be set at will, but you need to ensure that the module IP and gateway are in the same network segment 192.168.1.xx.
  3. The subnet mask and gateway are the IP information obtained previously, and can be filled in accordingly.
  4. Just keep the default port configuration.
  5. The module name can be default or customized.
  6. The MAC address and DNS parameters can be kept as default.
  7. Check command echo.

2. Port settings:

  1. These parameters of the serial port can be kept as default or customized. Usually the baud rate is 115200.
  2. The packaging time and packaging length can be customized to select appropriate values ​​or keep the default values.
  3. Select TCP server as working mode.
  4. The target IP is the computer IP address obtained above, just fill it in accordingly.
  5. It is not necessary to check the specified local port. It has little effect and can be seen by the network debugging assistant.
  6. The remote port can be customized, that is, the port of the network debugging assistant.

Note: "Local port" and "remote port" are relative to the module.

The detailed configuration is as shown below:

Insert image description here
After configuring all parameters, click Save Parameters (to read whether the parameters are set successfully), then click to close the serial port status, and then click the TEST label of the host computer to configure network communication:

Insert image description here

2.2.3.1 Network assistant communication test

1. Use the host computer’s own network debugging assistant to communicate:

Insert image description here

It should be noted here: the module mode selection issue is relative to the module. It is not like other network debugging assistants where one is the client and the other is the server selection method.

2. Use the network debugging assistant to communicate:
Open the network debugging assistant:

Insert image description here

Select the corresponding communication protocol method, and the module is configured as a server, so the network assistant here should select the client's communication method.

Host computer connection serial port:

Insert image description here

After clicking the serial port connection successfully, the serial port receiving area will return a True prompt.
After the connection is successful, the module host computer and the network debugging assistant will send and receive information:

Insert image description here

3. Use the network debugging assistant to communicate:

Insert image description here

2.2.4 UDP client test

1. Basic settings:

  1. Select Static IP for IP address type.
  2. The module IP can be set at will, but you need to ensure that the module IP and gateway are in the same network segment 192.168.1.xx.
  3. The subnet mask and gateway are the IP information obtained previously, and can be filled in accordingly.
  4. Just keep the default port configuration.
  5. The module name can be default or customized.
  6. The MAC address and DNS parameters can be kept as default.
  7. Check command echo.

2. Port settings:

  1. These parameters of the serial port can be kept as default or customized. Usually the baud rate is 115200.
  2. The packaging time and packaging length can be customized to select appropriate values ​​or keep the default values.
  3. Select UDP client as working mode.
  4. The target IP is the computer IP address obtained above, just fill it in accordingly.
  5. It is not necessary to check the specified local port. It has little effect and can be seen by the network debugging assistant.
  6. The remote port can be customized, that is, the port of the network debugging assistant.

Note: "Local port" and "remote port" are relative to the module.

The detailed configuration is as shown below:

Insert image description here

After configuring all parameters, click Save Parameters (to read whether the parameters are set successfully), then click to close the serial port status, and then click the TEST label of the host computer to configure network communication:

Insert image description here

2.2.4.1 Network assistant communication test

1. Use the host computer’s own network debugging assistant to communicate:

Insert image description here

It should be noted here: the module mode selection issue is relative to the module. It is not like other network debugging assistants where one is the client and the other is the server selection method.

2. Use the network debugging assistant to communicate:
Open the network debugging assistant:

Insert image description here

Select the corresponding communication protocol method and configure the module as a client. Then the network assistant here should select the server's communication method.

Host computer connection serial port:

Insert image description here

After clicking the serial port connection successfully, the serial port receiving area will return a True prompt.
After the connection is successful, the module host computer and the network debugging assistant will send and receive information:

Insert image description here

3. Use the network debugging assistant to communicate:

Insert image description here

2.2.5 UDP server test

1. Basic settings:

  1. Select Static IP for IP address type.
  2. The module IP can be set at will, but you need to ensure that the module IP and gateway are in the same network segment 192.168.1.xx.
  3. The subnet mask and gateway are the IP information obtained previously, and can be filled in accordingly.
  4. Just keep the default port configuration.
  5. The module name can be default or customized.
  6. The MAC address and DNS parameters can be kept as default.
  7. Check command echo.

2. Port settings:

  1. These parameters of the serial port can be kept as default or customized. Usually the baud rate is 115200.
  2. The packaging time and packaging length can be customized to select appropriate values ​​or keep the default values.
  3. Select UDP server as working mode.
  4. The target IP is the computer IP address obtained above, just fill it in accordingly.
  5. It is not necessary to check the specified local port. It has little effect and can be seen by the network debugging assistant.
  6. The remote port can be customized, that is, the port of the network debugging assistant.

Note: "Local port" and "remote port" are relative to the module.

The detailed configuration is as shown below:

Insert image description here

After configuring all parameters, click Save Parameters (to read whether the parameters are set successfully), then click to close the serial port status, and then click the TEST label of the host computer to configure network communication:

Insert image description here

2.2.5.1 Network assistant communication test

1. Use the host computer’s own network debugging assistant to communicate:

Insert image description here

It should be noted here: the module mode selection issue is relative to the module. It is not like other network debugging assistants where one is the client and the other is the server selection method.

2. Use the network debugging assistant to communicate:
Open the network debugging assistant:

Insert image description here

Select the corresponding communication protocol method, and the module is configured as a server, so the network assistant here should select the client's communication method.

Host computer connection serial port:

Insert image description here

After clicking the serial port connection successfully, the serial port receiving area will return a True prompt.
After the connection is successful, the module host computer and the network debugging assistant will send and receive information:

Insert image description here

3. Use the network debugging assistant to communicate:

Insert image description here

2.3 Dynamic IP communication

2.3.1 Module wiring

Dynamic IP mode requires the module to be connected to a network port, router or switch.
The dynamic IP method does not require obtaining an IP address, just check DHCP.

2.3.2 Host computer configuration

Insert image description here

After configuring all parameters, click Save Parameters (to read whether the parameters are set successfully), then click to close the serial port status, and then click the TEST label of the host computer to configure network communication:

Insert image description here

2.3.3 Network debugging assistant configuration

Open the network debugging assistant:

Insert image description here

Insert image description here

Note: The principles of TCP/UDP communication under dynamic and static communication are the same. Please refer to static IP for details.

Chapter 3 Communication between two modules (static IP)

Communication between two modules can only use static IP to communicate with each other.

3.1 Module wiring

Module wiring reference comparison table:

USB-TTL module Ethernet module interface
5V 5V
GND GND
RXD TXD
TXD RXD

Note: The two modules are connected to the computer serial port using a USB-TTL module respectively, and the two modules are connected through a network cable. As shown below:

Insert image description here

3.2 IP acquisition

To obtain the IP, please see the obtaining tutorial in Chapter 1 above.

3.3 Host computer configuration

Step 1: Check whether the serial port and module are connected successfully
Open the configuration software of the two modules respectively and select the corresponding serial port and baud rate:
The factory default serial port parameters of the module are: baud rate 115200, stop bit 1, data bit 8, parity bit NONE. Then open the serial port status button, and then click Read Parameters to view the configuration information.

Insert image description here

The parameters read are as shown below:

Insert image description here

Step 2: Configure network parameters:

Insert image description here

Note: 1. Any network segment must be consistent, that is, 1 is in the same LAN. 2. The client’s target IP is the server’s module IP. 3. The local port and remote port need to be consistent. After configuring the parameters, click Save.

3.4 Communication arrangement

Select the corresponding serial port number and baud rate, and then click Connect to see that the serial port receiving area on the left returns a True prompt.

Insert image description here
After the connection is successful, data can be sent and received on the two host computers.

Insert image description here

At the same time, you can also send and receive data to each other on the network debugging assistant. As shown below:

Insert image description here

Chapter 4 Module connects to Atomic Cloud Server

The Atomic Cloud domain name is:cloud.alientek.com, and the port number is: 59666

Step 1: Log in to the Atomic Cloud server and click Device Management to add an ATK-UART2EH device.

Insert image description here

Step 2: Add a new device, customize the name and password, and generally keep the default password.

Insert image description here

Step 3: After adding the device, you can see the device information (name and number), as shown below:

Insert image description here

The device status displayed at this time is disconnected, indicating that there is no device connection. After the Ethernet module is successfully connected, the connected status can be displayed.

Host computer configuration:

Insert image description here

Copy the device number and password of Yue Atom Cloud to the host computer, and then click to save the parameters.

After the connection is successful, it will be displayed as connected, as shown below:

Insert image description here

4.1 Data communication

1. Communication between host computer and Atomic Cloud:

Insert image description here

After clicking on the serial port connection successfully, the serial port receiving area will return a True prompt.

Insert image description here

2. Serial debugging assistant and Atomic Cloud communication:

Insert image description here

The above is a simple test process for the module to connect to the Atomic Cloud for communication.

Chapter 5 Module Firmware Upgrade

When the computer where the host computer is located can connect to the external network, it is recommended to use the network upgrade method to avoid selecting the wrong firmware when manually selecting firmware.

5.1 Module wiring

Module wiring reference comparison table:

USB-TTL module Ethernet module interface
5V 5V
GND GND
RXD TXD
TXD RXD
GND DF

After the module is connected to the serial port, select the corresponding serial port number and baud rate, click to open the serial port status, and then check the read parameters to see if the connection is successful. After it can be read normally, connect the "DF" pin of the module to GND, then click the firmware upgrade button in the upper left corner and select the method of loading the firmware. As shown below:

Insert image description here

Note that after clicking "Start Upgrade", you need to keep the level on the "DF" pin low, otherwise the update will fail.

5.2 Offline method

After entering the upgrade interface, click the Open File button and select the firmware below.

Insert image description here

Insert image description here

After selecting the firmware and clicking to start the upgrade, you will be prompted to confirm whether the DF pin is connected to GND, as shown below:

Insert image description here
Click OK to upgrade the firmware normally:

Insert image description here

Insert image description here

After the upgrade progress reaches 100%, you can directly close the "Firmware Update" interface. Release the low level on the "DF" pin, and if the AT command communication can be used normally, the upgrade is successful.

5.3 Online methods

After entering the upgrade interface, select the network loading firmware method and click the APP button.

Insert image description here

After the upgrade progress reaches 100%, you can directly close the "Firmware Update" interface. Release the low level on the "DF" pin, and if the AT command communication can be used normally, the upgrade is successful.


Summarize

You need to use the Ethernet module. You need to have some network knowledge to use this module correctly (you need to use concepts such as IP address and IP port).

Guess you like

Origin blog.csdn.net/weixin_53944340/article/details/129889260