Working with ESP8266: Initial setup, firmware update, Wi-Fi communication, sending and receiving data to a PC. Managing NodeMCU load using mobile app What is sta client mode

I ordered the simplest board with ESP8266 - ESP-01, it looks like this:

In the old revision of the board, only VCC, GND, URXD and UTXD were brought out to the connector.
The latest revision added RST, GPIO0, GPIO2 and CH_PD.

In total, there are 11 modifications of the boards, differing in the number of pins and execution options:
ESP-01: PCB antenna, after matching the distance to do about the open 400 meters, easy to use.
ESP-02: SMD package for submission limit, the antenna can be drawn with the IPX header casing.
ESP-03: SMD package, the built-in ceramic antenna technology, all available IO leads.
ESP-04: SMD package, customers can customize the antenna types, flexible design, all the IO leads.
ESP-05: SMD package, only leads to serial and RST pin, small external antenna.
ESP-06: bottom mount technology, leads all the IO ports, with metal shielding shell, can be had FCC CEcertification, recommended.
ESP-07: Semi-hole chip technology, all the IO leads, with metal shielding shell, can be had FCC CE certified IPX external antenna, can also be built-in ceramic antenna.
ESP-08: with the ESP-07, except that the antenna is in the form of customers can define their own.
ESP-09: Ultra-small size package, only 10 * 10 mm, four-layer board technology 1M bytes! ..
ESP-10: SMD interface, narrow-body design, 10 mm wide, suitable for light with controller.
ESP-11: SMD interface, ceramic antenna, small volume.

ESP-01 connector pinout:

The pin assignment of the ESP-01 board is as follows:
VCC, GND - board power supply (+ 3.3V);
URXD, UTXD - RS232 pins are 3.3V tolerant
RST - Hard reset(reset)
GPIO0, GPIO2 - GPIO pins
CH_PD - Chip enable, must be connected to + 3.3V to work.

To switch to the firmware update mode, you need to apply a low level to GPIO0 and a high level to CH_PD.

To connect the ESP-01 board to a PC, I used a USB-to-RS232 converter on FT232R with TTL 3.3V outputs, you can use this for example.
The ESP-01 needs strictly 3.3V power supply, so I had to use a DC-DC converter, you can use this one.

With the basic firmware, the ESP-01 board is controlled by AT commands, so we need a terminal program, I used CoolTerm.

There are 2 options for using the module:
1. Using the ESP-01 board in conjunction with an additional microcontroller that will control the module via UART.
2. Writing your own firmware for the ESP8266 chip and using it as a self-sufficient device.

The second option is naturally more profitable, especially since the potential of the ESP8266 chip is quite large.

To begin with, we will try option # 1, that is, control the ESP-01 board via RS232.

The connection diagram is very simple:
VCC pin - board power supply (+ 3.3V);
GND pin - common;
Conclusions URXD, UTXD - connect to USB-to-RS232 converter (in 3.3V mode)
CH_PD pin - connect to the board power supply (+ 3.3V);

In the terminal (CoolTerm) we set the speed of the COM port to 57600. You need to set exactly this speed, since if the ESP8266 chip has an old firmware (and most likely it is), then it will work only at this port speed.

Click Connect, enter the AT command, OK should come in response. If everything is so, then the board is working, you can move on.

Firmware update procedure

We enter the AT + GMR command - checking the AT and SDK version, in response it gives 0016000902, where 0016 is the SDK version, 0901 - the AT version

Currently (11/06/2014) firmware 0018000902 is already available (SDK version - 0018, AT version - 0902)

Now you can and should update the firmware:
1. Download the XTCOM utility from here.
2. Download the firmware ESP_8266_v0.9.2.2 AT Firmware.bin from here
3. Turn off the board power, connect the GPIO0 pin to the common wire, turn on the power.
4. Run XTCOM_UTIL.exe, go to Tools -> Config Device, select the COM port to which the board is connected, set the port speed to 57600, click Open, then Connect, the program should say “Connect with target OK!”, Close the settings window. Go to the API TEST menu, select (4) Flash Image Download, specify the path to the "ESP_8266_v0.9.2.2 AT Firmware.bin" file, leave the address 0x00000, click DownLoad. The firmware download should start, and a message will be displayed at the end.
5. Turn off the board power, disconnect the GPIO0 output from the common wire, turn on the power, start the terminal (ATTENTION! Change the port speed to 9600), check the readiness of the board with the AT command and the firmware version with the AT + GMR command.

After updating to version 0018000902, the default COM port speed will change from 57600 to 9600, but this speed is new firmware can now be set with the AT + CIOBAUD command. Watching AT + CIOBAUD =? available speeds and set the command AT + CIOBAUD = 115200 speed 115200, in response it should give OK. We give the command to restart: AT + RST. Change the port speed in the terminal program to 115200.

Example:
AT OK AT + CIOBAUD =? + CIOBAUD: (9600-921600) OK AT + CIOBAUD = 115200 BAUD-> 115200 OK

Setting up a Wi-Fi connection

Now let's try to connect our ESP-01 board to a Wi-Fi access point.
We execute the following commands:
1. Set the mode Wi-Fi operation command: AT + CWMODE = The following modes are available: 1 - STA, 2 - AP, 3 - BOTH
Example:
AT + CWMODE = 1 OK 2. We look at the list of access points with the command: AT + CWLAP
Example
AT + CWLAP + CWLAP: (3, "WiFi-DOM.ru-0474", - 85, "c8: d3: a3: 30: 17: 40", 8) + CWLAP: (4, "Intersvyaz_516C", - 89 , "2c: ab: 25: ff: 51: 6c", 10) + CWLAP: (4, "pletneva", - 96, "f8: 1a: 67: 67: 2b: 96", 11) + CWLAP :( 4, "Test", - 69, "64: 70: 02: 4e: 01: 4e", 13) OK The brackets indicate: SECURITY, SSID, RSSI, BSSID, CHANNEL
SECURITY can take on the following values:
0 - OPEN, 1 - WEP, 2 - WPA-PSK, 3 - WPA2-PSK, 4 - MIXED (WPA-WPA2-PSK)
3. Connect to our AP with the command: AT + CWJAP = "SSID", "PASSWORD" Example:
AT + CWJAP = "Test", "habrahabr" OK Connection takes 2-5 seconds, after which OK appears if successful.
3. Let's see what IP address our board received with the command: AT + CIFSR
AT + CIFSR 192.168.1.104 OK Disconnecting from the access point is done with the AT + CWQAP command.
The address is received, you can move on.

The ESP-01 board can act as a Soft-AP; to enable this mode, execute the following commands:
1. Disconnect from the access point: AT + CWQAP.
2. Change the Wi-Fi operating mode with the command: AT + CWMODE = 2
3. Create your AP with the command: AT + CWSAP = "SSID", "PASSWORD", CHANNEL, SECURITY Example:
AT + CWSAP = "Test2", "habrahabr", 10.4 OK 4. We try to connect to our AP from a computer. Let's see the result:


As you can see in the picture, the speed is only 54 Mbit / s and I am also confused by the addresses DNS servers, I think they are clearly Chinese, you cannot put your own through AT commands.
The AP address can be found with the command: AT + CIFSR
Example:
AT + CIFSR 192.168.4.1 OK The list of clients of our AP can be viewed with the command: AT + CWLIF
Example:
AT + CWLIF 192.168.4.101, f4: ec: 38: 8d: 05: 62 OK

Configuring TCP Server Mode

On the ESP-01 board, you can run a TCP server to receive and send data, or it can act as a TCP client to send and receive data to the server.
To start the TCP server, run the following commands:
1. Set the transmission mode with the command AT + CIPMODE = mode = 0 - not data mode (the server can send data to the client and can receive data from the client)
mode = 1 - data mode (the server cannot send data to the client, but can receive data from the client)
Example:
AT + CIPMODE = 0 OK 2. Set up multiple connections: AT + CIPMUX = mode 0 - single connection
mode 1 - multiple connection
You can check the connection mode with the command AT + CIPMUX?
Example:
AT + CIPMUX = 1 OK AT + CIPMUX? + CIPMUX: 1 OK 3. Start the server on port 8888: AT + CIPSERVER = [,] mode 0 - to close server
mode 1 - to open server
Example:
AT + CIPSERVER = 1.8888 OK
Now you can connect to the ESP-01 and send-receive some data. To connect, we will use the utility
Run java -jar SocketTest.jar, on the Client tab, enter the address and port of ESP-01, click Connect. If the connection is successful, the Link message will appear in the terminal and the Message line and the Send button will become active in the SocketTest.
You can view the list of active connections to the ESP-01 with the command AT + CIPSTATUS
Example:
AT + CIPSTATUS STATUS: 3 + CIPSTATUS: 0, "TCP", "192.168.1.100", 44667.1 OK You can close an active connection with the command AT + CIPCLOSE = or all AT + CIPCLOSE connections without parameters.
Example:
AT + CIPCLOSE = 0 OK Unlink 4. Sending data from ESP-01 to PC
,
Example:
AT + CIPSEND = 0.16> Ping Habrahabr SEND OK 5. Send a test message from the PC:


The terminal displays the line + IPD, 0.16: Ping Habrahabr Message received.
The format of the received data is as follows:
For Single Connection mode (CIPMUX = 0): + IPD, :For Multiple Connection mode (CIPMUX = 1): + IPD, ,:

Configuring TCP Client Mode

Now let's change roles, PC - server, ESP-01 - client, try:
1. Restart the AT + RST board
2. Set the transmission mode with the command AT + CIPMODE = mode = 0 - not data mode (the client can send data to the server and can receive data from the server)
mode = 1 - data mode (the client cannot send data to the server, but can receive data from the server)
Example:
AT + CIPMODE = 0 OK 3. Set the connection mode Multiple connection: AT + CIPMUX = 1
4. On the PC, in SocketTest, start the server on port 8888
5. Launch the client on ESP-01
For Single connection mode (+ CIPMUX = 0), the format is AT + CIPSTART = ,,For the Multiple connection mode (+ CIPMUX = 1) the format is AT + CIPSTART = ,,Possible parameter values:
id = 0-4
type = TCP / UDP
addr = IP address
port = port
Example:
AT + CIPMUX = 1 OK AT + CIPSTART = 0, "TCP", "192.168.1.100", 8888 OK Linked 6. Sending data from ESP-01 to PC
For Single connection mode (+ CIPMUX = 0), sending goes like this: AT + CIPSEND = For the Multiple connection mode (+ CIPMUX = 1), the sending goes like this: AT + CIPSEND = ,After executing AT + CIPSEND, you need to enter text, completion of the input and sending is carried out by Enter.
Example:
AT + CIPSEND = 0.16> Ping Habrahabr SEND OK
An example of sending and receiving data:

Helpful documentation:
Description of AT Commands (In Chinese)
ESP8266 Chip Specification (Chinese)
ESP8266 Chip Specification (English)

Conclusion:

As we can see, the board successfully copes with the tasks, namely, connecting to Wi-Fi as a client, it can act as a Soft-AP, you can raise a TCP server on the board to receive and send data, or you can be a TCP client ...
In this article, we examined how to work with the ESP-01 board via RS232, a PC acted as a control controller, you can connect without problems Arduino board or any microcontroller with UART and send / receive data via Wi-Fi network between controllers or PC.

In the next article (as Karma allows) I will try to talk about the principles of writing my own firmware for the ESP8266 chip, thus the ESP-01 board will be completely autonomous, it will not need an additional controller to control all the parameters. We will try to connect various peripherals to the board.

I will be happy to answer your questions, although I have not yet learned the ESP-01 board to the end.

Comfast CF-WU715N is the cheapest wireless WiFi network adapter that I could find in the vastness of online stores. So in today's review there will be an interesting product that will really appeal to those who like to save money. Let's look at its characteristics, find out how to install drivers and configure the Comfast WU715N WiFi receiver.

He also has a more powerful "brother" - Comfast CF-WU720N. It has almost the same parameters, but due to more efficient hardware, the case is much larger.

I want to make a reservation right away that Comfast WU715N is not the most inexpensive adapter - there is even cheaper one, but their quality will not satisfy even the most inexperienced user. Therefore, I did a little work to find a really suitable product that would be inexpensive, but at the same time of high quality. And I found a model from a manufacturer little-known in Russia but very popular in China. network equipment Comfast.


External view of the Comfast CF-WU715N network adapter

Externally, the adapter has a very small size - no more than a two-ruble coin. Due to this, being connected to a laptop or computer in USB port, he does not interfere at all and does not draw attention to himself.

Since I made an order in the online store in the most inexpensive configuration, it included only the device itself and installation disk, on which the configuration program and the driver for the adapter are written - in fact, nothing else is needed to work.


If you take it in a branded box, then it will look like this:

The adapter drivers are suitable for Windows 7 and 8, so any modern computer can work with it.

Specifications

This is the most budget model from the line of this manufacturer, so it would be naive to expect something supernatural from him. But specifications allow you to work stably and without problems with wireless connection inside a small apartment.

  • Chipset - Ralink RT5370
  • Antenna - 2 decibels
  • Interface - USB 2.0
  • WiFi standard - B, G, N
  • Speed ​​- up to 150 mbit / s
  • Encryption - WEP, WPA, WPA2

From the capabilities of this adapter, it should be noted the ability to work not only in the standard role of a client, receiving a signal via WiFi to a computer, but also as an access point, simultaneously receiving and transmitting a wireless signal. There is also a built-in WiFi Direct function. This is when devices connect to each other via wifi without using a router. Having bought two such adapters and installed them on different PCs, you can establish communication between them without setting up the traditional local network.

That is, three in one at once - not bad for budget model!

Driver installation and Comfast CF-WU715N configuration

Now let's take a look at how this little wireless adapter is configured.
We insert it into the USB port, and the accompanying CD with drivers for the adapter and the configuration program in the CD-Rom. It is better not to lose the disk, since then it will be problematic to download the driver for the network adapter - the Russian version, as well as any other, except for Chinese and English, is not available on the official website of the manufacturer. Through a long search, I still managed to find the Comfast CF-WU715N model page, but I could not find any software in the download section.


So, if you are afraid of losing the installation CD, I recommend copying all the files from it to your computer's hard drive or USB flash drive.

Having opened its contents, we will see folders, the name of which indicates that there is all necessary software to work on both Windows 7/8 and Linux and MacOS.

We need to run the 3070setup.exe file. First, we agree with the license agreement, after which we choose the type of installation - only Comfast drivers or together with a proprietary application - the translation of the Chinese is a little lame, but the essence of the content is clear.

If you do not plan to use your wireless adapter for WiFi connections Direct, then the configuration program itself can be omitted, since all connections to the network are made standard means Windows.


After installation, a characteristic icon will appear in the bottom icon bar in Windows wireless connection... You can click on it and select your WiFi from the list of available networks.

But we will go the other way and see what the installed Ralink Wireless Utility, which was on the disk, offers us.

The program is very simple and allows you to manage the basic functionality of the network adapter. By clicking on the "Magnifier" icon, we will see the same list of wireless networks, but with a detailed description of their properties - signal quality, encryption type, MAC address ohm access point, etc.

We select the WiFi we need and connect to it step by step. After that, all information about the current connection will be displayed in the main window of the program.

If you want to directly connect to another computer, which also has a wireless adapter that supports work via WiFi Direct, then click on the WiFi icon in the application and open a new window

To enable, double-click on the zone of this window and set the name of our computer for detection

After that, we do the same on other PCs, after which all computers in the access zone for connection will be displayed in the main window. Unfortunately, due to the lack of a second adapter that works with this technology, so far I have no opportunity to show in detail how this happens, so wait for a new separate article!

Comfast adapter as access point

Now let's look at the third feature of the Comfast network adapter - to work as an Access Point, that is, to distribute the Internet via WiFi to other devices.

To activate this mode, we find in the lower right corner on the icon panel "arrow" and in the window that opens - the Ralink Utility program icon in the form of the letter "R".

Click on it right click mouse and see several items. We are currently interested in the second and third - "Switch to STA + AP mode" and "Switch to access point mode".

  • STA + AP is a mode in which the adapter will simultaneously receive the Internet via wifi from the router and immediately distribute it to others.
  • AP is a simple hotspot mode in which your computer must be connected to the Internet via a cable or other wireless network adapter- it doesn't matter directly or through a router - and Comfast will only transmit a signal, but not receive it.

Let's choose the AP mode, because in practice, when you do not have a router and you need to connect the Internet from one computer connected to the provider, it will be more in demand.

A new window will open in which we need to select from the list the network adapter or card that is currently already connected to the Internet and from which it will be distributed through our Comfast.

After that, our point will work, and the application icon in the panel will change to the letter "A". Opening again this utility it will be possible to configure the parameters of the access point.

To do this, click on the first icon in the menu and set the SSID, frequency, channel, encryption type and password.

After that new network appears in the list for connection.

Speed ​​test

All this is great, but what about the result of the work? After all, we buy a network adapter primarily for stable work in the Internet. Therefore, we made speed measurements through the SpeedTest.net service. First, for the reference point, the speed of the PC connected to the router via a cable.

Then - via the Comfast adapter

As a result, we have 27 MB / s for downloading via a wireless adapter versus 39 MB / s for a cable and a slightly lower indicator for downloading - 24 versus 41. Quite good indicators for such a device, which guarantee us a fairly high speed when working on the Internet via WiFi connection.

And almost the same results of the adapter when working as an access point - we connected to it iPad Air and measured the indicators through the application from the same SpeedTest.

Finally, the last reading in the mode of simultaneous operation as a client and a point, when the adapter received a signal via WiFi and distributed it longer on the iPad.

As you can see, the speed dropped a little more, which is not surprising, since now our device was doing double work and the presence of another link in the chain from the provider to the end user, as always, did not affect the result in the best way.

Where to buy this network adapter, you ask? I ordered it from my beloved Chinese online store AliExpress and it cost about $ 5, which for our money at the time of purchase was about 170 rubles. Now, because of the dollar rate, it has become a little more expensive, but where else can you find something worthwhile for that kind of money?

If you have any questions, I will answer in the comments ..

If the article helped, then in gratitude I ask you to do 3 simple things:
  1. Subscribe to our YouTube channel
  2. Send a link to the publication to your wall in social network by button above

The functions of the WiFi ESP8266 library are very similar to those of the library for a regular WiFi shield.

List of differences:

  • WiFi. mode (m): select mode WIFI_AP(access point), WIFI_STA(client), or WIFI_AP_STA(both modes at the same time).
  • WiFi. softAP (ssid) creates an open access point
  • WiFi. softAP (ssid, password) creates an access point with WPA2-PSK encryption, password must be at least 8 characters
  • WiFi. macAddress (mac) allows you to get the MAC address in client mode
  • WiFi. softAPmacAddress (mac) allows you to get the MAC address in the access point mode
  • WiFi. localIP () allows you to get an IP address in client mode
  • WiFi. softAPIP () allows you to get an IP address in access point mode
  • WiFi. RSSI () not yet implemented
  • WiFi. printDiag (Serial); displays diagnostic information
  • Class WiFiUDP supports reception and transmission of multicast packets in client mode. To send a multicast packet, use instead udp. beginPacket (addr, port) function udp. beginPacketMulticast (addr, port, WiFi.localIP ())... When expecting multicast packets, use instead udp. begin (port) function udp. beginMulticast (WiFi. localIP (), multicast_ip_addr, port)... you can use udp. destinationIP () to determine if the packet was sent to a multicast address or was intended for you. Multicast functions are not supported in AP mode.

WiFiServer, WiFiClient, and WiFiUDP I work in the same way as with the library of a regular WiFi shield. Four examples are included with this library.

Ticker

The Ticker library can be used to execute recurring events through certain time... Two examples are included in the delivery.

It is currently not recommended to block I / O operations (network, serial, file operations) in ticker callback functions. Instead of blocking, set a flag in callback functions and check this flag in the main loop.

EEPROM

This library is slightly different from the standard Arduino EEPROM. It is necessary to call the function EEPROM. begin (size) each time before you start reading or writing, the size (indicated in bytes) corresponds to the size of the data that you intend to use in the EEPROM. The data size must be between 4 and 4096 bytes.

Function EEPROM. write does not write data to flash memory immediately, you must use the function EEPROM. commit () every time you want to save data to memory. Function EEPROM. end () also writes data, and also frees RAM from the data that was recorded. The EEPROM library uses one sector in flash memory, starting at address 0x7b000, to store data. The delivery includes three examples of working with EEPROM.

I2C (Wire Library)

Only the master mode is implemented, the frequency is approximately up to 450 kHz. Before using the I2C bus, you need to select the SDA and SCL pins by calling the function Wire. pins (int sda, int scl), for example Wire. pins (0, 2) for the ESP-01 module. For other modules, the default pins are 4 (SDA) and 5 (SCL).

SPI

The SPI library supports the entire Arduino SPI API, including transactions, including the sync phase (CPHA). Clock polarity (CPOL) is not yet supported (SPI_MODE2 and SPI_MODE3 do not work).

ESP8266 API

Support for ESP8266-specific functions (deep sleep mode and watchdog timer) implemented in the object ESP... Function ESP. deepSleep (microseconds, mode) puts the module into deep sleep mode. Parameter mode can take on the following values: WAKE_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED... GPIO16 must be connected to RESET to wake up from deep sleep mode.

Functions ESP. wdtEnable (), ESP. wdtDisable (), and ESP. wdtFeed () control the watchdog timer.

ESP. reset () reloads the module

ESP. getFreeHeap ()

ESP. getFreeHeap () returns the size of free memory

ESP. getChipId () returns ESP8266 chip IDE, int 32bit

ESP. getFlashChipId () returns flash chip ID, int 32bit

ESP. getFlashChipSize () returns the size of flash memory in bytes as defined by the SDK (may be less than the actual size).

ESP. getFlashChipSpeed ​​(void) returns the frequency of flash memory, in Hz.

ESP. getCycleCount () returns the number of CPU cycles since start, unsigned 32-bit. May be useful for precise timing of very short operations

OneWire Library

The OneWire library was adapted for the ESP8266 (changes were made to OneWire.h) If you have the OneWire library installed in the Arduino / libraries folder, then it will be used, and not from the package.

mDNS library ESP8266mDNS

The library allows you to implement in your program the response to multicast DNS queries for the local zone, for example, “esp8266.local”. Only one zone is currently supported. Lets refer to WEB server ESP8266 by name, not just IP address. You can find more information in the attached example and in the readme file of this library.

Servo library

The library allows you to control servo motors. Supports up to 24 servos on any available GPIOs. By default, the first 12 servos will use Timer0 and will be independent of any other processes. The next 12 servos will use Timer1 and will share resources with other functions using Timer1. Most servos will operate with a 3.3v ESP8266 control signal, but will not be able to operate at 3.3v and will require a separate power supply. Remember to connect the GND of this source to the GND of the ESP8266

  • DHT11 - use the following parameters for initialization DHT dht (DHTPIN, DHTTYPE, 15)
  • NeoPixelBus - Arduino NeoPixel library for esp8266
  • PubSubClient MQTT Library by @Imroy. Article on our website about this library
  • This article shows an example of using the NodeMCU board. Namely, load control using a relay module of 4 relays and an application for mobile phone android.

    We connect all contacts according to the scheme

    After connecting all the components, you need to copy the program code below and paste it into Arduino program IDE and upload this program code to the Arduino board itself.

    #include // Name and password of your WiFi network const char * ssid = "test"; const char * password = "test"; // Create a server and listening port 80 WiFiServer server (80); void setup () (Serial.begin (115200); delay (10); // Prepare GPIO pinMode (5, OUTPUT); digitalWrite (5, 1); pinMode (4, OUTPUT); digitalWrite (4, 1); pinMode (0, OUTPUT); digitalWrite (0, 1); pinMode (2, OUTPUT); digitalWrite (2, 1); // assign a static IP address WiFi.mode (WIFI_STA); // client mode WiFi.config (IPAddress ( 192,168,1,131), IPAddress (192,168,1,111), IPAddress (255,255,255,0), IPAddress (192,168,1,1)); WiFi.begin (ssid, password); // Wait for connection while (WiFi.status ()! = WL_CONNECTED) (delay (500); Serial.print (".");) Serial.println (""); Serial.println ("WiFi connected"); // Start the server server.begin (); Serial.println ("Server started"); // Outputting the received IP address Serial.println (WiFi.localIP ());) void loop () (// Checking WiFiClient connection client = server.available (); if (! Client) (return ;) // Waiting for data Serial.println ("new client"); while (! Client.available ()) (delay (1);) // Reading the first line of the request String req = client.readStringUntil ("\ r"); Serial.println (req); client.flush (); // Working with GPIO if (req.indexOf ("/ 1/0")! = -1) digitalWrite (5, 0); else if (req.indexOf ("/ 1/1")! = -1) digitalWrite (5, 1); else if (req.indexOf ("/ 2/0")! = -1) digitalWrite (4, 0); else if (req.indexOf ("/ 2/1")! = -1) digitalWrite (4, 1); else if (req.indexOf ("/ 3/0")! = -1) digitalWrite (0, 0); else if (req.indexOf ("/ 3/1")! = -1) digitalWrite (0, 1); else if (req.indexOf ("/ 4/0")! = -1) digitalWrite (2, 0); else if (req.indexOf ("/ 4/1")! = -1) digitalWrite (2, 1); else if (req.indexOf ("/ 5")! = -1) (Serial.println ("TEST OK"); String s = "HTTP / 1.1 200 OK \ r \ nContent-Type: text / html \ r \ n \ r \ n\ r \ n \ r \ nTest OK. Uptime: "; // UpTime counting int Sec = (millis () / 1000UL)% 60; int Min = ((millis () / 1000UL) / 60UL)% 60; int Hours = ((millis () / 1000UL) / 3600UL)% 24; int Day = ((millis () / 1000UL) / 3600UL / 24UL); s + = Day; s + = "d"; s + = Hours; s + = ":"; s + = Min ; s + = ":"; s + = Sec; s + = "\ n "; client.print (s); client.stop (); return;) else // If an invalid request, write an error (Serial.println (" invalid request "); String s =" HTTP / 1.1 200 OK \ r \ nContent-Type: text / html \ r \ n \ r \ n\ r \ n \ r \ nInvalid request "; s + ="\ n "; client.print (s); client.stop (); return;) client.flush (); // Forming the response String s =" HTTP / 1.1 200 OK \ r \ nContent-Type: text / html \ r \ n \ r \ n\ r \ n \ r \ nGPIO set OK "; s + ="\ n "; // Send the response to the client client.print (s); delay (1); Serial.println (" Client disonnected ");)

    The sources can be viewed at this link: https://yadi.sk/d/ehabE3C_3M36Yo this link will download a file with the .aia extension and you can add it to the MIT app invertor and see what the program consists of in full.

    Which reflects the most important changes in the new edition of the standard compared to the current 802.11ac.

    Please note that 802.11ax will work in the 2.4 and 5 GHz bands (previously in 802.11ac they tried to abandon the 2.4 GHz band). Also, the new specification will quadruple the number of OFDM FFT subcarriers. But the most important change is that with the release of 802.11ax, the spacing between subcarriers will also be reduced by four times, while the existing channel bandwidths remain unchanged:

    Figure 1 - Spacing between subcarriers in 802.11ax

    Thus, in the figure above, we see narrower spacing between subcarriers. In addition to the changes in OFDM, 1024-QAM modulation is also added, which will increase the maximum (theoretical maximum possible) data transfer rate to almost 10 Gbit / s.

    Let's move on to the examination of 802.11ax technologies at the physical layer

    In 802.11ax, the beamforming mechanism (automatic beamforming towards the subscriber) will be improved, compared to more early version 802.11ac. In accordance with this mechanism, the beamformer initiates the channel sounding procedure with a Null Data Packet. In doing so, it measures the level of activity in the channel and uses this information to calculate the channel matrix. The channel array is then used to focus RF energy towards each individual user. Together with beamforming, 802.11ax will support two new multi-user technologies for Wi-Fi: Multi-User MIMO and Multi-User OFDMA.

    Multi-user MIMO and OFDMA

    The 802.11ax standard will define two modes of operation:

    Single User (one user). In this mode, wireless STAs send and receive AP data one at a time as soon as they access the medium. The access mechanism was described in.

    Multi-User (multi-user mode). This mode allows the AP to work with multiple STAs at the same time. The standard divides this mode further into multiplayer Downlink and Uplink.

    DownlinkMulti-User allows AP simultaneously transmit data to multiple wireless STAs that are served in the AP's radio coverage area. The existing 802.11ac standard already defines this feature. Multiplayer Uplink, however, is new.

    UplinkMulti-User allows AP simultaneously receive data from multiple wireless STA stations. This is a new feature of the 802.11ax standard that did not exist in any of the previous versions Wi-Fi standard.

    In a multi-user mode of operation, the standard also defines two different ways to multiplex more users in a given area: Multi-User MIMO and OFDMA. For both of these methods, the AP acts as a central controller, similar to how a cellular base station LTE manages multiplexing of users in the service area. Let's take a closer look at MU-MIMO and OFDMA.

    Multi-user MIMO

    802.11ax devices will use beamforming techniques (borrowed from 802.11ac) to simultaneously route packets to multiple spatially separated users. That is, the AP will compute a channel matrix for each user and manage parallel beams for different users, with each beam containing packets for its specific user.

    802.11ax supports the simultaneous sending of up to eight multi-user MIMO streams. In addition, each MU-MIMO stream can have its own MCS (bit rate and modulation degree). An arbitrary number of streams can be organized to different users. With MU-MIMO spatial multiplexing, the AP can be compared to an Ethernet switch with multiple ports. Each individual port is a separate MU-MIMO stream. At the same time, several streams can be "forwarded" to each individual subscriber:


    Figure 2 - MU-MIMO Beamforming to serve multiple, spatially separated users

    A new feature in 802.11ax is MU-MIMO Uplink. As stated above, the AP can initiate the simultaneous reception of packets from each of the STAs through a trigger frame. When multiple STAs transmit their own packets in response to the trigger frame, the AP applies the channel matrix to the received beams and separates the information contained in each beam. So the AP can also initiate multi-user reception simultaneously from all subscriber STAs in the network:


    Figure 3 -

    Multiplayer OFDMA

    In the 802.11ax standard, a new technology for Wi-Fi, borrowed from 4G networks, will appear for multiplexing a large number of subscribers in a common bandwidth: Orthogonal Frequency Division Multiple Access (OFDMA). This technology builds on OFDM, which is already used in 802.11ac. Its essence is that OFDMA in 802.11ax allows you to additionally "cut" standard channels with a width of 20, 40, 80 and 160 MHz into smaller ones. Thus, the channels are divided into smaller subchannels with a predetermined number of subcarriers. Like LTE, 802.11ax calls the smallest subchannel a Resource Unit (RU) with a minimum size of 26 subcarriers. For clarity, the figure below shows the division of frequency resources for one user using OFDM (left) and multiplexing four users in one channel using OFDMA (right):


    Figure 4 -

    In busy environments, where many users will typically struggle inefficiently for channel usage, Wi-Fi's new OFDMA engine serves them simultaneously with a smaller but user-specific sub-channel, which improves average throughput for each individual user.

    The figure below shows how an 802.11ax system can multiplex a channel using different RU sizes. Note that the smallest channel spacing accommodates up to 9 users for every 20 MHz of bandwidth:


    Figure 5

    Separation of Wi-Fi channels using 40 MHz channels:


    Figure 6

    Splitting Wi-Fi channels using 80 MHz channels:


    Figure 7

    The following table shows the number of users (for different channel widths) that can now receive OFDMA frequency multiplexed access:

    Number of subchannels RU Channel width 20 MHz Channel width 40 MHz Channel width 80 MHz Channel width 160 MHz
    26 9 18 37 74
    52 4 8 16 32
    106 2 4 8 16
    242 1-SU / MU-MIMO 2 4 8
    484 N / A 1-SU / MU-MIMO 2 4
    966 N / A N / A 1-SU / MU-MIMO 4
    2x966 N / A N / A N / A 1-SU / MU-MIMO

    Multi-User Uplink Operation

    As noted above, 802.11ax will enable simultaneous transmission of packets from multiple subscribers to an access point. To coordinate MU-MIMO or Uplink OFDMA operation, the AP sends a trigger frame to all users. This frame indicates the number of spatial streams and / or OFDMA parameters (frequency and RU sizes) of each user. The trigger frame also contains power control information so that individual users can increase or decrease their transmit power in an effort to equalize the power received by the AP from all users and thereby improve frame reception. The AP also instructs all users when to start and stop transmission. The AP sends a multi-user trigger frame that tells all users the exact time when they should all start transmitting data and the exact duration of their frames to ensure they all complete transmission at the same time. As soon as the AP receives frames from all users, it sends back an ACK block indicating the completion of the transfer:


    Figure 8 - Coordination of multiuser operation of devices in a Wi-Fi network

    Conclusion

    One of the main goals of the 802.11ax standard is to provide a higher average bandwidth per user (on average 4 times) in dense wireless networks... To this end, 802.11ax devices support multi-user MIMO and OFDMA technologies. It also added the ability to simultaneously transmit from multiple devices to the AP, thereby reducing latency and equipment downtime due to unsuccessful attempts to capture the transmission medium. In theory, everything looks, as always, clear and beautiful, however, what effect will be in practice - time will tell. In the meantime, we can only say with confidence that the effect of 802.11ax will only be if all devices in the network support new standard... Otherwise, it will take a few more years before we switch from good old Wi-Fi (with its freezes in large networks) to efficient 802.11ax.