Load management on NodeMCU using a mobile application. Working with ESP8266: Initial setup, firmware update, Wi-Fi communication, sending and receiving data on a PC Driver installation and configuration of Comfast CF-WU715N

This article shows an example of using the NodeMCU board. Namely, load control using a relay module of 4 relays and an application for an Android mobile phone.

We connect all contacts according to the diagram

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

#include // Name and password of your WiFi network const char* ssid = "test"; const char* password = "test"; // Create a server and port for listening 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); // Waiting for connection while (WiFi.status() ! = WL_CONNECTED) ( delay(500); Serial.print("."); ) Serial.println(""); Serial.println("WiFi connected"); // Starting the server server.begin(); ("Server started"); // Print the received IP address Serial.println(WiFi.localIP()); void loop() ( // Check the connection WiFiClient 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 calculation int Sec = (millis() / 1000UL) % 60; int Min = ((millis() / 1000UL) / 60UL) % 60; int Hours = ((millis() / 1000UL) / 3600UL) % 24; int Day = ((millis() / 1000UL) / 3600UL); s += "d "; s += ":"; ; s += ":"; s += Sec;\n"; client.print(s); client.stop(); return; ) else // If the request is invalid, 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(); // Formation of 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.

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 output to the connector.
The latest revision added RST, GPIO0, GPIO2 and CH_PD.

There are a total of 11 board modifications, differing in the number of pins and design 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 certifiedIPX 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 assignments of the ESP-01 board are as follows:
VCC, GND - board power supply (+3.3V);
URXD,UTXD - RS232 pins are tolerant to 3.3V
RST - Hard reset
GPIO0, GPIO2 - GPIO pins
CH_PD - Chip enable, must be connected to +3.3V to work.

To switch to 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 the FT232R with TTL 3.3V outputs, for example you can use this one.
The ESP-01 needs strictly 3.3V power supply, so I had to use a DC-DC converter, you can use this one.

With basic firmware, the ESP-01 board is controlled by AT commands, so we will 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.

Naturally, the 2nd option is more profitable, especially since the potential of the ESP8266 chip is quite large.

First, we will try option No. 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;
Pins URXD,UTXD - connect to the 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, because if the ESP8266 chip has old firmware (and most likely this is the case), then it will only work with that port speed.

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

Firmware update procedure

Enter the command AT+GMR - check the AT and SDK version, the response is 0016000902, where 0016 is the SDK version, 0901 is 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 power to the board, connect the GPIO0 pin to the common wire, and 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 file “ESP_8266_v0.9.2.2 AT Firmware.bin”, leave the address as 0x00000, click DownLoad. The firmware download should begin and a message will be displayed when completed.
5. Turn off the board's power, disconnect the GPIO0 pin 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 speed of the COM port will change from 57600 to 9600, but this speed in the new firmware can now be set with the AT+CIOBAUD command. Let's look at AT+CIOBAUD=? available speeds and set the command AT+CIOBAUD=115200 speed to 115200, the response should be 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 Wi-Fi operating mode with the command: AT+CWMODE= The following modes are available: 1 - STA, 2 - AP, 3 - BOTH
Example:
AT+CWMODE=1 OK 2. View 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 Indicate in brackets: SECURITY, SSID, RSSI, BSSID, CHANNEL
SECURITY can take 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 The connection lasts 2-5 seconds, after which, if successful, OK will appear.
3. Let's see what IP address our board received with the command: AT+CIFSR
AT+CIFSR 192.168.1.104 OK Disconnection from the access point is done with the AT+CWQAP command.
The address has been received, you can move on.

The ESP-01 board can act as a Soft-AP; to enable this mode, run 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 54Mbit/s and I’m also confused by the DNS server addresses, I think they are clearly Chinese, you can’t install your own via 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

Setting TCP server mode

The ESP-01 board can run a TCP server to receive and send data, or it can act as a TCP client to receive and send 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 the possibility of multiple connections: AT+CIPMUX= mode 0 - single connection
mode 1 - multiple connection
Can you check the connection mode using the AT+CIPMUX command?
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 and 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 the 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 SocketTest.
You can view the list of active connections to the ESP-01 using 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 connections AT+CIPCLOSE without parameters.
Example:
AT+CIPCLOSE=0 OK Unlink 4. Send data from ESP-01 to PC
,
Example:
AT+CIPSEND=0.16 > Ping Habrahabr SEND OK 5. Send a test message from the PC:


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

Setting 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 connection mode to Multiple connection: AT+CIPMUX=1
4. On the PC in SocketTest we launch the server on port 8888
5. Launch the client on ESP-01
For Single connection mode (+CIPMUX=0) the format is AT+CIPSTART= ,,For 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. Send data from ESP-01 to PC
For Single connection mode (+CIPMUX=0) sending goes like this: AT+CIPSEND= For Multiple connection mode (+CIPMUX=1) sending goes like this: AT+CIPSEND= ,After executing AT+CIPSEND, you need to enter text, completion of entry and sending is carried out by Enter.
Example:
AT+CIPSEND=0.16 > Ping Habrahabr SEND OK
Example of sending and receiving data:

Useful documentation:
Description of AT Commands (Chinese)
ESP8266 chip specification (Chinese)
Specification for the ESP8266 chip (English)

Conclusion:

As we can see, the board successfully copes with the assigned tasks, namely, connecting to Wi-Fi as a client, can act as a Soft-AP, on the board you can install a TCP server to receive and send data, or you can be a TCP client .
In this article, we looked at working with the ESP-01 board via RS232; a PC acted as the control controller; you can easily connect an Arduino board or any microcontroller with UART and send and receive data via a Wi-Fi network between controllers or a PC.

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

I will be happy to answer questions, although I have not yet fully studied the ESP-01 board.

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 operate in the 2.4 and 5 GHz frequency bands (previously they tried to abandon the 2.4 GHz band in 802.11ac). Also, the new specification will quadruple the number of FFT OFDM subcarriers. But the most important change is that with the release of 802.11ax, the interval between subcarriers will also be reduced by a factor of four, while existing channel bandwidths remain unchanged:

Figure 1 - Intervals between subcarriers in 802.11ax

Thus, in the figure above we see narrower intervals 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 consider 802.11ax technologies at the physical level

In 802.11ax, the beamforming mechanism (automatic formation of a radiation pattern towards the subscriber) will be improved, compared to the earlier version of 802.11ac. According to this mechanism, the beamformer initiates a channel probing procedure using 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. A matrix of channels is then used to focus the RF energy toward each individual user. Together with beamforming, the 802.11ax standard 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 operating modes:

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 access point to operate multiple STAs simultaneously. The standard further divides this mode into multi-user Downlink and Uplink.

DownlinkMulti-User allows AP simultaneously transmit data to multiple wireless STAs that are serviced within the AP's radio coverage area. The existing 802.11ac standard already defines this feature. But multi-user Uplink is an innovation.

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

In multi-user 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 an LTE cellular base station controls multiplexing of users in its service area. Let's look at MU-MIMO and OFDMA in more detail.

Multi-user MIMO

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

802.11ax supports up to eight simultaneous multi-user MIMO streams. In addition, each MU-MIMO stream can have its own MCS (bit rate and modulation degree). An arbitrary number of threads can be organized for different users. By using MU-MIMO spatial multiplexing, the access points can be compared to an Ethernet switch with multiple ports. Each individual port is a separate MU-MIMO stream. In this case, several flows can be “forwarded” to each individual subscriber:


Figure 2 - MU-MIMO Beamforming to serve multiple, spatially dispersed 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 a trigger frame, the AP applies a 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 -

Multi-user OFDMA

The 802.11ax standard will feature a new technology for Wi-Fi, borrowed from 4G networks, for multiplexing a large number of subscribers in a common bandwidth: Orthogonal Frequency Division Multiple Access (OFDMA). This technology is based 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. As in LTE, in the 802.11ax standard the smallest subchannel is called a Resource Unit (RU), which has 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 congested environments where many users would typically compete inefficiently for channel usage, Wi-Fi's new OFDMA mechanism serves them simultaneously with a smaller, user-specific subchannel, improving 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 split accommodates up to 9 users for every 20 MHz of bandwidth:


Figure 5

Wi-Fi channel separation using 40 MHz channels:


Figure 6

Wi-Fi channel sharing 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 allow simultaneous transmission of packets from several subscribers to the access point. To coordinate MU-MIMO or Uplink OFDMA operation, the AP transmits 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 transmitted power in an effort to equalize the power received by the AP from all users, thereby improving the quality of 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 point in time when they should all start transmitting data and the exact duration of their frames to ensure that they all complete transmission at the same time. Once the AP receives frames from all users, it sends back an ACK block indicating the completion of the transmission:


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

Conclusion

One of the main goals of the 802.11ax standard is to provide higher average throughput per user (on average 4 times) in dense wireless networks. To this end, 802.11ax devices support multi-user MIMO and OFDMA technologies. The ability to simultaneously transmit from several devices to an AP access point has also been added, thereby reducing waiting time and equipment downtime due to unsuccessful attempts to capture the transmission medium. In theory, everything looks, as always, clearly and beautifully, however, what effect will be in practice - time will tell. For now, we can only say with confidence that the effect of 802.11ax will only be if all devices on the network support the new standard. Otherwise, it will be several more years before we move from good old Wi-Fi (with its hang-ups on large networks) to efficient 802.11ax.

Comfast CF-WU715N is the cheapest wireless WiFi network adapter that I could find in online stores. So today’s review will contain 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.

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

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


Appearance of the Comfast CF-WU715N network adapter

Externally, the adapter is very small in size - no larger than a two-ruble coin. Thanks to this, when connected to a laptop or computer via a USB port, it does not interfere at all and does not attract attention.

Since I placed an order from an online store in the most inexpensive package, it included only the device itself and an installation disk on which the configuration program and drivers for the adapter were recorded - in fact, nothing else is needed for work.


If you take it in a branded box, 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 this manufacturer’s line, so it would be naive to expect anything supernatural from it. But the technical characteristics allow you to work stably and without problems with a 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

Among the capabilities of this adapter, it is worth noting 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 distributing a wireless signal. There is also built-in WiFi Direct functionality. This is when devices connect to each other via wifi without using a router. By purchasing two such adapters and installing them on different PCs, you can establish communication between them without setting up a traditional local network.

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

Driver installation and configuration of Comfast CF-WU715N

Now let's see how this little wireless adapter is configured.
We insert it into the USB port, and the included disk with drivers for the adapter and a configuration program is included in the CD-Rom. It’s better not to lose the disk, since then downloading the driver for the network adapter will be problematic - the manufacturer’s official website does not have a Russian version, as well as any other version except Chinese and English. After a long search using the scientific method, I was still able to find a page for the Comfast CF-WU715N model, but I did not find any software in the downloads 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 flash drive.

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

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

If you do not plan to use your wireless adapter for WiFi Direct connections, then you do not need to install the setup program itself, since all network connections are made using standard Windows tools.


After installation, a characteristic wireless connection icon will appear in the bottom icon bar in Windows. 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” utility, which was on the disk, offers us.

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

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

If you want to directly connect to another computer that also has a wireless adapter installed that supports 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 this, we do the same on other PCs, after which all computers within 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, I am not yet able to show in detail how this happens, so wait for a new separate article!

Comfast adapter as an access point

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

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

We right-click on it and see several items. We are currently interested in the second and third ones - “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 access point mode in which your computer must be connected to the Internet via a cable or through another wireless network adapter - directly or through a router, it does not matter - and Comfast will only distribute a signal, but not receive it.

Let's choose AP mode, because in practice, when you don't have a router and need to connect to the Internet from one computer connected to a 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 this, our point will work, and the application icon in the panel will change to the letter “A”. By opening this utility again, you can 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 this, the new network will appear 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 operation on the Internet. Therefore, we measured the speed through the SpeedTest.net service. First, the starting point is the speed of the PC connected to the router via cable.

After which - through the Comfast adapter

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

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

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

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

Where to buy this network adapter, you ask? I ordered it from my favorite Chinese online store AliExpress and it cost about $5, which was about 170 rubles with our money at the time of purchase. Now, due to the dollar exchange 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 on a social network using the button above

The ESP8266 WiFi library functions are very similar to the library functions 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, the password must be at least 8 characters
  • WiFi macAddress (mac) allows you to get a MAC address in client mode
  • WiFi softAPmacAddress (mac) allows you to obtain a MAC address in access point mode
  • WiFi localIP() allows you to obtain an IP address in client mode
  • WiFi softAPIP() allows you to obtain an IP address in access point mode
  • WiFi RSSI() not implemented yet
  • WiFi printDiag(Serial); displays diagnostic information
  • Class WiFiUDP supports receiving and transmitting multicast packets in client mode. To transmit a multicast packet, use instead udp. beginPacket(addr, port) function udp. beginPacketMulticast(addr, port, WiFi. localIP()). When you are expecting multicast packets, use instead udp. begin(port) function udp. beginMulticast(WiFi. localIP(), multicast_ip_addr, port). You can use udp. destinationIP() to determine whether the packet was sent to a multicast address or was intended specifically for you. Multicast functions are not supported in access point mode.

WiFiServer, WiFiClient, And WiFiUDP I work in exactly the same way as with the library of a regular WiFi shield. Four examples come with this library.

Ticker

The Ticker library can be used to perform periodic events after a certain time. Two examples are included in the delivery.

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

EEPROM

This library is slightly different from the standard Arduino EEPROM. You need to call the function EEPROM begin(size) each time before you start reading or writing, the size (specified in bytes) corresponds to the size of the data 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 of 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 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 clock 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) is implemented in the object ESP. Function ESP. deepSleep(microseconds, mode) puts the module into deep sleep mode. Parameter mode can take values: WAKE_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED. GPIO16 must be connected to RESET to exit 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 determined by the SDK (may be less than the actual size).

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

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

OneWire Library

The OneWire library has been adapted for the ESP8266 (changes have been 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 a response to multicast DNS queries for a local zone, for example “esp8266.local”. Currently only one zone is supported. Allows you to access the ESP8266 WEB server by name, and not just by 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 servos. Supports up to 24 servos on any available GPIO. 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 work with the ESP8266's 3.3V control signal, but will not operate at 3.3V and will require a separate power supply. Don't forget to connect the GND common wire of this source to the GND 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