├── .gitignore ├── CNAME ├── LICENSE ├── README.md ├── advanced_router_settings.jpg └── esp8266-router.ino /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Config Files 35 | local-config.ino 36 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | esp8266-router.ahmetozer.org -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ahmet ÖZER 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Extend Wifi Range With ESP8266 (NodeMCU) 2 | 3 | This project goal is extending WiFi range with ESP8266. 4 | Currently It is only supports IPv4 . 5 | 6 | ## Configuration 7 | 8 | This system is requires Two way Configuration. 9 | One of them is your router other one is ESP8266 (NodeMCU). 10 | 11 | ### ESP8266 Side 12 | 13 | - Set your Home router WiFi SSID and password 14 | 15 | ```c++ 16 | const char* SSID = "ahmetozer.org"; 17 | const char* PASSWORD = "MyhomeNetworkPass"; 18 | ``` 19 | 20 | - Set your ESP Wifi name, password and channel 21 | 22 | ```c++ 23 | const char* SOFT_AP_SSID = "ahmet.engineer"; 24 | const char* SOFT_AP_PASSWORD = password; 25 | int Wifi_SoftAP_Channel = 11; 26 | ``` 27 | 28 | - Set your sub local network on ESP8266 29 | .**Note:** Each ESP use /29 block but requires /24 block. 30 | 31 | ```c++ 32 | IPAddress SOFT_AP_Local_IP(10,0,1,1); 33 | IPAddress SOFT_AP_Gateway(10,0,1,1); 34 | IPAddress SOFT_AP_Subnet(255,255,255,0); 35 | ``` 36 | 37 | ### Home Side 38 | 39 | 1. Firstly compile and flash firmware to your NodeMCU. 40 | 2. Bootup your ESP8266. 41 | 3. Find ESP8266 IPAddress on your router. 42 | 4. Go to Advanced Routing settings. 43 | 5. Add esp network to router. 44 | 45 | Advanced route setting for ESP8266 46 | 47 | ## Performance Tunings 48 | 49 | - Change channel 9,10 or 11 on your Router. 50 | - Select Same Wifi channel on your ESP8266. 51 | it is delegated with `Wifi_SoftAP_Channel` variable. 52 | - Change lwIP library version to "V2 IPv6 High Bandwidth" or "V2 High Bandwidth". 53 | 54 | ## Without Configuring Home Side - Update 55 | 56 | Nat is Disabled by default for better performance but if you don't have chance to edit route table on router or having issue, you can enable NAT on ESP8266. 57 | 58 | ```c++ 59 | #define NAT_Enabled true 60 | ``` 61 | 62 | **NOTE**: You have to select lwIP library version to "V2 High Bandwidth" for enabling nat. Other wise nat will not work. 63 | 64 | **Serial output is disabled by default. To enable set to true `SERIAL_Enabled true`** 65 | 66 | ## [Source Code - Github](https://github.com/ahmetozer/esp8266-router) | [BLOG](https://ahmetozer.org/ESP8266-Wifi-Range-Extender.html) 67 | -------------------------------------------------------------------------------- /advanced_router_settings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmetozer/esp8266-router/ac65a626f549b46c5af77bccb6a763313e23a473/advanced_router_settings.jpg -------------------------------------------------------------------------------- /esp8266-router.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #if LWIP_FEATURES 7 | 8 | #define SERIAL_Enabled false // To show details on serial 9 | // Write Your Router SSID which is your wifi name and your wifi PASSWORD. 10 | const char *SSID = "ahmetozer.org"; 11 | const char *PASSWORD = "12345678"; 12 | 13 | // Your ESP Wifi 14 | const char *SOFT_AP_SSID = "ahmet.engineer"; 15 | const char *SOFT_AP_PASSWORD = PASSWORD; // My preference is same as my home SSID PASSWORD. 16 | int SOFT_AP_Channel = 11; 17 | 18 | // ESP 8266 Local Network Configuration 19 | IPAddress SOFT_AP_Local_IP(10, 0, 1, 1); 20 | IPAddress SOFT_AP_Gateway(10, 0, 1, 1); 21 | IPAddress SOFT_AP_Subnet(255, 255, 255, 0); 22 | #define Copy_DNS_Settings true // if this is set to true 23 | // System copy connected modem dns settings to dns server, other wise set to Cloudflare Public DNS 24 | IPAddress SOFT_AP_DNS1(1, 1, 1, 1); 25 | IPAddress SOFT_AP_DNS2(1, 0, 0, 1); 26 | 27 | // Rename Your ESP name to find easily on your router 28 | const char *espHostname = SOFT_AP_SSID; // By default, hostname is AP SSID but if you want you can set by manual by replace SOFT_AP_SSID with "YourHostName"; 29 | 30 | #define NAT_Enabled false 31 | 32 | #if NAT_Enabled && !LWIP_IPV6 33 | #define NAPT 1000 34 | #define NAPT_PORT 10 35 | #include 36 | #endif 37 | 38 | void setup() 39 | { 40 | #if SERIAL_Enabled 41 | Serial.begin(115200); 42 | Serial.println(); 43 | Serial.println("\n\n\nStarting ..."); 44 | #endif 45 | WiFi.mode(WIFI_AP_STA); 46 | #if SERIAL_Enabled 47 | Serial.print("Connecting to "); 48 | Serial.println(SSID); 49 | #endif 50 | WiFi.begin(SSID, PASSWORD); 51 | while (WiFi.status() != WL_CONNECTED) 52 | { 53 | #if SERIAL_Enabled 54 | Serial.print("."); 55 | #endif 56 | delay(500); 57 | } 58 | WiFi.hostname(espHostname); 59 | #if Copy_DNS_Settings 60 | SOFT_AP_DNS1 = WiFi.dnsIP(0); 61 | SOFT_AP_DNS2 = WiFi.dnsIP(1); 62 | #endif 63 | 64 | dhcps_set_dns(0, SOFT_AP_DNS1); 65 | dhcps_set_dns(1, SOFT_AP_DNS2); 66 | 67 | WiFi.softAPConfig(SOFT_AP_Local_IP, SOFT_AP_Gateway, SOFT_AP_Subnet); 68 | WiFi.softAP(SOFT_AP_SSID, SOFT_AP_PASSWORD, SOFT_AP_Channel); 69 | #if SERIAL_Enabled 70 | // Wifi Client Part 71 | Serial.printf("\nConnected WiFi %s\n MAC addr: %s\nESP8266 client ip address: %s \nDNS adresses: %s , %s\n", 72 | SSID, WiFi.softAPmacAddress().c_str(), 73 | WiFi.localIP().toString().c_str(), 74 | WiFi.dnsIP(0).toString().c_str(), 75 | WiFi.dnsIP(1).toString().c_str()); 76 | // Wifi AP Part 77 | Serial.printf("Ap Info\nEsp AP IPAddress: %s \nDHCP Settings\nGateway: %s \nSubnet: %s\nDNS: %s - %s\n", 78 | WiFi.softAPIP().toString().c_str(), 79 | SOFT_AP_Gateway.toString().c_str(), 80 | SOFT_AP_Subnet.toString().c_str(), 81 | SOFT_AP_DNS1.toString().c_str(),SOFT_AP_DNS2.toString().c_str()); 82 | 83 | #endif 84 | 85 | #if NAT_Enabled && !LWIP_IPV6 86 | err_t nat_err = ip_napt_init(NAPT, NAPT_PORT); 87 | #if SERIAL_Enabled 88 | Serial.println("Initializing NAT"); 89 | #endif 90 | if (nat_err == ERR_OK) 91 | { 92 | nat_err = ip_napt_enable_no(SOFTAP_IF, 1); 93 | #if SERIAL_Enabled 94 | Serial.println("Enabling NAT on AP"); 95 | #endif 96 | if (nat_err == ERR_OK) 97 | { 98 | #if SERIAL_Enabled 99 | Serial.printf("Nat Is Enabled on '%s' \n", SOFT_AP_SSID); 100 | #endif 101 | } 102 | } 103 | 104 | if (nat_err != ERR_OK) 105 | { 106 | #if SERIAL_Enabled 107 | Serial.println("ERR: NAT is not initialized"); 108 | #endif 109 | } 110 | #elif NAT_Enabled 111 | Serial.println("ERR: NAT is not initialized"); 112 | Serial.println("\n\n\nPlease select LwIP Variant: v2 Higher Bandwidth or v2 Lower Memory"); 113 | #endif 114 | } 115 | 116 | #else 117 | void setup() 118 | { 119 | Serial.begin(115200); 120 | Serial.println(); 121 | Serial.println("\n\n\nPlease select LwIP Variant: v2 Higher Bandwidth or v2 Lower Memory"); 122 | } 123 | #endif 124 | 125 | void loop() 126 | { 127 | } 128 | --------------------------------------------------------------------------------