-->
Page 1 of 1

Strange data appear when I using scanComplete() function

PostPosted: Fri Jun 09, 2017 10:09 pm
by linh.truc.esp
This is example code

Code: Select all/*
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is almost the same as with the WiFi Shield library,
 *  the most obvious difference being the different file you need to include:
 */
#include "ESP8266WiFi.h"

void setup() {
 
  Serial.begin(115200);
  Serial.println();
  // 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
  WiFi.scanNetworks(true, false);
  int n = 0;
  n = WiFi.scanComplete();
  while(n == -1);
    {
    } //Waiting for scan complete.
  Serial.println("scan done");
  Serial.println(n);
  delay(1000);
}


After upload, the Monitor show this:
Image
and nothing happen after that.

When I press reset button on board, the Monitor show thí repeatly.
Image


I don't know what actually the data on Monitor is, and as I know that setup() function just run 1 time, but in this case, it does repeatly.

I really need a solution !!
Thanks you guys!!