Wifi module MT7688: How to establish connection?

2022-01-02/ By Admin

Introduction of the wifi module MT7688

Normally, we pre-fill wifi and password information in the wifi module MT7688 code, but this method can only be common for on-site testing purposes. And when common in practice, it is very inconvenient. For example, when you bring your circuit to show to your friends or when you do a project.

And bring it to school to report, do you have to take out your laptop and reload the code?

In this article, I will show you a few methods to transmit wifi information to esp8266 without reloading the code, that is using Wifi AP mode (access point).

Specifically, ESP will emit 1 wifi module MT7688for the phone to connect to and transmit wifi information down to esp8266 via HTTP protocol.

To establish a Wi-Fi module MT7688connection, the 3-step handshake occurs as follows:

  1. The client requests to open the service port by sending an SYN packet (TCP packet) to the server, in this packet, the sequence number parameter is assigned a random value X.
  2. The wifi module MT7688 responds by resending the client an SYN-ACK message. In this packet, the acknowledgment number parameter is set to X + 1, and the sequence number parameter is randomly assigned a value of Y.
  3. To complete the three-way handshake, the client continues to send the server an ACK message, in which the sequence number parameter   is assigned a value of X + 1 and the acknowledgment number parameter   is assigned a value of Y + first

At this point, both the client and the server are confirmed that a connection has been established.

Wifi module MT7688

Data transmission with wifi module MT7688

Some basic characteristics of TCP to distinguish it from UDP:

  • Error-free data transmission (due to error correction/retransmission mechanism)
  • Also, Transmit data packets in the correct order
  • Moreover, Retransmission of data packets lost in transit
  • Furthermore, Remove duplicate data packets
  • In addition, Mechanism to limit transmission congestion

Data transfer technique

In the first two of the three handshakes, the two computers exchange an Initial Sequence Number (ISN). This number can be chosen at random. This sequence number is common to mark the blocks of data sent from each computer. After each byte is transmitted, the number is incremented. 

This way we can rearrange them when they arrive at the other computer regardless of the order in which the packets arrive.

In theory, data transfer with the wifi module MT7688 each byte sent has a sequence number, and when received, the receiving computer sends back an acknowledgment (ACK). In practice, only the first data byte assigns a sequence number in the sequence number field of the packet. And the receiver sends an acknowledgment by sending the sequence number of the pending byte.

Data transfer speed through Wi-Fi module MT7688

For example, Computer A sends 4 bytes with the initial sequence number 100 (in theory, 4 bytes will have the order of 100, 101, 102, 103), then the receiver will send an acknowledgment message with content 104 because that's the order of the next byte it needs. 

By sending an acknowledgment of 104, the receiver has implicitly informed that it has received bytes 100, 101, 102, and 103. In case the last two bytes are faulty, the receiver will send an acknowledgment with the content of 102 because 2 bytes 100 and 101 have receive successfully.

Data transfer problem solution

wifi module MT7688: If the lost packet was the first, the sender would have to resend all 10 packets because there's no way for the receiver to notify it of receiving the other nine. This problem solves in the SCTP (Stream Control Transmission Protocol) protocol with the addition of selective acknowledgment.

Wifi module MT7688 2022

End connection

To terminate the connection two parties use a 4-way handshake and the direction of the connection terminates independently of each other. When one side wants to terminate, it sends a FIN packet and the other side sends back an ACK. Therefore, a typical termination process will have two pairs of packets exchanged.

A connection can exist as "semi-open": one party has finished sending data, so it only receives information, the other continues to send.

Source port: The port number at the sending computer

Destination port: The port number at the receiving computer.

Sequence number This field has 2 tasks. If the SYN flag is on, it is the initial packet sequence number and the first byte sent has this sequence number plus 1. If the SYN flag is not present, this is the sequence number of the first byte.

Acknowledgment number

 If the ACK flag is on, the value of the field is the sequence number of the next packet the receiver needs.

Data offset A 4-bit field that specifies the length of the header (in 32-bit word units). The header has a minimum length of 5 words (160 bits) and a maximum length of 15 words (480 bits).

Reserved For the future and has a value of 0

Window Number of bytes that receive starting from the value of the Acknowledgment (ACK) field

Checksum: 16 bits check for the whole TCP packet and part of the IP packet

Urgent pointer wifi module MT7688

 If the URG flag is on, the value of this field is the number of 16-bit words that the packet sequence number (sequence number) needs to shift left.

Options This is an options field. If so, the length is a multiple of 32 bits.

Its working process is as follows:

When the ESP starts, it will try to connect to the wifi module MT7688previously connects, if it fails. It will emit wifi named AutoConnectAP

We just need to take out the phone and connect to the AutoConnectAP wifi, a window will pop up and you just need to select the home wifi and enter the password.


With this project, it is possible to be successful in several applications where it is necessary to collect remote data and transmit it to a receiver and save it somewhere or send it to the internet.

WiFi module MT7688 is a technology that came to solve long-distance communication problems, in addition to solving this problem, it also has low consumption, low implementation and maintenance costs, and simple implementation in some cases.