Skip to main content

Node MCU Wifi connection problem

I'm trying to connect my nodeMCU to my WiFi network also i have provided ip address but it keeps printing ........ it is not connecting to the network. Below is my code.

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

// Configration Parameter for Access Poin
char * ssid_ap = ""; 
char * password_ap = "";
IPAddress ip(192, 168, 1, 158); 
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255,255,255,0);

// Set up the server object
ESP8266WebServer server (80);

// Keep track of sensor data that's going to be sent by the client
float sensor_value = 0.0;

void setup() 
{
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.softAP(ssid_ap,password_ap);

  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid_ap);

  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
 
  server.begin();
  Serial.println("Server started");
  Serial.print("IP Address:"); 
  // Serial.print(WiFi.localIP());
  // Configure Server Router
  server.on("/",handleIndex); // use the top root path to report the last sensor value
  server.on("/update",handleUpdate);
  // server.begin();
}

void loop() {
  // put your main code here, to run repeatedly:

}

void handleIndex()
{
  server.send(200,"text/plain",String(sensor_value)); //we'll need to refresh the page for getting the latest value
 
}

void handleUpdate()
{
 sensor_value = server.arg("value").toFloat(); 
 Serial.println(sensor_value);
 server.send(200,"text/plain","Updated");
  
}