Build a DIY WiFi Extender Using ESP32 for Under $5

Build a cheap DIY WiFi extender using an ESP32 development board. Install Arduino IDE, configure the ESP32, upload the code and extend your WiFi network using AP, STA and NAPT.

DIY WiFi extender project using an ESP32 development board to extend wireless internet coverage
ADVERTISEMENT

Having a weak WiFi signal in certain rooms can be frustrating, especially when your router is located far away. Commercial WiFi extenders can solve this problem, but what if you could build a basic WiFi extender using an inexpensive ESP32 development board?

In this project, we will use an ESP32 to connect to your existing WiFi router and create a separate wireless network that other devices can connect to. By configuring the ESP32 in Access Point and Station modes and enabling NAPT, connected devices can share the internet connection received from your original router.

This project is designed as a low-cost DIY experiment. An ESP32 development board may cost less than $5 depending on the seller, board version and shipping costs. Performance will not be equivalent to a dedicated commercial WiFi extender.

How Does an ESP32 WiFi Extender Work?

The ESP32 connects to your existing router as a WiFi client, also known as Station mode or STA. At the same time, it creates another WiFi network that nearby devices can join using Access Point mode or AP.

The ESP32 receives internet connectivity from your original router and shares it with devices connected to its newly created WiFi network. NAPT (Network Address and Port Translation) allows multiple connected devices to share the upstream network connection.

  • Original router: Provides the internet connection.
  • ESP32 Station mode: Connects to the original router.
  • ESP32 Access Point mode: Creates a new WiFi network.
  • NAPT: Allows connected clients to share the ESP32's upstream connection.

Components Required

You do not need many components to build this project. An ESP32 development board, a USB cable and a computer are enough to get started.

  • ESP32 development board (ESP32 DevKit or compatible)
  • USB data cable compatible with your board
  • Windows PC or laptop
  • Existing WiFi router with internet access
Some ESP32 boards use Micro USB while others use USB Type-C. Make sure your cable supports data transfer, not only charging.

Step 1: Install Arduino IDE From the Microsoft Store

Arduino IDE is the software we will use to write, compile and upload the WiFi extender program to the ESP32. Windows users can install Arduino IDE directly from the Microsoft Store.

  • Open the Microsoft Store on your Windows computer.
  • Search for Arduino IDE.
  • Find the official Arduino IDE application.
  • Click Install and wait for the installation to finish.
  • Launch Arduino IDE from the Start menu.

If you cannot find the application in your Microsoft Store, you can download Arduino IDE from the official Arduino website instead.

Download Arduino IDE from the official Arduino website

Step 2: Install the ESP32 Board Package

Arduino IDE does not include ESP32 board support by default. We need to install the board package developed by Espressif Systems before we can compile and upload programs to our ESP32.

  • Open Arduino IDE.
  • Click File and open Preferences.
  • Locate the Additional Boards Manager URLs field.
  • Add the ESP32 board package URL below.
  • Click OK to save the preferences.
text
https://espressif.github.io/arduino-esp32/package_esp32_index.json

If you already have other board package URLs in the field, add the ESP32 URL separated by a comma instead of replacing your existing URLs.

  • Open Tools > Board > Boards Manager.
  • Search for ESP32.
  • Find the package named esp32 by Espressif Systems.
  • Click Install.
  • Wait for the package and its required files to download and install.
Install the official package named esp32 by Espressif Systems. Avoid installing unrelated third-party board packages.

Step 3: Connect the ESP32 and Select the Board

Connect your ESP32 development board to your computer using a USB data cable. Arduino IDE should detect the serial connection if the board's USB interface and drivers are working correctly.

  • Connect the ESP32 board to your PC.
  • Open Tools > Board > ESP32 Arduino.
  • Select ESP32 Dev Module for a common ESP32-WROOM development board.
  • Open Tools > Port.
  • Select the COM port that appears after connecting your board.
The correct board selection depends on your ESP32 model. ESP32 Dev Module works with many standard ESP32 development boards, but ESP32-S2, S3, C3 and other variants may require their specific board selection.

How to Identify the Correct COM Port

If you are unsure which COM port belongs to the ESP32, disconnect the board and check Tools > Port. Connect the ESP32 again and look for the new port that appears. Select that newly detected port.

Some development boards use a CH340 or CP210x USB-to-serial chip. If no COM port appears, you may need to install the appropriate USB driver for your board. Also try another USB cable or port because some USB cables only provide power.

Step 4: Configure Upload Speed and Serial Baud Rate

Before uploading the code, check the board settings. For this project, use a conservative upload speed to reduce upload errors. The Serial Monitor must also use the same baud rate specified in Serial.begin() inside our program.

SettingValue
BoardESP32 Dev Module (or your matching board)
PortYour ESP32 COM port
Upload Speed115200
Serial Monitor Baud115200
Program baud rateSerial.begin(115200)

You can find the upload speed under Tools > Upload Speed. Select 115200. This is the data transfer speed used while uploading the program over the serial connection.

The Serial Monitor baud rate is different from the upload speed setting. Open the Serial Monitor and set its baud rate to 115200 so that the messages printed by the ESP32 appear correctly.

Step 5: Configure Your WiFi Credentials

Now we need to enter the WiFi credentials of the router that already has internet access. We will also choose a name and password for the new WiFi network that the ESP32 will create.

cpp
const char* ROUTER_SSID     = "YOUR_ROUTER_WIFI";
const char* ROUTER_PASSWORD = "YOUR_ROUTER_PASSWORD";


const char* EXTENDER_SSID     = "ESP32_Extender";
const char* EXTENDER_PASSWORD = "Extender123";
  • Replace YOUR_ROUTER_WIFI with the SSID of your existing WiFi router.
  • Replace YOUR_ROUTER_PASSWORD with your router's WiFi password.
  • Change ESP32_Extender if you want a different network name.
  • Change Extender123 to a password of your choice.
The extender password must be at least 8 characters for WPA2-PSK networks. Use a strong password and do not publish your real router credentials in screenshots, code examples or online repositories.

Step 6: Understand the ESP32 Network Configuration

Our extender will use a separate IP address range so that the new WiFi network does not conflict with the network provided by the original router.

cpp
IPAddress AP_IP(192, 168, 50, 1);
IPAddress AP_GATEWAY(192, 168, 50, 1);
IPAddress AP_SUBNET(255, 255, 255, 0);
IPAddress AP_LEASE_START(192, 168, 50, 2);
IPAddress AP_DNS(8, 8, 8, 8);
Network settingValuePurpose
AP IP192.168.50.1ESP32's local network address
Gateway192.168.50.1Gateway for connected devices
Subnet255.255.255.0Defines the local network range
DHCP lease start192.168.50.2Starting address for connected clients
DNS8.8.8.8Google public DNS server

The ESP32 will use 192.168.50.1 as its access point address. Devices joining ESP32_Extender will receive an IP address from the new network and use the ESP32 as their gateway.

If your original router already uses the 192.168.50.x subnet, choose a different subnet for the ESP32 access point to avoid network conflicts.

Step 7: Upload the ESP32 WiFi Extender Code

Once the Arduino IDE and ESP32 board package are installed and the correct board and COM port are selected, copy the following code into a new Arduino sketch.

cpp
#include <Arduino.h>
#include <WiFi.h>

// ===== Original router WiFi =====
const char* ROUTER_SSID     = "YOUR_ROUTER_WIFI";
const char* ROUTER_PASSWORD = "YOUR_ROUTER_PASSWORD";


// ===== ESP32 extended WiFi =====
const char* EXTENDER_SSID     = "ESP32_Extender";
const char* EXTENDER_PASSWORD = "Extender123";


// AP network configuration
IPAddress AP_IP(192, 168, 50, 1);
IPAddress AP_GATEWAY(192, 168, 50, 1);
IPAddress AP_SUBNET(255, 255, 255, 0);
IPAddress AP_LEASE_START(192, 168, 50, 2);
IPAddress AP_DNS(8, 8, 8, 8);

void onEvent(arduino_event_id_t event, arduino_event_info_t info)
{
    switch (event)
    {
        case ARDUINO_EVENT_WIFI_AP_START:
            Serial.println("Extender AP started");
            break;

        case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
            Serial.println("Client connected to ESP32");
            break;

        case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:
            Serial.println("Client disconnected");
            break;

        case ARDUINO_EVENT_WIFI_STA_CONNECTED:
            Serial.println("Connected to original router");
            break;

        case ARDUINO_EVENT_WIFI_STA_GOT_IP:
            Serial.println("\n===== Router Connection =====");
            Serial.print("ESP32 STA IP: ");
            Serial.println(WiFi.STA.localIP());

            Serial.print("Gateway: ");
            Serial.println(WiFi.STA.gatewayIP());

            Serial.println("Enabling NAT...");
            WiFi.AP.enableNAPT(true);
            Serial.println("NAT enabled!");
            break;

        case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
            Serial.println("Router connection lost. Reconnecting...");
            break;

        default:
            break;
    }
}


void setup()
{
    Serial.begin(115200);
    delay(1000);

    Serial.println("\nESP32 WiFi Repeater Starting...");

    // Register WiFi event handler
    Network.onEvent(onEvent);

    // Enable AP + Station mode
    WiFi.mode(WIFI_AP_STA);

    // Configure extender network
    WiFi.AP.begin();

    WiFi.AP.config(
        AP_IP,
        AP_GATEWAY,
        AP_SUBNET,
        AP_LEASE_START,
        AP_DNS
    );

    // Create Access Point
    bool apStarted = WiFi.AP.create(
        EXTENDER_SSID,
        EXTENDER_PASSWORD
    );

    if (!apStarted)
    {
        Serial.println("Failed to start ESP32 AP!");
        return;
    }

    Serial.println("ESP32 Access Point started");
    Serial.print("SSID: ");
    Serial.println(EXTENDER_SSID);

    Serial.print("AP IP: ");
    Serial.println(WiFi.AP.localIP());

    // Connect to the original router
    Serial.println("Connecting to original router...");

    WiFi.begin(
        ROUTER_SSID,
        ROUTER_PASSWORD
    );
}


void loop()
{
    delay(1000);

    if (WiFi.STA.status() == WL_CONNECTED)
    {
        // Router connection is active
    }
}

Step 8: Verify the Code and Upload

  • Replace the original router credentials in the sketch.
  • Connect your ESP32 to your PC using the USB cable.
  • Confirm the correct ESP32 board is selected.
  • Confirm the correct COM port is selected.
  • Click the Verify button (checkmark) to compile the sketch.
  • If compilation succeeds, click Upload.
  • Wait until Arduino IDE reports that the upload has completed.

If the ESP32 does not enter upload mode automatically, try holding the BOOT button when the upload process begins, then release it when the IDE starts connecting to the board. The exact procedure may vary by development board.

Step 9: Open the Serial Monitor

After uploading the code, open Tools > Serial Monitor. Set the baud rate in the Serial Monitor to 115200. If everything is working, the ESP32 will print startup messages, show that the access point has started and attempt to connect to your original router.

When the ESP32 successfully receives an IP address from the router, the sketch enables NAPT on its access point interface. You should see messages similar to the following.

text
ESP32 WiFi Repeater Starting...
Extender AP started
ESP32 Access Point started
SSID: ESP32_Extender
AP IP: 192.168.50.1
Connecting to original router...
Connected to original router
===== Router Connection =====
ESP32 STA IP: 192.168.x.x
Gateway: 192.168.x.x
Enabling NAT...
NAT enabled!
The router-assigned STA IP address and gateway will vary depending on your existing network. The example above is illustrative, not a guaranteed output.

Step 10: Connect Your Phone or Laptop to the ESP32 Extender

Now the ESP32 should broadcast its own WiFi network. Take your phone, laptop or another wireless device and scan for available networks.

  • Open WiFi settings on your phone or laptop.
  • Find ESP32_Extender in the available networks list.
  • Connect using the password Extender123, unless you changed it in the sketch.
  • Once connected, open a browser and visit a website.
  • Test internet access and see whether the device can load pages.

You can also check the connected device's network details. Its IP address should normally be in the 192.168.50.x range, and its gateway should be 192.168.50.1.

Step 11: Test the WiFi Range and Internet Speed

Simply connecting to ESP32_Extender does not prove that the extender is performing well. Test it in the location where your original router has a weak signal and compare the results.

  • Test the WiFi signal and internet speed near your original router.
  • Move to the location where the WiFi signal becomes weak and test again.
  • Place the ESP32 somewhere between the router and the weak-signal area, where it can still receive a reasonably strong signal.
  • Connect to ESP32_Extender and run the same speed test.
  • Compare download speed, upload speed, latency and signal strength.
  • Repeat the test at different ESP32 positions to find a better location.
TestOriginal WiFiESP32 Extender
Download speedRecord your resultRecord your result
Upload speedRecord your resultRecord your result
Ping/latencyRecord your resultRecord your result
Signal strengthRecord RSSIRecord RSSI
Use the same phone or laptop, test server and location for both tests where possible. Real measurements will make your article much more useful than claiming a specific speed without testing.

Why Does the ESP32 WiFi Extender Have Lower Speed?

The ESP32 uses a single WiFi radio for its connection to the original router and for its own access point. It must share radio airtime between receiving data from the upstream network and sending data to connected clients.

  • The ESP32 has limited processing and wireless capabilities compared with dedicated routers.
  • The same WiFi radio handles both the upstream and downstream wireless connections.
  • Wireless interference from neighboring routers can affect performance.
  • A weak upstream signal limits the internet connection available to extender clients.
  • Extra network routing can increase latency.

The ESP32 extender may be useful for experimenting, IoT devices or light browsing in an area with poor coverage. However, it may not be suitable for high-resolution streaming, online gaming, large downloads or connecting multiple demanding devices.

Troubleshooting Common Problems

ESP32 COM Port Is Not Appearing

  • Try a different USB cable that supports data transfer.
  • Try a different USB port on your PC.
  • Check whether the board uses a CH340 or CP210x USB-to-serial chip.
  • Install the appropriate driver if required.
  • Disconnect and reconnect the board, then check Tools > Port again.

Failed to Upload the Code

  • Confirm that the correct board is selected.
  • Confirm that the correct COM port is selected.
  • Lower the upload speed to 115200.
  • Close other applications that may be using the COM port.
  • Try holding the BOOT button during the upload connection stage if your board requires manual boot mode.

ESP32_Extender Appears but Has No Internet

  • Check that the original router SSID and password are correct.
  • Check the Serial Monitor for the router connection and IP address messages.
  • Confirm that the ESP32 has received an IP address from the original router.
  • Check that NAPT is enabled after the STA interface obtains its IP address.
  • Try connecting a single phone or laptop to the extender first.
  • Restart the ESP32 and check whether the original router connection is restored.
The current sketch prints 'Router connection lost. Reconnecting...' when it receives a disconnection event, but it does not explicitly call a reconnect function in that event. Automatic reconnection behavior may depend on the WiFi core version and settings. If it fails to reconnect, additional reconnect logic may be needed.

ESP32 WiFi Extender vs Commercial WiFi Extender

FeatureDIY ESP32Commercial Extender
CostPotentially under $5 for the boardHigher initial price
SetupRequires Arduino IDE and codeUsually guided setup
PerformanceLimited radio and processing resourcesDepends on model and radio design
CustomizationProgrammable and open for experimentationUsually limited
Best useLearning, experimentation, basic connectivityRegular home WiFi coverage

Can an ESP32 Really Replace a WiFi Extender?

An ESP32 can be configured to create another WiFi network and share an upstream connection using networking features such as NAPT. This makes it a useful DIY project for learning about wireless networking, routing and embedded programming.

However, it is not a direct replacement for a dedicated WiFi extender. Commercial devices often have better antennas, more capable radios, optimized firmware and support for handling multiple clients. The ESP32 is best considered an inexpensive experimental extender rather than a high-performance networking solution.

Conclusion

Building a DIY WiFi extender using an ESP32 is an interesting way to learn how wireless networking works without spending much money. With Arduino IDE, the ESP32 board package and a sketch that uses AP + STA mode with NAPT, you can create a new WiFi network and experiment with internet sharing.

If you already have an ESP32 board, this project costs almost nothing beyond the power and USB connection needed to run it. If you are buying one, compare local prices first to see whether you can stay within the $5 budget.

Try the project, measure its real performance and experiment with different placements. It is a fun electronics project that demonstrates how a tiny microcontroller can perform basic networking tasks.

ADVERTISEMENT
RA

rajkumar29000

Developer, creator and technology enthusiast sharing practical programming, Android, Unity and web development tutorials.