A
A
Alline2019-01-14 23:05:13
Arduino
Alline, 2019-01-14 23:05:13

Why won't esp8266 connect to network?

There is a wifi shield for arduino (esp-12). Connected to a laptop via usb-uart, without the arduino itself.
I want to send a get request from it. The code I'm uploading:

#include <ESP8266WiFi.h>

const char* ssid     = "xxx";
const char* password = "xxx";
const char* host = "xxx";
 
void setup() 
{
  Serial.begin(115200); 
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password); 
  delay(1000);
}

void loop()
{
  WiFiClient client;
  
  if (client.connect(host, 80)) {
    client.print( "GET /index.php?r=test%2Fadd");
    client.println( " HTTP/1.1");
    client.print( "Host:" );
    client.println(host);
    client.println( "Connection: close" );
    client.println();
    client.println();
  }
  
  Serial.println("---");
  delay(5000);
}

And silence, no requests fly away anywhere, client.connect = 0.
The module sees the network. WiFi.scanNetworks() returns reasonable values.
WiFi.status() is always WL_DISCONNECTED.
I can't figure out what's going on. Tell me, pliz, where to dig.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vanyamba-electronics, 2019-01-15
@vanyamba-electronics

Check out an example sketch here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question