My esp8266 is not searching for networks

I own esp8266 with usb converter. I prepared the converter according to the manual. Checked for firmware update. Went through the forums with various troubleshooting tips and still the following situations occur. I insert two codes that upload to esp without any problem, but they write similar outputs.

// ESP8266 Thingspeak ukázka

// připojení potřebné knihovny
#include <ESP8266WiFi.h>
 
// vytvoření proměnné s naším API klíčem z Thingspeak - viz návod
String apiKlic = "xxx";
// vytvoření proměnných s názvem WiFi sítě a heslem
const char* nazevWifi = "xxx";
const char* hesloWifi = "xxx";
// vytvoření proměnné s názvem serveru Thingspeaku
const char* server = "api.thingspeak.com";
// inicializace WiFi v módu klienta
WiFiClient client;
 
void setup() {
  // zahájení komunikace po sériové lince
  Serial.begin(115200);
  // zahájení bezdrátové WiFi komunikace s připojením
  // na router skrze zadané přihl. údaje
  WiFi.mode(WIFI_STA);

  WiFi.begin(nazevWifi, hesloWifi);
 // WiFi.setCountry("EU");  // Změň na správný region, například "US" nebo "EU"

  // čekání na úspěšné připojení k routeru,
  // v průběhu čekání se vytiskne každých
  // 500 milisekund tečka po sériové lince
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Pripojeno k WiFi siti ");
  Serial.println(nazevWifi);
  Serial.print("IP adresa: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  // vytvoření proměnných pro načtení hodnoty analogového
  // pinu a času od spuštění Arduina
  int cas = millis()/1000;
  int analog = analogRead(A0);
  // připojení na server Thingspeak pro odeslání dat
  if (client.connect(server,80)) {
    // vytvoření zprávy, která bude odeslána na Thingspeak
    // každé pole je označeno jako "field" + pořadí pole,
    // je nutné každý údaj převést na String
    String zprava = apiKlic;
    zprava +="&field1=";
    zprava += String(cas);
    zprava +="&field2=";
    zprava += String(analog);
    zprava += "\r\n\r\n";
    // po vytvoření celé zprávy ji odešleme na server Thingspeak
    // včetně našeho API klíče
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: "+apiKlic+"\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(zprava.length());
    client.print("\n\n");
    client.print(zprava);
    // vytištění informací po sériové lince o odeslání na Thingspeak
    Serial.print("Cas od spusteni Arduina: ");
    Serial.print(cas);
    Serial.print(" vterin a analogovy pin A0: "); 
    Serial.println(analog);
    Serial.println("Udaje odeslany na Thingspeak.");
  }
  // ukončení spojení se serverem Thingspeak
  client.stop();
  // nyní musíme vyčkat minimálně 15 vteřin do dalšího odeslání dat,
  // 15 vteřin je omezení Thingspeaku, v tomto příkladu je nastaven
  // interval 30 vteřin
  Serial.println("Pauza pred dalsim odeslanim dat.");
  delay(30000);
}

no WiFi found, reconnecting....

I tried using a different network scan code, it uploaded successfully again, unfortunately it says the following.

#include "ESP8266WiFi.h"

void setup()
{
  Serial.begin(115200);
  Serial.println();

  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
}

void loop()
{
  Serial.print("Scan start ... ");
  int n = WiFi.scanNetworks();
  Serial.print(n);
  Serial.println(" network(s) found");
  for (int i = 0; i < n; i++)
  {
    Serial.println(WiFi.SSID(i));
  }
  Serial.println();

  delay(5000);
}

Scan start ... scandone
0 network(s) found

I'm getting desperate, please help in this way. Thank you

Your code seems to have all important details.

Anyway give this code a try

// Demo-Code connect an ESP8266 to a WiFi-network using stationmode STA

// stationmode is simply join the WiFi-network as your computer or smartphone does it
// the code has three useful functions one for easy identifiying the code in the flash
// one for non-blocking timing
// a heartbeat-blinker function for indicating the state the code is in

// if the code is unable to connect to a WiFi the code wil Scan for available WiFis
// and print a list of all found WiFis and theier signal strength
// the SSIDs start with a "#" and end with a "#"
// which means the characters inbetween the "#" signs show the complete name
// example #my SSID -# which has a SPACE inside the SSID and a minus-sign
// which might be overlooked without the embracing "#"

// the code is written with two programming rules:
// 1. put EACH functionality into its OWN function
// 2. give EACH function a SELF-explaining name what the function does
// you should follow these programming rules

#if defined(ESP32)
#include <WiFi.h>
char deviceType[] = " ESP32";
#else
#include <ESP8266WiFi.h>
char deviceType[] = " ESP8266";
#endif

const char *ssid     = "Android AP";
const char *password = "12345678";


void PrintFileNameDateTime() {
  Serial.println( F("Code running comes from file ") );
  Serial.println( F(__FILE__));
  Serial.print( F("  compiled ") );
  Serial.print(F(__DATE__));
  Serial.print( F(" ") );
  Serial.println(F(__TIME__));
  Serial.print("Code runs on device-type");
  Serial.println(deviceType);
}



boolean TimePeriodIsOver (unsigned long &periodStartTime, unsigned long TimePeriod) {
  unsigned long currentMillis  = millis();
  if ( currentMillis - periodStartTime >= TimePeriod )
  {
    periodStartTime = currentMillis; // set new expireTime
    return true;                // more time than TimePeriod) has elapsed since last time if-condition was true
  }
  else return false;            // not expired
}

unsigned long MyTestTimer = 0;                   // variables MUST be of type unsigned long
const byte    OnBoard_LED = 2;


void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
  static unsigned long MyBlinkTimer;
  pinMode(IO_Pin, OUTPUT);

  if ( TimePeriodIsOver(MyBlinkTimer, BlinkPeriod) ) {
    digitalWrite(IO_Pin, !digitalRead(IO_Pin) );
  }
}


void ScanForWiFis() {
  WiFi.disconnect(); // disconnect from WiFi to enable promiscuitive WiFi-mode
  Serial.println("WiFi.disconnect(); done wait 1 second");
  delay(1000);

  Serial.println("start scanning for WiFi...");
  int numberOfNetworks = WiFi.scanNetworks();
  Serial.println("scanning finished");
  Serial.print("number of networks: ");
  Serial.println(numberOfNetworks);

  for (int i = 0; i < numberOfNetworks; i++) {

    Serial.print("Network name: #");
    Serial.print(WiFi.SSID(i));
    Serial.print("# Signal strength: ");
    Serial.println(WiFi.RSSI(i));
    Serial.println("---------------------- -");
  }
}


void ConnectToWiFi() {
  const byte maxCount = 60;

  WiFi.mode(WIFI_STA);
  Serial.println("set WiFi.mode(WIFI_STA) done");

  int myCount = 0;

  Serial.println("trying to connect to SSID ");
  Serial.print("#");
  Serial.print(ssid);
  Serial.print("#");
  Serial.print(" with password #");
  Serial.print(password);
  Serial.println("#");
  Serial.print("for ");
  Serial.print(maxCount / 2);
  Serial.println(" seconds");

  WiFi.begin(ssid, password);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED && myCount < maxCount) {
    BlinkHeartBeatLED(OnBoard_LED, 50); // blink LED fast during attempt to connect
    yield();
    if ( TimePeriodIsOver(MyTestTimer, 500) ) { // once every 500 miliseconds
      Serial.print(".");                        // print a dot
      myCount++;
    }

    if (myCount >= maxCount) { // after 60 dots = 30 seconds restart
      Serial.println();
      Serial.println("trying to connect to WiFi with SSID");
      Serial.print("#");
      Serial.print(ssid);
      Serial.println("# failed.");
      Serial.println("Are you sure that the SSID ");
      Serial.print("#");
      Serial.print(ssid);
      Serial.print("#");
      Serial.print(" with password ");
      Serial.print("#");
      Serial.print(password);
      Serial.println("#");
      Serial.println("are correct ? ");

      ScanForWiFis();
    }
  }

  if (WiFi.status() == WL_CONNECTED ) {
    Serial.println("");
    Serial.print("Connected to #");
    Serial.print(ssid);
    Serial.print("# IP address: ");
    Serial.println(WiFi.localIP());
  }
}

void setup() {
  delay(2000);
  Serial.begin(115200);
  while (!Serial);
  delay(2000);
  Serial.println( F("Setup-Start") );
  PrintFileNameDateTime();
  ConnectToWiFi();
}


void PrintHelloMsg() {
  Serial.print( F("Hi there I'm the demo-code my IP address is: ") );
  Serial.println(WiFi.localIP());
}


void loop() {
  BlinkHeartBeatLED(OnBoard_LED, 500); // change blinking to a lower frequency indicating beeing connected

  if ( TimePeriodIsOver(MyTestTimer, 1000) ) {
    if (WiFi.status() == WL_CONNECTED ) {
      PrintHelloMsg();
    }
    else {
      // Serial.println("not connected to WiFi");
    }
  }
}


/*
  most ESP8266 boards have a blue LED connected to GPIO-pin 2
  This blue LED is used to indicate state connecting to WiFi by blinking fast
  state beeing connected to Wifi by blinking with 1 Hz

  If the WiFi-connection is successfully established the serial monitor shows

  08:44:02.915 -> Setup-Start
  08:44:02.915 -> Code running comes from file
  08:44:02.915 -> your-path\yourfilename.ino
  08:44:02.915 ->   compiled date/time of compiling
  08:44:02.971 -> WiFi.mode(WIFI_STA)
  08:44:02.971 -> trying to connect to #Your SSID#
  08:44:03.362 -> ....
  08:44:04.215 -> Connected to #Your SSID# IP address: given IP-adress NNN.NNN.NNN.NNN
  08:44:04.865 -> Hi there I'm the demo-code my IP address is: NNN.NNN.NNN.NNN
*/

best regards Stefan

Hi Stefan, thank you for your response....i just tried that and you can see the result below.

10:00:37.853 -> reconnect
10:00:38.073 -> .
10:00:38.073 -> trying to connect to WiFi with SSID
10:00:38.073 -> #xxx# failed.
10:00:38.073 -> Are you sure that the SSID
10:00:38.073 -> #xxx# with password #xxx#
10:00:38.073 -> are correct ?
10:00:38.073 -> scandone
10:00:38.073 -> WiFi.disconnect(); done wait 1 second
10:00:39.593 -> start scanning for WiFi...
10:00:42.927 -> scandone
10:00:42.927 -> scanning finished
10:00:42.927 -> number of networks: 0

Do you have any ideas? Thx
L.

I moved your topic to a more appropriate forum category @lulaskovicz89.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

Can you show us a picture of the unit and/or a link to where you got it from ?

allways start with examples from the IDE Examples / Core.
In this case the example can be found in
ESP8266WiFi / WiFiScan

before you run the test, check that your wifi router doesn't hide the SSID (lot of router have a setting in the admin console).
Additionally span a Hotspot with your smartphone.

Now run the IDE Example again.

Do you see any WIFI?

Yes, the pictures are below...

i bought it at Internet věcí je tady! TCP/IP WIFI ESP8266 | drotik-elektro.sk as well as the adapter usb adapter...


I additionally tested the WiFiScan source code....


screenshot from router...

yes, I tried testing on a mobile hotspot as well

same like i didn't see any other WiFi which are in the vicinity

sorry out of ideas.
Try another module. I propose a NodeMCU oder Wemos D1.

Ah the ESP-01, and the wire between GND & GPIO enables the upload, but if you power it up again it will be in flash mode, so you can only run the sketch just after uploading like this.

Anyway, shouldn't matter, networks should show up, possibly a faulty unit, i can not see anything else that may cause your issue unless the unit is under powered. Try and add a 100uF capacitor between GND & Vcc.

if I run File>Examples>ESP8266WiFi>WiFiScan.ino on an ESP-01 I get

SP8266 WiFi scan example
Starting WiFi scan...
3 networks found:
  00: [CH 01] [CE:XXXXXXXXXXXX] -66dBm * V 802.11b/g/n     TEG-xxxx
  01: [CH 01] [A4:XXXXXXXXXXXX] -50dBm * V 802.11b/g/n WPS horacexxxx
  02: [CH 01] [24:XXXXXXXXXXXX] -90dBm * V 802.11b/g/n WPS SKYxxxxx

for programming/running ESP-01 I find the ESP-01 Helper V3 useful - no switching wires etc and a clone connector to attach sensors etc

Another idea is to set the debugport to serial
and to actiavte debug-level WiFi

maybe this gives some new information what is going on

Thank you so much guys...i f**k it all...I just set up upload by stefanL38 picture - except for the Reset Method, the module does not want to connect to me at dtr...look for this

thank you once again

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.