Help me figure out the esp8266 module

please tell me what is wrong in the code? The phone cannot connect to the access point of the module in any way

#include <ESP8266WiFi.h>
 
// Имя и пароль вашей сети WiFi
const char* ssid = "test";
const char* password = "test";
 
// Создаем сервер и порт для прослушки 80
 
WiFiServer server(80);
 
void setup() {
 Serial.begin(115200);
 delay(10);
 
 // Подготовка 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); 
 
 // присваиваем статичесий IP адрес
 WiFi.mode(WIFI_STA); // режим клиента
 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);
// Ожидание подключения
 while (WiFi.status() != WL_CONNECTED) {
 delay(500);
 Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");
  
 // Запуск сервера
 server.begin();
 Serial.println("Server started");
  
 // Вывод полученного IP адреса
 Serial.println(WiFi.localIP());
}
  
 
 
void loop() {
 
 // Проверка подключения
 WiFiClient client = server.available();
 if (!client) {
 return;
 }
 
 // Ожидание данных
 Serial.println("new client");
 while (!client.available()) {
 delay(1);
 }
 
 // Чтение первой строки запроса
 String req = client.readStringUntil('\r');
 Serial.println(req);
 client.flush();
 
 // Работа с 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<!DOCTYPE HTML>\r\n<html>\r\nTest OK. Uptime: ";
 
 // Подстчет UpTime
 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 += "</html>\n";
 client.print(s);
 client.stop();
 return;
 }
 else
 // Если неверный запрос написать об ошибке
 {
 Serial.println("invalid request");
 String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nInvalid request";
 s += "</html>\n";
 client.print(s);
 client.stop();
 return;
 }
 
 client.flush();
 
 
 
 // Формирование ответа
 String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO set OK";
 s += "</html>\n";
 
 // Send the response to the client
 client.print(s);
 delay(1);
 Serial.println("Client disonnected");
 
}

Are the pin numbers used in the code the chip pin numbers or, as is more conventional, the board pin numbers ? If the latter then they are usually referred to as printed on the board, ie with a D prefix

Which ESP8266 board or module are you using ?

Node MCU

Then try using the pin labels as printed on the board, ie with a D prefix

you have

WiFi.mode(WIFI_STA);

SoftAP is off

As per @Juraj comment. You have not set the device up in "Soft AP" mode. You have setup in "Station" mode - in this mode it expects to connect to an existing access point.

Have a look at Soft Access Point Class — ESP8266 Arduino Core 3.0.2-28-g986dd420 documentation

@arduino556665, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

how should it happen? Should the phone connect to the Wi-Fi module or the Wi-Fi module to the phone? Thank you in advance

You can do either - although just to clarify they don't connect directly - they connect to the same WiFi network. The ESP8266 can be set to connect to an existing WiFi network... probably your home network. To do that you'll need to change the SSID & password in the code...

const char* ssid = "test";
const char* password = "test";

I'd probably remove (or comment out) the following line... let the ESP8266 get an IP address from your network instead.

WiFi.config(IPAddress(192,168,1,131),IPAddress(192,168,1,111),IPAddress(255,255,255,0),IPAddress(192,168,1,1));

This statement will show the IP address of the ESP8266 on the network.

 Serial.println(WiFi.localIP());

Then from your phone browser try to connect to http:// [ESP8266 IP address] (as above).