Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the LiteOS AT instruction

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use LiteOS AT instructions". In daily operation, I believe many people have doubts about how to use LiteOS AT instructions. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use LiteOS AT instructions". Next, please follow the editor to study!

1. Environment preparation hardware preparation

Development board

ESP8266 communication module

Software preparation

QCOM Serial Port Assistant

Network debugging assistant

Document preparation

ESP8266 AT instruction set

This document comes from Lexin official! When reading this tutorial, please refer to this document for detailed instructions on the AT directive!

Changeover switch

If the switch in the upper right corner of the Bear development board is turned on to the AT-PC, the module is directly connected to the PC for easy debugging.

All tools and documentation are available on the official account of "Cubs Open Source Community" in reply to "Communication Module"!

two。 Basic AT instruction AT

Instruction: AT

Function: test whether the AT instruction function is normal

Example:

ATOKAT+GMR

Instruction: AT+GMR

Function: query module firmware version information

Example:

AT+GMRAT version:1.3.0.0 (Jul 14 2016 18:54:01) SDK version:2.0.0 (5a875ba) v1.0.0.3Mar 13 2018 09:37:06OKAT+RST

Instruction: AT+RST

Function: soft reset module

Example:

AT+RSTOK ets Jan 8 2013 RST cause:2, boot mode: (3) load 0x40100000, len 2408, room 16 tail 8chksum 0xe5load 0x3ffe8000, len 776, room 0 tail 8chksum 0x84load 0x3ffe8310, len 632, room 0 tail 8chksum 0xd8csum 0xd82nd boot version: 1.6 SPI Speed: 40MHz SPI Mode: QIO SPI Flash Size & Map: 32Mbit (512KB+512KB) jump to run user1 @ 1000WIFI DISCONNECT3. Based on TCP protocol to connect remote server communication example 3.1. Configure WIFI mode

Use the following command to set the working mode of the module to softAP and Station mode coexistence:

AT+CWMODE=3

Example:

AT+CWMODE=3OK

In softAP mode, ESP8266 module itself acts as a WIFI hotspot, allowing other devices to connect to this hotspot; in Station mode, ESP8266 module acts as a device to connect other WIFI hotspots.

3.2. Connect to a router with Internet access

Use the following command to connect the module to a wireless router that can access the Internet, or a mobile hotspot that can surf the Internet normally, where SSID is the name of the hotspot and password is the password of the hotspot:

AT+CWJAP= "SSID", "password"

Example:

AT+CWJAP= "FAST_88A6", "12345678" WIFI CONNECTEDWIFI GOT IPOK3.3. Query the ip address of the device

After connecting to the router successfully, use the following command to query the ip address obtained by the module. There are two kinds of ip queried. APIP is the gateway ip provided by the module itself as a hot spot, and the other STAIP is the ip address automatically obtained by the module connecting router:

AT+CIFSR

Example:

AT+CIFSR+CIFSR:APIP, "192.168.4.1" + CIFSR:APMAC, "de:4f:22:5e:90:b7" + CIFSR:STAIP, "192.168.0.101" + CIFSR:STAMAC, "dc:4f:22:5e:90:b7" OK3.4. Connect to a remote TCP server

First, we need to build a TCP server, which can be done in two ways:

Use Python, Java, C # and other languages to write server programs on the server.

Use the network debugging assistant to start the TCP server on the local PC

Here, we use the second method to start a TCP server using the network debugging assistant tool. The specific steps are as follows:

First, make sure that PC is connected to the same router as the module, and use the Ping command on the cmd command line to test whether the network is connected:

Ping

Example:

After ensuring that there is ping communication between the module and PC, turn on the TCP server:

Next, enter the listening port of the TCP server, ranging from 0 to 65535, and avoid ports 21 (FTP), 22 (SSH), 80 (HTTP) and 431 (HTTPS). Here I use 9999 as the test:

After the creation is successful, as shown below:

Next, you need to turn off Windows Defender's network firewall, otherwise the module cannot access PC. Search for "Firewall" in the lower left corner of the desktop, select "Firewall and Network Protection", and turn off the firewalls of the three networks:

Next, the last step is to query the ip address of PC, which can be found in the network settings:

Finally, use the AT command to connect to the TCP server, where the first parameter is the protocol type, "TCP" means to use the TCP protocol, the second parameter is the ip address of the TCP server, or you can use the domain name, and the most important parameter is the port where the TCP server opens the listening port (note: no quotation marks):

AT+CIPSTART= "TCP", "192.168.0.102", 9999

Example:

AT+CIPSTART= "TCP", "192.168.0.102", 9999CONNECTOK

After connecting, you can also see it in the network debugging assistant:

3.5. The module actively sends messages.

You can send a message to the TCP server using the following command. First, set the number of bytes of data to be sent, wait for the module to return >, and enter the data to be sent. If the data sent exceeds the set n bytes, only the first n bytes will be sent. The following data is considered invalid and will not be sent:

AT+CIPSEND=5 > hello

Example:

AT+CIPSEND=5OK > Recv 5 bytesSEND OK

Send it successfully to see if the network debugging assistant on the PC side has received:

3.6. Module receives messages

When the network debugging assistant sends data to the module as a TCP server, the module prints out the received information:

The module outputs the received information in the serial assistant:

+ IPD,13:hello,esp82663.7. Close the TCP connection

After the communication is complete, you can close the TCP connection using the following command:

AT+CIPCLOSE

Example:

At this point in CLOSEDOK, the study on "how to use LiteOS AT instructions" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report