На одной esp8266 крутится созданная из flprog web-страница с данными. (блок web-page)
Другая esp8266 с помощью блока web-client должна забирать данные со страницы. Путем GET запроса. (GET / HTTP1.1)
Но данные так и не появляются))
Причем если залить любой сторонний пример скетча web-client - то все данные прекрасно забираются со страницы! Т.е. сам web-сервер работает.
Не работает именно блок web-client.
/////////////////////////////////////////////////
web-page
СпойлерПоказать
СпойлерПоказать
СпойлерПоказать
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
/* Set these to your desired credentials. */
const char *ssid = "GavigorWiFi-2.4"; //ENTER YOUR WIFI SETTINGS
const char *password = "24061984";
//Web/Server address to read/write from
const char *host = "192.168.138.20"; //https://circuits4you.com website or IP address of server
//=======================================================================
// Power on setup
//=======================================================================
void setup() {
Serial.begin(9600);
WiFi.mode(WIFI_STA); //This line hides the viewing of ESP as wifi hotspot
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
Serial.print("Connecting");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
//=======================================================================
// Main Program Loop
//=======================================================================
void loop() {
HTTPClient http; //Declare object of class HTTPClient
String Link;
Link = "http://192.168.138.20/";
http.begin(Link); //Specify request destination
int httpCode = http.GET(); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
delay(5000); //GET Data at every 5 seconds
}
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
/* Set these to your desired credentials. */
const char *ssid = "GavigorWiFi-2.4"; //ENTER YOUR WIFI SETTINGS
const char *password = "24061984";
//Web/Server address to read/write from
const char *host = "192.168.138.20"; //https://circuits4you.com website or IP address of server
//=======================================================================
// Power on setup
//=======================================================================
void setup() {
Serial.begin(9600);
WiFi.mode(WIFI_STA); //This line hides the viewing of ESP as wifi hotspot
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
Serial.print("Connecting");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
//=======================================================================
// Main Program Loop
//=======================================================================
void loop() {
HTTPClient http; //Declare object of class HTTPClient
String Link;
Link = "http://192.168.138.20/";
http.begin(Link); //Specify request destination
int httpCode = http.GET(); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
delay(5000); //GET Data at every 5 seconds
}