Соедините nodemcu с базой данных 000webhost - PullRequest
0 голосов
/ 19 марта 2020

Я хочу соединить nodemcu с базой данных 000webhost. Для этого я создал файл php в файловом менеджере моего сайта. всякий раз, когда я делаю http-запрос через веб-браузер, он работает должным образом. означает, что он выполняет свою функцию должным образом. но всякий раз, когда я пытаюсь сделать http-запрос через nodemcu, он не работает !!

мой код nodemcu:

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#define WIFI_SSID "imayank2"
#define WIFI_PASSWORD "123456789"


void setup() {

Serial.begin(74880);
  wifiConnect();

}

void loop()
{ 


 HTTPClient http;  //Declare an object of class HTTPClient

http.begin("mywebsite address\dataenter.php");  //Specify request destination
int httpCode = http.GET();                                                                  //Send the request

if (httpCode > 0) { //Check the returning code

String payload = http.getString();   //Get the request response payload
Serial.println(payload);                     //Print the response payload

}

http.end();   //Close connection



  delay(5000);

}


void wifiConnect()
{
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  Serial.println(" ...");
  int teller = 0;
  while (WiFi.status() != WL_CONNECTED)
  {                                       // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++teller);
    Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");  
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer
}

вывод: nothing only connected with my wifi , not payload

...