Y
Y
YuriyOlovets2021-05-11 22:07:53
Arduino
YuriyOlovets, 2021-05-11 22:07:53

Esp8266 does not send a GET request, what's the problem?

Please tell me what is the problem, esp is not sending a get request

<code lang="cpp">
#include <ESP8266WiFi.h>

const char* ssid = "";
const char* password = "";
const char* host = "smart-shelf.net";
// Create an instance of the server
// specify the port to listen on as an argument
//WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  // prepare LED
  //pinMode(LED_BUILTIN, OUTPUT);
 // digitalWrite(LED_BUILTIN, 0);
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print(F("Connecting to "));
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

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

  // Start the server
 // server.begin();
  //Serial.println(F("Server started"));

  // Print the IP address
  //Serial.println(WiFi.localIP());
}

void loop() {

WiFiClient client;
  if (client.connect(host, 80)){
    client.print("GET /test?");
    //client.print("test=1");
    client.println(" HTTP/1.1");
    client.print("Host:");
    client.println(host);
    client.println("Connection: close");
    client.println();
    client.println();
    delay(5000);
  }
  }
</code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-05-11
@fox_12

const char* host = "smart-shelf.net";
...
if (client.connect(host, 80)){
...

609ae18375969979676257.png
So, is the host you are connecting to a worker?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question