Connecting wifi module esp8266 01 into wifi

#include <String.h>

#include <SoftwareSerial.h>
SoftwareSerial esp(2,3);// RX, TX
//declaration of post script path
String uri_short = "/auto/receiver1.php?data=1";
String uri;
String ip = "192.168.137.80";
String ssid ="NUIXHEXA";
String password="1234567809";

void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT);
pinMode(3, OUTPUT);
esp.begin(9600);
Serial.begin(9600);
//connnect to internet
connectWifi();

}

void connectWifi() {

Serial.println("Trying to connect");
esp.println("AT+CWMODE=3");
delay(100);
String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";
esp.println(cmd);
esp.println("AT");
String inData = esp.readStringUntil('\r');
Serial.println("Got reponse from ESP8266: " + inData);

delay(4000);
if(esp.find("OK")){Serial.println("Connected!");}
else {Serial.println("Cannot connect to wifi");}

}

//===========================send data through post method============================
void httppost (String ip) {
String data;
//ip adress of the computer
//String ip = "192.168.137.80";
Serial.println("Starting Conn");
esp.println("AT+CIPSTART="TCP","" + ip + "",80");//start a TCP connection.

if( esp.find("OK")) {
Serial.println("TCP connection ready");
}
delay(2000);

String postRequest =

"POST " + uri +
" HTTP/1.0\r\n" +

"Host: " + ip + "\r\n" +
"Accept: " + "/" + "\r\n" +

"Content-Length: " + data.length() + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of characters to be sent.
esp.print(sendCmd);
esp.println(postRequest.length() );

delay(500);

if(esp.find(">")) {
Serial.println("Sending..");
esp.print(postRequest);

if( esp.find("SEND OK")) {
  Serial.println("Packet sent");    
while (esp.available()) {  
  String tmpResp = esp.readString();
  Serial.println("tmpResp=");    
  Serial.println(tmpResp);  
  }  
esp.println("AT+CIPCLOSE"); // close the connection  
}

}
}

void loop() {
// put your main code here, to run repeatedly:
// uri = uri_short + "&arrival="+ 1;
Serial.println(uri);
httppost ("192.168.137.80");

delay (2000);
}

i get the following error in serial monitor , kind help

Trying to connect
Got reponse from ESP8266:
Cannot connect to wifi

Starting Conn

Starting Conn

help me out its now two weeks when am stack her

Welcome to the forum.

Please post a link to the site where you got the code you started with.

Are you using identical hardware? If not. Please say what you are using in its stead.

a7

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

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