Improving the home router on our own. CC3200 - Cortex-M4 microcontroller with built-in WiFi ESP8266 module parameters

The most numerous class of routers are models with "average" characteristics. Most of these systems, at the same time, are built on a modern element base. In theory, you can replace something in the router to improve it. Let's consider what components the router circuit contains in order to decide what exactly needs to be "upgraded".

How to improve the performance of the router

The router can be "improved" programmatically by installing an alternative firmware into it. The authors of these firmware try to make everything work on standard hardware.

A hardware upgrade of a router means installing port connectors and increasing the amount of memory. The latter, by the way, is performed at your own peril and risk, since replacing a microcircuit is a complicated operation, and the probability of success here is less than 100%.

The device of a modern router

Let's consider a block diagram of a router based on a SoC (System on Chip) chip. Memory (RAM), ROM, Wi-Fi module and clock generator are directly connected to the processor:

Router module connection diagram

In reality, many SoCs do not have five LAN controllers at their disposal (so a switch will also be soldered on the board). In addition, there will be power circuit elements, different ports (USB, COM), buttons and lights:

Router device - a look from the inside

  1. Soc chip containing CPU
  2. Flash memory
  3. RAM (2 modules of 16 Megabytes)
  4. Radio module (in this router - CX50221 or CX50321)
  5. Hardware switch
  6. Debug port
  7. SPI serial memory connector
  8. Control button and reset
  9. Contacts for USB port

You can see that there are many interfaces (for example, USB) that are not used on the board. It is logical to start the router upgrade by installing the appropriate connectors. But the fact is that the problem may lie in the absence of software in which the required interface is supported.

Any Linux based firmware (which is used in most routers) has COM port support. In the router itself, most often, such a port is also present. You just need to solder a couple of contacts to the board:

COM port on the router board

Rx and Tx are standard serial pins, Gnd is signal ground. Who needs the supply voltage can take it from the SPI connector (but this is 3.3 Volts).

Upgrading memory chips

The routers use SD-RAM or DDR memory, the same as in old computers (Pentium I..IV). Such memory sticks were produced before the advent of DDR2, but you can buy them now. However, there is no need to rush! First you need to find out which microcircuits will work on this router (not only their type, for example, PC133, but also the brand).

After replacing microcircuits, the following "negative" consequences are possible:

  1. The router works, but the amount of memory remains the same
  2. The router won't turn on or boot

The second situation may arise not because of a soldering defect, but simply because the installed microcircuits are not compatible with the processor soldered on the board. When choosing a memory "at random", it happens.

Memory in the router (two Samsung chips)

The reasons for the emergence of situation "1" may well be "software", that is, to be able to use all the memory - the standard firmware is not required.

"Hardware" reasons for volume limitation - missing track or resistor. The SoC chip addresses 128 MB (for most models). The board may lack the track of the senior address (then, only 64 MB will be "seen"). Sometimes there is a conductor, but there are no required parts (it can be a single resistor on the underside of the board).

It is important to know that the "first" contact on the microcircuit is marked with a circle or a dot. On the board in the corresponding area - there must be an arrow or a unit.

Is the upgrade really that important? It is not difficult to solder the microcircuit, it is more difficult to remove it from the board without killing it. Here are some things to keep in mind before making a decision.

We activate the required amount of memory in the firmware

You need to go to the router control console via SSH or Telnet. The latter of these protocols is supported by all models (but may be disabled by default).

Next, execute the commands:

  • nvram set sdram_init = 0x11 // true for 128MB, for 64 you need 0x13
  • nvram set sdram_config = 0x62 // or 0x32, you must try
  • nvram commit // this is how it should be

Finally, it remains to reboot the router with the reboot command. You can also view the amount of available memory from the console using the free command:

128 MB available

Happy upgrade!

And now (do not try to repeat) - replacing memory chips with a 30 Watt soldering iron:

Views: 2762

INCREASING COMPETITION
The WLAN sector is the largest in the wireless market today. Analyst firm IDC predicts that shipments of semiconductor chips for wireless LAN systems will grow from 23.5 million in 2002 to 114.5 million. in 2007, which is primarily due to the growth of their use in laptops. Thus, according to the company's analysts, by 2007, 91% of these portable systems will be equipped with 802.11a / b / g chipsets, allowing the user to connect to local networks operating at 54 Mbps (in accordance with the 802.11g standard) or 11 Mbps (in accordance with 802.11b / a) in the 2.4 (802.11b / g) and 5 GHz (802.11a) frequency bands. Already in 2003, about 42% of laptops were equipped with Wi-Fi. The use of 802.11a / b / g chipsets in mobile phones will not be so wide. According to IDC, in 2007 the share of handsets with built-in PDA functions based on 802.11a / b / g chipsets will not exceed 5%. At the same time, 802.11b chipsets will cost $ 5.9, 802.11g chipsets - $ 6.8, and dual-band 802.11a / b / g chips - $ 7.4. Fi-chips for the period under review in value terms will increase from 599 million to 1.1 billion dollars. Not surprisingly, the number of chip suppliers for WLAN systems is also growing. All of this intensifies competition in the 802.11 chip market, prompting manufacturers to reduce the number of chips in a chipset and expand their functions. A chipset designed to support the IEEE 802.11 standard must contain three main functional blocks:
· A transceiver for a frequency of 2.4 or 5.6 GHz;
· A modem that supports orthogonal frequency division multiplexing (OFDM) and CCK modulation;
· A unified media access controller (MAC) that supports one, two or all three a / b / g versions of the 802.11 standard, as well as their extensions.
802.11 chipsets on the market today typically include two chips - a MAC / baseband processor * and a radio module. At the same time, the main attention is paid to the creation of chipsets suitable for working with two or three versions of the standard.
The biggest publicity buzz was easily created by Intel in 2003 when promoting 802.11b mobile technology for Centrino notebooks and PDAs **. In 2004, the PRO / Wireless 2200BG Wi-Fi mini-PCI-modem was released, supporting versions a and b of the 802.11 standard and providing transmission speeds of 11 and 54 Mbps, respectively, as well as a PRO / Wireless 2915ABG modem that supports all three versions of the standard. The PRO / Wireless 2200BG operates in the 2.4GHz ISM band and supports Direct Sequencing (DSSS) technology for 802.11b and OFDM for 802.11g networks. In the 802.11g standard, the modem provides a transmission range indoors of 30 m at a maximum speed of 54 Mbit / s and 91 m at 1 Mbit / s, in the 802.11b standard - 30 m at 11 Mbit / s and 90 m at 1 Mbit / s. The PRO / Wireless 2915ABG modem operates in the UNII 5-GHz band and supports OFDM for 802.11a / g networks and DSSS technology for 802.11b networks. In version a of the standard, the transmission range indoors is 12 m at 54 Mbit / s and 91 m at 6 Mbit / s, in version b - 30 m at 11 Mbit / s and 90 m at 1 Mbit / s, in version g - 30 m @ 54 Mbps and 91 m @ 1 Mbps.
Intel's Wireless Compatibility System helps reduce interference between PRO / Wireless devices and Bluetooth devices. Temperature calibration tools dynamically optimize performance by adjusting the output power in response to temperature changes.
However, companies such as Broadcom, Atheros, Philips and IceFyre Semiconductor (Canada) compete successfully with Intel, outstripping it in the release of more advanced 802.11 chipsets for about $ 20 in large purchases. And the $ 300 million Intel spent on its Centrino mobile technology campaign contributed in no small measure to promoting their products on the market.
In mid-2004, Broadcom announced a single-chip 802.11g WLAN solution. Part of the AirForce One family, this BCM4318 transceiver chip is 72% smaller and cheaper than traditional Wi-Fi modules. Thanks to this, it will find wide application in laptops, pocket computers and consumer electronics. The microcircuit is based on BroadRange technology, which uses digital signal processing methods to obtain high sensitivity. It contains a highly efficient 2.4 GHz RF unit, an 802.11a / g baseband processor, MAC and other radio components. By reducing the number of components used by 45% in comparison with existing solutions, the microcircuit can reduce the cost of equipment for networks of household devices and devices of small businesses in which it is used.
The microcircuit supports 54g technology, a variant of Broadcom's implementation of the 802.11g standard. This technology provides the industry's best combination of performance, coverage and data protection. The company's 54g products are compatible with over 100 million 802.11b / g devices installed to date.
The chip features a power management scheme that extends battery life, and the company's SuperStandby software checks for incoming messages to ensure that the minimum number of chips is turned on for the shortest possible time. As a result, standby power consumption is 97% less than traditional WLAN solutions.
In addition, the company released a system-on-a-chip, a single-chip BCM5352E router that performs 54 Mbps routing, Fast Ethernet switching, and MIPS command set processing. Both chips support the company's OneDriver software for superior performance and security.
In the fall of 2004, Broadcom released a 54g BCM4320 with a built-in USB 2.0 interface. The microcircuit provides the possibility of Wi-Fi connection of any device with a USB 2.0 port to a local network. By placing the 802.11a / g standard MAC / baseband processor, USB 2.0 transceiver, processor core and memory in one case, the company not only reduced the size and power consumption of the wireless communication module, but also reduced the cost of materials used by 50%.
One of the most famous developers of MAC chips and processors, as well as software for WLAN systems, is Texas Instruments. Its TNETW1130 single-chip MAC / baseband processor (Figure 1) supports 54 Mbps in the 2.4 and 5 GHz frequency bands, as well as all three a / b / g versions of the 802.11 standard. The chip is selected by the Wi-Fi Alliance as a design reference used in verifying interoperability of 802.11g devices and ensuring interoperability of networks with 802.11b and 802.11g devices. In accordance with the requirements of the 802.11i standard, which provides the highest level of data protection today, the chip contains an accelerator for implementing Protected Access Protocols (WPA) and mandatory and optional programs of the AES standard. It also provides a Quality of Service (QoS) support block to perform an extended distributed coordination function and a hybrid coordination function, which allows frequency band determination of emerging applications in real time, such as voice over WLAN, radio transmission, video conferencing, etc. In addition, the function of the microcircuit includes power control during transmission, which allows you to optimize power consumption and extend battery life.
The TNETW1130 microcircuit is mounted in a 257-pin BGA-type package with a size of 16x16 mm. The package is pinout compatible with previous generations of MAC / baseband processors.

CONNECT MORE, CONSUME LESS
One of the main directions of work of modern chipset manufacturers for 802.11 standard networks is to increase the operating range. This parameter for most standard Wi-Fi modems does not exceed 100 m indoors and 300 m in open space in the line of sight. Atheros Communications' 4th generation 802.11a / b / g chipset of the AR5004X series, which contains two chips and is made using extended range technology (eXtended Range - XR), provides twice the range - up to 790 m. any 802.11 standard currently in force anywhere in the world. The chipset includes two microcircuits made using CMOS technology (Fig. 2):
· A dual-band "radio station-on-chip" (RNC) type AR5112, designed for the frequency ranges 2.3-2.5 and 4.9-5.85 GHz and containing a power amplifier and a low-noise amplifier. For special applications, it is possible to use external amplifiers (power and low noise). The microcircuit eliminates the need for IF filters and most RF filters, as well as external VCO and SAW filters. The supply voltage of the microcircuit is 2.5–3.3 V;
· Multi-protocol MAC / baseband-processor of AR5213 type, supporting RNA. The microcircuit contains blocks of data compression in real time, fast frame and packet transmission, DAC and ADC. Supply voltage 1.8–3.3 V.
The increase in transmission range has been achieved by improving the MAC / baseband processor chip, rather than the RF chip. The XR technology used in the microcircuit allows tracking, calibrating and interpreting the signals of the four OFDM channels. By dropping the transmission rate at large distances, the problem of reducing the peak-to-average power ratio is solved and the coding efficiency is improved.
The data transfer rate in the 802.11a standard is 6-54 Mbps, in the 802.11b standard - 1-11 Mbps and 802.11g - 1-54 Mbps. The chipset also provides the ability to operate in Super G and Super AG modes, which use adaptive radio technology and automatically detect free channels in order to ensure maximum throughput. At the same time, the transmission speed reaches 108 Mbit / s. As a result, the typical user channel throughput can exceed 60 Mbps. The receiver sensitivity provided by the chipset is -105 dBm, which is more than -20 dBm better than the value of this parameter given in the standard.
Another important advantage of the new chipset is the reduction in power consumption. Most modern WLAN radios are always on, even when no data is being sent or received. In a radio station based on the new chipset, the power is turned off when inoperative, and as a result, the total power consumption in comparison with other similar devices is reduced by 60% (even when operating at a transfer rate of 54 Mbps), and the current consumption in standby mode is only 4 mA.
The chipset provides not only wireless connectivity, but also a theft alarm. In this mode, the power supply of the microcircuits of the set is not turned off, even if the device in which they are used (laptop, PDA or other host device) does not work. If triggered by theft, the chipset warns the network of unauthorized removal of the mobile device, even if the device is turned off.
The microcircuits of the kit are mounted in a 64-pin leadless plastic case-carrier of the crystal with a size of 9x8 mm or in a 196-pin BGA-type package.
At the end of 2004, Atheros announced the creation of the world's first fully functional Wi-Fi module, the AR5006X, based on the AR5413 single-chip CMOS chip (Figure 3), which implements 802.11a / b / g LAN connectivity. The microcircuit contains a MAC, baseband processor and a dual-band RF unit with improved characteristics. With seamless connectivity to any Wi-Fi network, 802.11i support, and XR and Super AG support, the AR5006X will be in great demand among manufacturers of integrated systems for PCs, industrial, retail and consumer electronics equipment. The AR5006X not only eliminates one chip from the previous chipset, but also reduces the number of discrete components used by 24. As a result, it was possible to reduce the number of components used in developed devices by 15% and significantly reduce material costs.
The AR5413 802.11a / b / g single chip uses an advanced wideband receiver that incorporates the best channel sequencing controller, providing longer transmission range and better multipath resistance than traditional EQ devices. As with the previous RNA chip, an external power amplifier and low noise amplifier can be used for special applications, and all IF and most RF filters, as well as external VCOs and SAW filters, are excluded. In general, in terms of its parameters, a single-chip microcircuit is comparable to the previous chipset.
The supply voltage is 1.8–3.3 V. The microcircuit is mounted in a plastic BGA-type case 13x13 mm in size.
Mass production of the WLAN device was planned for the fourth quarter of 2004. Its price should not exceed $ 12 when purchasing a batch of 10 thousand pieces.
The possibilities offered by the 802.11 standard, and hence the markets for microcircuits and chipsets for them, are endless. If every pocket computer and cell phone is equipped with a means of supporting this standard (or at least part of it), the number of users of such devices will increase from tens of millions to hundreds of millions of people. This will require a large number of low-power chipsets. The first step towards creating such microcircuits was made by IceFyre Semiconductor, which announced at the end of 2003 that it had created two chipsets: one - SureFyre of the 802.11a standard and the second - TwinFyre to support all three versions of the a, b and g standard.
The SureFyre Chipset includes:
ICE5125 low-power microcircuit of the MAC controller, supporting versions 802.11a, b, h, I and providing guaranteed quality of data transmission services at a speed of more than 30 Mbps (Fig. 4). The controller architecture can be scaled to provide data rates up to 108 Mbps;
· A physical layer 802.11 chip of the ICE5351 type (according to the developers, at the time of the chipset creation it was the only single-chip physical layer of the 802.11a standard);
· An ICE5352 5GHz Chirex stacking GaAs class F power amplifier that outperforms traditional class AB amplifiers in the 40–120mW output power range.
Improving the design of the traditional OFDM modem, the company's developers have managed to fit three computing mechanisms into the ICE5351 physical layer microcircuit. This is a Light Clipper, limiting the ratio of the peak power to the average power of the OFDM signal to an acceptable level; adaptive pre-distortion source; a phase fragmentator that splits the OFDM transmission signal into multiple signals with a constant envelope with a peak-to-average power ratio of 0 dB (Fig. 5).
The TwinFyre chipset includes the same ICE5125 MAC controller and ICE5352 power amplifier chips, as well as a dual-band ICE5825 physical layer chip with an integrated baseband processor supporting CCK modulation, and an 802.11b / g radio module ICE2501, which ensures the chipset operation in two ranges.
The peak output power of both chipsets exceeds 1.1W at a transfer rate of 54Mbps. The receiver sensitivity and linearity of the transmission signal are 10 and 2 dB better than in the 802.11 standard, respectively. So, the sensitivity of the receiver at a transmission rate of 54 Mbit / s is -75 dB (against the level specified by the standard -65 dB), at the minimum transmission rate (6 Mbit / s) it is -95 dB. With a delay spread tolerance of 150 ns, antenna spacing and power control for each packet transmission, the indoor range at 54 Mbps and 6% transmission error rate can exceed 40 m. With an outdoor point-to-point connection, the transmission range at a top speed of 2.9 km. In addition, the SureFyre and TwinFyre chipsets provide designers with greater flexibility by allowing either the complete system or just the physical layer to interface with an embedded host or proprietary MAC chip. The linearity of the signal transmission of the TwinFyre chipset when the 802.11b standard is implemented is -30 dB, the 802.11g standard is -27 dB. Average RF output power exceeds 20 dBm.
The maximum power consumption of both chipsets is almost half that of competing chipsets - 720 mW. With such low power consumption and aggressive power regulation, IceFyre's chipsets will be able to connect a cell phone or PDA to an 802.11 network. Moreover, these chipsets will facilitate the formation of networks of consumer devices, including TV, audio system, set-top box, cable modem, and the like.
IceFyre planned to begin large-scale production of the 802.11a chipset in the first quarter of 2004, and the 802.11a / b / g TwinFyre chipset in the third quarter of that year. The SureFyre chipset was supposed to start at around $ 20, and the TwinFyre will sell for $ 5-7 more.

ANSWER TO MIMO TECHNOLOGY
As in any industry, successfully bringing WLAN systems to the market requires continually increasing bandwidth and improving communication quality. The following three key areas of work to improve such systems can be distinguished:
· Improvement of radio communication technology in order to increase the transmission speed;
· Development of new mechanisms for the implementation of physical layer modes;
· Improving transmission efficiency to compensate for the performance degradation associated with the transmission of headers and switching the radio to transmit mode.
And with all this, it is necessary to support all three versions of the 802.11 standard. One of the ways to increase the transmission speed of wireless systems is to use multiple antennas at the input and output of the chip for implementing a wireless LAN connection. This technology, called multiple-input multiple-output (MIMO), or smart antenna technology, exploits multipath propagation, which is so undesirable in wireless communication systems, putting it at the service of these systems (Figure 6). It allows you to consistently retrieve information from multiple channels using spatially separated antennas. MIMO technology solves the problem of increasing transmission speed over long distances and full compatibility with existing standards. And all this without using additional frequency spectrum. MIMO will be a key technology to enable the 802.11n standard, which supports transmission rates above 100 Mbps, according to Wi-Fi semiconductor chip companies. In the United States alone, there are 24 non-overlapping channels in the 5 GHz band and three channels in the 2.4 GHz band. At 100 Mbps data rates for each of these 27 channels, the available bandwidth can reach 3 Gbps.
MIMO technology has been developed since 1995 by scientists at Stanford University, who later formed Airgo Networks (www.airgonetworks.com), which in August 2003 announced the creation of an experimental Wi-Fi chipset of the AGN100 type, made using True MIMO technology based on a unique multi-antenna system and providing a transmission speed of up to 108 Mbit / s. However, in order to achieve such speed, it is necessary to use routers and client boards, which are based on the company's MIMO technology. At the same time, the new chipset is compatible with all existing Wi-Fi standards. Tests have shown that in terms of transmission range, the chipset is two to six times greater than the devices that existed at the time of its release. As a result, the coverage area of ​​each Access Point (AP) has increased by an order of magnitude.
The AGN100 chipset contains two chips - a MAC / baseband processor (AGN100BB) and an RF module (AGN100RF). The chip architecture is scalable, allowing the manufacturer to implement a single antenna system using a single RF chip, or increase bandwidth by adding additional RF chips. The chipset supports all three versions of 802.11a / b / g and meets the requirements of the 802.11i standard adopted by the IEEE working group for communication safety and security, as well as the standard for the quality of services provided.
As the company reported in late 2004, more than 1 million MIMO chipsets have been purchased in the retail market in one quarter since the start of sales.
The growing popularity of MIMO technology is evidenced by the fact that at the Consumer Electronics Show (CES), held on January 6-9, 2005, a number of OEMs presented their WLAN systems based on this technology or their descriptions. And many of these systems, including those from Belkin, Netgear, and Linksys, are based on chipsets from Airgo Networks.
The situation is aggravated by the demonstration at CES by Atheros Communications of the AR5005VL chipset, which supports MIMO-like operation of systems based on smart antennas. The chipset supporting both 802.11g and 802.11a / g versions can operate with four antennas and provide 50 Mbps user performance when installed at both ends of the line (when installing the chipset at one end of the network with many different 802.11g standard devices, the performance is 27 Mbps). It uses phase antenna beamforming and relay cyclic diversity techniques. In addition, the circuit provides advanced signal processing techniques that combine incoming RF signals and thereby increase the intensity and quality of received signals.
The 802.11a / g chipset is priced at $ 23 in a 10K batch, and the 802.11g chipset is priced at less than $ 20.
The market for WLAN devices has grown significantly over the past four years, and, obviously, its growth rate will not slow down in the near future. And this opens up great opportunities for manufacturers of the element base of such devices.

WLAN MICROCIRCUIT SUPPLIERS

Company

The ESP-01 Wi-Fi module is the most popular module in the ESP8266 series. Communication with a computer or microcontroller is carried out via the UART using a set of AT commands. In addition, the module can be used as an independent device, for this you need to load your firmware into it. You can program and download firmware through the Arduino IDE version higher than 1.6.5. You will need a UART-USB adapter to flash the module. The ESP-01 module can be widely used for use in IoT (Internet of Things) devices.

Specificationsmodule

  • Wi-Fi 802.11 b / g / n
  • WiFi modes: client, hotspot
  • Output power - 19.5 dB
  • Supply voltage - 1.8-3.6 V
  • Consumption current - 220 mA
  • GPIO Ports: 4
  • CPU clock speed - 80 MHz
  • The amount of memory for the code
  • RAM - 96 KB
  • Dimensions - 13x21mm

Connection

Let's take a look at the AT command mode. To do this, connect the module to the computer via a USB-UART adapter. Module pin assignment (see Figure 1):
  • VCC - +3.3 V
  • GND - ground
  • RX, TX - UART pins
  • Output CH_PD - Chip enable
  • GPIO0, GPIO2 - digital pins
The module requires external 3.3V power supply.

Figure 1. Pin assignment of the ESP-01 module

Connection diagram for communicating with the module in AT command mode (Figure 2):

Figure 2. Scheme of connecting the ESP-01 module to a computer via a serial port

Figure 3. Schematic assembly

You can use CoolTerm to send AT commands in Mac OS X, and Termite in Windows. You can only find out the speed of the COM port for connecting to the module experimentally; it can be different for different firmwares. For my module, the speed turned out to be 9600 baud. In addition, it was possible to establish exchange only after disconnecting and reconnecting to the power supply of the CH_PD pin. After connecting, we type AT in the terminal and should receive OK in response from the module. The AT + GMR command gives the module firmware version number, the AT + RST command - reboots the module (see Fig. 4). A list of basic AT commands can be found in this document (ESP8266ATCommandsSet.pdf).

Figure 4. Sending AT commands to the module from the Termite program

If the AT command mode is not convenient for you, the board can be configured using the AppStack ESP8266 Config program, which can be downloaded from the link http://esp8266.ru/download/esp8266-utils/ESP8266_Config.zip. The appearance of the program is shown in Figure 5. The module is configured using the graphical interface, while the execution of commands can be seen in the program monitor (see Figure 6). In the monitor, you can also send AT commands from the command line.

Figure 5. AppStack ESP8266 Config Program

Figure 6. Serial monitor of AppStack ESP8266 Config

There are two options for using this module:

  • in conjunction with a microcontroller (for example, Arduino), which will control the module via UART;
  • writing your own firmware to use the ESP8266 as a standalone device.

Usage example

Let's consider an example of connecting a DHT11 humidity and temperature sensor to the ESP-01 module and sending data to the ThingSpeak cloud service (https://thingspeak.com/). We need the following details:
  • ESP-01 module
  • bread board
  • DHT11 humidity and temperature sensor
  • 10k ohm resistor
  • connecting wires
  • power supply unit 3 - 3.6V
First, let's connect the DS18B20 sensor to the ESP-01 module. DS18B20 is a digital temperature sensor operating over a 1-Wire single-wire interface. The connection diagram of the DS18B20 sensor to the module is shown in Fig. 7.

Figure 7. Diagram of connecting DHT11 sensor to ESP-01 module.

Then you need to create a profile in the ThingSpeak service. The service has instructions for sending data to the service and receiving data from the service.

Figure 8. Assembly diagram.

We will write the program in the Arduino IDE for ESP8266. We will use the ESP8266WiFi.h (built-in) and OneWire.h libraries. Let's upload the sketch from Listing 1 to the Arduino board - getting data from a temperature sensor and sending data to the ThingSpeak service. You need to enter your data for the WiFi access point for the ESP-01 module:

  • const char * ssid;
  • const char * password;
as well as the privateKey parameter for your application in the ThingSpeak service. Listing 1 // site // We include the library for working with esp8266 #include // Include the DHT library to work with DHT11 #include // pin for connecting the DATA contact #define DHTPIN 4 // DHT11 sensor #define DHTTYPE DHT11 // creating an instance of the DHT DHT object dht (DHTPIN, DHTTYPE); // ssid of WiFi connection network const char ssid = "********"; // Password of the WiFi network of the connection const char password = "******"; // ThingSpeak Server const char * host = "184.106.153.149"; // API KEY of your ThingSpeak application const char * privateKey = "****************"; // variables for storing temperature and humidity float temp; float humidity; // variable for the measurement interval unsigned long millis_int1 = 0; void setup () (// start the serial port Serial.begin (115200); delay (10); Serial.print ("Connect to WiFi"); Serial.println (ssid); // Connect via WiFi WiFi.begin (ssid , password); while (WiFi.status ()! = WL_CONNECTED) (delay (500);) Serial.println ("WiFi connected"); // start dht dht.begin ();) void loop () (// wait for 10 minutes interval if (milis () - millis_int1> = 10 * 60000) (Serial.print ("connect to ThingSpeak"); Serial.println (host); // Use WiFi client WiFiClient client; if (! client.connect (host, 80)) (Serial.println ("connection failed"); return;) // get temperature data temp = get_data_temperature (); humidity = get_data_humidity (); // Create a URL with a request for the server String url = "/ update? key = "; url + = privateKey; url + =" & temp = "; url + = temp; url + =" & humidity = "; url + = humidity; // Send a request to the server client.print (String (" GET ") + url +" HTTP / 1.1 \ r \ n "+" Host: "+ host +" \ r \ n "+" Connection: close \ r \ n \ r \ n "); delay (10); // ThingSpeak server response while (client.available ()) (String req = client.readStringUntil ("\ r"); Serial.print (req);))) Now in the ThingSpeak service we can watch the graph of our DHT11 temperature sensor (Figure 9).

Figure 9. Diagram of the DS18B20 temperature sensor readings in the ThingSpeak service.

Frequently Asked Questions FAQ

1. The module does not respond toAT commands
  • Check if the module is connected correctly;
  • Check the correct connection of the Rx, Tx pins to the UART-USB adapter;
  • Check the connection of the CH_PD pin to 3.3V;
  • Experimentally select the baud rate for the serial port.
2. The ESP-01 module does not receive temperature data from the sensorDHT11
  • Check the correct connection of the DHT11 sensor to the module.
3. Data is not transferred to the ThingSpeak service
  • Check the module's connection to the WiFi access point;
  • Check the connection of the WiFi access point to the Internet;
  • Verify the request to the ThingSpeak service is correct.

Today I propose to get acquainted with the novelty of radio amateur technology - the WiFi module. It is something like the already familiar NRF24L01, but slightly smaller in size and slightly different functionality. The WiFi module has both its undeniable advantages and some disadvantages, the latter is most likely partly due to the fact that it is a novelty and the developers approached this in a very strange way - information is spread very tightly (the documentation only gives general ideas about the modules, without disclosing their full functionality). Well, let's wait for the leniency of the company that provided the "hardware".

The cost of the module is especially worth noting: at the moment it is $ 3-4 (for example, on AliExpress)

Right NRF, left ESP module.

What exactly are these WiFi modules? The WiFi chip itself is located on the board, in addition, there is an 8051 microcontroller in the same case, which can be programmed without a separate microcontroller, but more on that another time, then there is an EEPROM memory chip on the board, which is necessary to save the settings, also on the module board there is all the minimum necessary piping - a quartz resonator, capacitors, a bonus LED indication of the supply voltage and transmission (reception) of information. The module implements the UART interface only, although the capabilities of the WiFi chip allow you to use other interfaces. A WiFi antenna of the required configuration is made with a printed conductor on the board. The biggest part is the 4 x 2 pin connector.

To connect this module to the circuit, you need to connect the power to VCC and GND, to TX and RX the corresponding UART pins of the receiving device (remember that RX connects to TX, and TX to RX) and CH_PD (like an enable chip, without it everything is on, but nothing works) for plus power supply.

ESP8266 module parameters:

  • supply voltage 3.3 V (and the module itself tolerates 5 V, but the I / O pins will most likely refuse to work)
  • current up to 215 mA in transmission mode
  • current up to 62 mA during reception
  • 802.11 b / g / n protocol
  • + 20.5dBm power in 802.11b mode
  • SDIO (two pins are present on the module board, but they cannot be especially used except for service operations)
  • power save and sleep modes to save power
  • built-in microcontroller
  • AT command control
  • operating temperature from -40 to +125 degrees Celsius
  • maximum communication distance 100 meters

As mentioned, the module can be controlled by AT commands, but their full list is not known, the most necessary is presented below:

# Team Description
1 Just a test command, under normal state the module will reply OK
2 AT + RST
3 Checking the firmware version of the module, the answer is the version and the answer is OK
4

AT + CWMODE =<режим>

Set the operating mode of the module mode: 1 - client, 2 - access point, 3 - combined mode, answer OK
5 Get a list of access points to which you can connect, answer a list of points and OK
6

AT + CWJAP =<имя>,<пароль>

Join the access point by specifying its name and password, the answer is OK
7 Disconnect from access point, answer OK
8

AT + CWSAP =<имя>,<пароль>,<канал>,<шифрование>

Set the access point of the module itself, setting its parameters, the answer is OK
9 Get a list of connected devices
10 Get the current status of a TCP connection
11


AT + CIPSTART =<тип>,<адрес>,<порт>

AT + CIPSTART =<айди>,<тип>,<адрес>,<порт>

TCP / UDP connection
<айди>- connection identifier
<тип>- connection type: TCP or UDP
<адрес>- IP address or URL
<порт>- port
12

AT + CIPMODE =<режим>

Set transfer mode:

<режим>= 0 - not data mode (the server can send data to the client and can receive data from the client)
<режим>= 1 - data mode (the server cannot send data to the client, but can receive data from the client)

13

For one connection (+ CIPMUX = 0):
AT + CIPSEND =<длина>
For multi connection (+ CIPMUX = 1):
AT + CIPSTART =<айди>,<длина>

Send data
<айди>- connection identifier
<длина>- the amount of data sent
The transmitted data is sent after the module responds to the> character, after entering the command
14

For one connection (+ CIPMUX = 0):
AT + CIPCLOSE
For multi connection (+ CIPMUX = 1):
AT + CIPCLOSE =<айди>

Close the connection. Parameter for multi-threaded mode<айди>- connection identifier. Module response should be OK and unlink
15 Get module IP
16

AT + CIPMUX =<режим>

Set the number of connections,<режим>= 0 for one connection,<режим>= 1 for multi-stream connection (up to four connections)
17

AT + CIPSERVER =<режим>, <порт>

Raise the port.<режим>- stealth mode (0 - hidden, 1 - open),<порт>- port

18

AT + CIPSTO =<время>

Set the time of one connection on the server
19

AT + CIOBAUD =<скорость>

For firmware versions from 0.92, you can set the UART speed
20

Receiving information

Data is received with a + IPD preamble, followed by information about the received data, and then the information itself

For one connection (+ CIPMUX = 0): + IPD,<длинна>:<передаваемая информация>

For multi connection (+ CIPMUX = 1): + IPD,<айди>,<длинна>:<передаваемая информация>

Example: + IPD, 0.1: x - 1 byte of information received

How the commands are entered:

  • Executing the command:<Команда>.
  • View status by command:<Команда>?
  • Run the command with parameters:<Команда>=<Параметр>

When purchasing a module, you can check the firmware version of the module via the AT + GMR command. The firmware version can be updated using a separate software, or with firmware version 0.92 and older, this can only be done using the AT + CIUPDATE command. In this case, the module must be connected to a router to access the Internet. The firmware and the program for the module firmware up to version 0.92 will be provided at the end of the article. For firmware flashing, you need to connect the GPIO0 pin to the plus of the power supply. This will enable the module update mode. Then select the module firmware file in the program and connect to the WiFi module, the firmware update will go automatically after connection. After the update, subsequent firmware updates will only be possible via the Internet.

Now, knowing the organization of the WiFi module commands, on its basis it is possible to organize the transfer of information via wireless communication, which, in my opinion, is their main purpose. For this, we will use an AVR Atmega8 microcontroller as a device that is controlled via a wireless module. Device diagram:

The essence of the scheme will be as follows. The DS18B20 temperature sensor measures the temperature, processed by the microcontroller and transmitted over the WiFi network with a short time interval. In this case, the controller monitors the received data via WiFi, when the symbol "a" is received, LED1 will light up, when the symbol "b" is received, the LED will go out. The scheme is more demonstrative than useful, although it can be used for remote temperature control, for example, on the street, you only need to write software for a computer or phone. The ESP8266 module requires a 3.3 volt power supply, so the entire circuit is powered by the 3.3 volt AMS1117 regulator. The microcontroller is clocked from an external 16 MHz crystal oscillator with 18 pF capacitors. Resistor R1 pulls the reset leg of the microcontroller to the positive power supply to prevent spontaneous restart of the microcontroller in the presence of any interference. Resistor R2 performs the function of limiting the current through the LED so that neither it nor the MK pin is burned out. This circuit can be replaced, for example, with a relay circuit and use the circuit for remote control. Resistor R3 is required for the thermometer to operate on the 1-Wire bus. The circuit must be powered from a sufficiently powerful source, since the peak consumption of the WiFi module can reach 300 mA. This is probably the main drawback of the module - high consumption. Such a battery-powered circuit may not work for a long time. When power is applied to the circuit during its initialization, the LED should blink 5 times, which will indicate the successful opening of the port and previous operations (after turning on the circuit, by pressing the reset button, the LED can blink 2 times - this is normal).

In more detail, the operation of the circuit can be viewed in the source code of the microcontroller firmware in the C language, which will be presented below.

The circuit was assembled and debugged on a breadboard, the DS18B20 thermometer is used in the "probe" format with a metal cap:

To "communicate" with such a circuit, you can use either a standard WiFi controller of a computer, or build a transceiver circuit using a USB-UART converter and another ESP8266 module:

Speaking of adapters and terminals, these modules are quite capricious to them, work well with a converter on CP2303 and refuse to adequately work with converters built on microcontrollers (homemade), the terminal is best suited to Termite (there is an automatic addition of a carriage return character in the settings, without which the module will also not work adequately with the terminal). But just when connected to a microcontroller, the modules work flawlessly.

So, to exchange information with the microcontroller via WiFi, we will use the second module connected to the computer and the Termite terminal. Before starting work with the circuit, each module must be connected via USB-UART and several operations must be done - set up the operating mode, create a connection point and connect to the point to which we will subsequently connect to exchange information, use the AT command to find out the IP address of the WiFi modules (it will be necessary to to connect modules to each other and exchange information). All these settings will be saved and will be automatically applied each time the module is turned on. Thus, you can save a little memory of the microcontroller on the commands for preparing the module for operation.

The modules work in a combined mode, that is, they can be both a client and an access point. If, according to the settings, the module is already working in this mode (AT + CWMODE = 3), then when you try to configure it in the same mode, the module will respond with "no change". For the settings to take effect, you need to restart the module or enter the AT + RST command.

After similar settings of the second module, our point named "ATmega" will appear in the list of available points:

In our case, the WiFi scheme will be as follows - the module with the microcontroller will connect to the home router (in fact, the microcontroller in this case can go online, if it is prescribed), then raise the port and act according to the algorithm. On the other side, we will also connect the module to the router and connect to the microcontroller via TCP (as shown in the screenshot, for this you need to configure the transmission mode and the number of connections with the AT + CIPMODE and AT + CIPMUX commands, respectively, and enter the command to connect to the AT + CIPSTART server). Everything! If you connect to an access point (WiFi point only, you need to reconnect to the server every time, just as every time the server needs to be lifted at the other end every time the power is turned on) and restart the module, then there is no need to connect again on your own, this is also stored in memory and automatically connects when available when the module is turned on. Convenient, however.

Now the temperature data should automatically go to the computer, and the LED can be controlled by commands from the computer. For convenience, you can write software for Windows and monitor the temperature via WiFi.

With the AT + CIPSEND command we send data, when data is received, the message "+ IPD,<айди>,<длинна информации>: "after the colon is our useful (transferable) information that needs to be used.

One BUT - it is desirable to power the module not from batteries, but from the stationary power supply of the socket (naturally through the power supply) due to the high consumption of the modules.

This is one of the options for transferring information between WiFi modules, you can also connect them directly to each other without a router, or you can connect to the module via a standard WIFi computer and work through it.

The most obvious of these modules is involved, who knows what else the developers have prepared for us!

To program the microcontroller, you need to use the following combination of fuse bits:

In conclusion, I would like to note that this is truly a revolution in the Internet of Things! With a module price of several green units, we have a full-fledged Wi-Fi module with huge capabilities (which are still limited by the developers of this miracle), the scope of application is simply not limited - wherever imagination allows, and given the fact that this module already there is a microcontroller, there is no need to use an external microcontroller, however, which needs to be programmed somehow. So, friends, this is the case - we give Wi-Fi to each outlet!

The article is accompanied by the firmware for the microcontroller, the source code in the program, the documentation for the Wi-Fi module microcircuit, the program for updating the module firmware and the module firmware version 0.92 (the archive is divided into 3 parts, because its total size is too large to be attached to article), as well as a video demonstrating the operation of the circuit (in the video, the controlled board connected via WiFi to the control module, the controlled board periodically transmits information about the temperature, when the thermometer is immersed in water, the video shows that the temperature begins to drop, then if you transmit the symbol " a "from the control module, the LED on the controlled board will light up, and if the symbol is" b ", it will go out).

This seems to be all. Do not forget to write your comments and suggestions, if there is attention to this topic, we will develop ideas for new ones.

List of radioelements

Designation A type Denomination number NoteScoreMy notebook
U1 WiFi module1 Into notepad
IC1 MK AVR 8-bit

ATmega8

1 Into notepad
IC2 temperature sensor

DS18B20

1 Into notepad
VR1 Linear regulator

AMS1117-3.3

1 Into notepad
C1, C2 Capacitor18 pF2 Into notepad
C3, C7, C8 Electrolytic capacitor100 uF3