Xampp 拒绝与XMAPP localhost进行nodeMCU连接

Xampp 拒绝与XMAPP localhost进行nodeMCU连接,xampp,arduino-esp8266,Xampp,Arduino Esp8266,我的项目是使用来自传感器DHT11的nodeMCU测量值,并将值发送到数据库Mysql。我使用xampp作为服务器。我无法将值发送到数据库。 nodeMCU可以读取值和发送值。但HTTP GET失败。返回connect REJECTED。我想可能在监听端口方面有问题 这是我的密码 #include <Arduino.h> #include <ESP8266HTTPClient.h> #include <ESP8266WiFi.h> #include <E

我的项目是使用来自传感器DHT11的nodeMCU测量值,并将值发送到数据库Mysql。我使用xampp作为服务器。我无法将值发送到数据库。 nodeMCU可以读取值和发送值。但HTTP GET失败。返回connect REJECTED。我想可能在监听端口方面有问题

这是我的密码

#include <Arduino.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include "DHT.h"

#define DHTPIN 2 // what digital pin the DHT22 is conected to
#define DHTTYPE DHT11 // there are multiple kinds of DHT sensors

DHT dht(DHTPIN, DHTTYPE);
ESP8266WiFiMulti WiFiMulti;
const char* ssid = "something";
const char* password = "something";

int EP =5;

void setup() {

Serial.begin(115200);
pinMode(EP, INPUT);
for (uint8_t t = 4; t > 0; t--) {
Serial.printf("[SETUP] WAIT %d...\n", t);
Serial.flush();
delay(1000);
}
WiFiMulti.addAP(ssid, password); // ssid , password
randomSeed(50);
}

int timeSinceLastRead = 0;

void loop() {
if ((WiFiMulti.run() == WL_CONNECTED)) {
HTTPClient http;
float temp = dht.readTemperature();
float humi = dht.readHumidity();
long meas =TP_init();
Serial.println(WiFi.localIP());

//int temp = random(25,35);
String url = "localhost:8012/add2.php?temp="+String(temp)+"&humi="+String(humi)+"&meas=0";

Serial.println(url);
http.begin(url); //HTTP

int httpCode = http.GET();
if (httpCode > 0) {
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
delay(3000);
}

long TP_init(){
delay(10);
long meas=pulseIn (EP, HIGH); //wait for the pin to get HIGH and returns measurement
return meas;
}
#包括


这是串行端口造成的。

String url=“localhost
应替换为
String url=“
,因为Web服务器显然没有在ESP8266上运行。

您是否可以将此错误添加为问题的一部分,以便将来图像不再可用,我们仍然可以知道错误?谢谢!你认为localhost指向哪里?@c-preaw你还在坚持吗?