Answer the question
In order to leave comments, you need to log in
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
const char* host = "smart-shelf.net";
...
if (client.connect(host, 80)){
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question