ESP8266 Can’t Connect To WiFi? It’s Probably One Of These…

Published Categorized as Arduino, ESP Devices
ESP8266 How To Fix Connection Errors

If your ESP8266 based board is not connecting to WiFi, there are some specific things you can troubleshoot in order to get it to work. In this article we cover everything you need to fix the problem of ESP8266 not connecting to WiFi.

This article is suitable for anyone having trouble with their ESP8266 based board, meaning any board with an ESP8266 chip on board.

This could be one of the popular Wemos D1 Mini type boards. It could be an ESP-01 module or any other board that features the ESP-12 module.

Did You Set The ESP8266 With The Correct SSID And Password?

Ok we should start with the obvious. Yes I know, I know, we are all super-duper electronics experts, of course we didn’t do something as type an incorrect password… did we?

Is your SSID typed in EXACTLY as it needs to be?

Is your password typed in EXACTLY as it needs to be?

Go check again, yes again …and again, at least three times to be sure!

I have been caught out by this one several times, especially when setting up the ESP8266 to connect in the Arduino IDE.

#include <ESP8266WiFi.h>
 
// Set WiFi credentials
#define WIFI_SSID "YOUR WIFI NETWORK SSID"
#define WIFI_PASS "YOUR WIFI PASSWORD"
 
void setup() {
  // put your setup code here, to run once:
 
}
 
void loop() {
  // put your main code here, to run repeatedly:
 
}

If you are trying to set up an ESP8266 to connect to WiFi with Arduino, you should definitely check out my tutorial on how to do this, its very easy to follow and has simple yet detailed examples of code, check it out!

Are You Trying To Connect The ESP8266 To A Router Set To Channel 13 or 14?

There has been some discussion regarding channels 13 and 14, whereby users have been unable to connect an ESP8266.

I decided to look into this a little further and I found that Espressif published a WiFi selection guide for the ESP8266. Within this document, the following table is published:

This would seem to support some of the feedback given regarding channels 13 and 14. It seems channels 12 through to 14 are not legal for use in geographical regions governed by the FCC (the United States).

In any case the simple solution to this problem would be to ensure that your router is not set to these channels and make sure you operate on a channel that is known to work.

Most likely setting your router channel and bandwidth to the auto setting will solve this issue.

Are You Trying To Connect The ESP8266 To A 2.4GHz Access Point?

The ESP8266 only operates on the 2.4GHz band and it is not compatible with the 5.8GHz band.

You must ensure that the router you are trying to connect to has the 2.4GHz band enabled and that you are trying to connect to it.

Depending on the router, you may needs to set the router AP band to 2.4GHz.

Router, Wireless, Network, Connection, Computer

Is The ESP8266 Set Up In Station Mode?

There are two modes that the ESP8266 can operate in:

  1. Station mode
  2. AP mode

In station mode the ESP8266 is operating like a WiFi client and is able to connect to a WiFi access point, like your router.

In AP mode (access point mode) your ESP8266 is acting as the AP, so it IS the router.

If your ESP8266 is configured in AP mode, you will not be able to connect to the router, you must configure it in station mode.

Note that your ESP8266 may retain certain settings from previous projects. It is advisable to include the instruction to switch to station mode within the code to make sure the mode is correct.

For further information on how to set up the ESP8266 in station mode, check out this tutorial. It is also possible to get the ESP8266 to function in station mode and AP mode simultaneously!

Are You Trying To Read The Analog To Digital Converter?

Another problem that has been reported by several sources concerns the analog to digital converter (ADC) within the ESP8266.

The ADC has the capability to read the voltage applied to the amplifier and in this configuration the A0 (TOUT) pin must be left floating.

Although it is not clear from the datasheet, it is generally known that the analogRead() function can disrupt the WiFi signal if it is called very frequently.

The simple solution to the problem is to make sure that there is a delay in the code using the millis() function, such as in the following example taken from Stack Exchange.

unsigned int tempSensRead() {

  const unsigned long MEASURE_INTERVAL = 2L * 1000 * 60; // 2 minutes
  static unsigned long lastMeasureMillis;
  static unsigned int lastValue;

  if (millis() - lastMeasureMillis > MEASURE_INTERVAL) {
    lastMeasureMillis = millis();
    lastValue = analogRead(A0);
  }
  return lastValue;
}

Are You Trying To Connect ESP8266 To A WEP Key Network?

So you’re the oldskool type and want to connect to a network that requires a WEP key? …nothing wrong with that!

However you should be aware that in terms of security, WEP is about as useful as an ashtray on a motorbike. Therefore it is necessary to write into your code that you understand that you are being reckless.

In order to connect the ESP8266 to a network that requires a WEP key, you must first enable WEP with the following code before you begin the WiFi:

WiFi.enableInsecureWEP();

Conclusion

As we have seen in this article, there are a number of things that could be preventing the ESP8266 from connecting to WiFi. All of which are relatively easy to solve, once you understand what is happening.

If you are still having problems, I would recommend going back to the beginning and starting with this tutorial.

If you have two ESP8266 boards available you can also follow this tutorial which will teach you how to link them together with WiFi.

If you have another problem that is not listed here, I would be very interested to hear about it so I can consider adding it to this guide, just drop me an email. Thanks!