为了账号安全,请及时绑定邮箱和手机立即绑定

Nodemcu 不响应 http GET 请求

Nodemcu 不响应 http GET 请求

PHP
喵喵时光机 2021-10-15 10:10:48
我想从我的 nodemcu 向本地主机服务器发送 HTTP GET 请求。nodemcu 和我的笔记本电脑都连接到同一个 Wifi 网络。虽然 nodemcu 连接到网络,但它不会发送请求。我尝试手动发送请求并使用“邮递员”,然后就可以了。所以我认为问题出在 nodemcu 代码或设备上。欢迎任何想法。#include <ESP8266WiFi.h>#include <WiFiClient.h> #include <ESP8266WebServer.h>#include <ESP8266HTTPClient.h>/* Set these to your desired credentials. */const char *ssid = "******";  //ENTER YOUR WIFI SETTINGSconst char *password = "****";//Web/Server address to read/write from //website or IP address of server//=======================================================================//                    Power on setup//=======================================================================void setup() {  delay(1000);  Serial.begin(115200);  WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)  delay(1000);  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(".");  }  //If connection successful show IP address in serial monitor  Serial.println("");  Serial.print("Connected to ");  Serial.println(ssid);  Serial.print("IP address: ");  Serial.println(WiFi.localIP());  //IP address assigned to your ESP}//=======================================================================//                    Main Program Loop//=======================================================================void loop() {  HTTPClient http;    //Declare object of class HTTPClient  String ADCData, station, getData, Link;  int adcvalue=253;  //Read Analog value of LDR  ADCData = String(adcvalue);   //String to interger conversion  station = "B";
查看完整描述

2 回答

?
POPMUISE

TA贡献1765条经验 获得超5个赞

localhost 是“自我”的简写。您告诉 NodeMCU 将请求发送给它自己,尽管它甚至可能不理解 localhost。您需要使用您尝试向其发送请求的计算机的实际名称或 IP 地址。Localhost 永远不会像您在此处尝试使用它的方式工作(从一台计算机向另一台计算机发送请求)。


查看完整回答
反对 回复 2021-10-15
?
慕工程0101907

TA贡献1887条经验 获得超5个赞

试试这个:


<?php 


echo "<pre>";

print_r($_REQUEST);


?>


查看完整回答
反对 回复 2021-10-15
  • 2 回答
  • 0 关注
  • 218 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信