0

I can't figure out why, but my very simple wifi scan code doesn't work on two pieces of ESP-01. At first I thought, about bad or burn out MCU, but none of my two ESP-01 and can not find nearby wifi. I have tried it on NodeMCU... That's works. But on ESP-01 it doesn't work at all. No nearby wifi found.

This is my code

#include "ESP8266WiFi.h"
void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i)));
      delay(100);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

and output from Serial console is "scan done ... no networks found"

6
  • what is your question? – jsotola Oct 16 '20 at 15:25
  • reduce your code to minimum that still exhibits the problem – jsotola Oct 16 '20 at 15:28
  • I have reduce my code to simple wifi.scannetworks print out, no wifi found... Same code on NodeMCU work perfect – Sahasrar Oct 16 '20 at 16:07
  • 1
    clear the flash and then try again – Juraj Oct 16 '20 at 17:24
  • 1
    the IDE has 3 erase options. normally you don't want to erase the entire flash. but for one upload set All flash to erase old RF calibrations settings area values – Juraj Oct 16 '20 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.