乐鑫技术交流
直播中

周必镜

8年用户 984经验值
私信 关注
[问答]

为什么无法将数据从esp8266-arduino发送网站?

我正在尝试将数据从 esp8266-arduino 发送到我的网站,但不幸的是我不能
这是我的代码
#include
#include
#include ti.h>
#include >包括
#include
ESP8266WiFiMulti WiFiMulti;
String myURL = "http://alfa8400.000webhostapp.com/index.php?";
//
  String first = "alfa";
  String second = "vita";
void setup() {
  Serial.begin(115200);
  序列号.println();
  序列号.println();
  序列号.println();
  对于 (uint8_t t = 4; t > 0;

    序列号.flush();
    延迟(1000);
  }
  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP("用户名", "密码");
}
  if ((WiFiMulti.run() == WL_CONNECTED)) {
    WiFiClient 客户端;
    HTTP客户端http;
    Serial.print("[HTTP] 开始...n");
   如果 (http.begin(client, myURL+"first="+first+"&second="+second))
      Serial.print("[HTTP] GET...n");
      //
      http.begin(myURL); //
      int httpCode = http.GET();       //如果 (httpCode > 0) {         //         Serial.printf("[HTTP] GET... code: %d", httpCode); //
      httpCode 在出错时将为负数



                如果(httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY){
          String payload = http.getString();
          Serial.println(有效载荷);
        }
      } else {
        Serial.printf("[HTTP] GET...失败,错误:%s", http.errorToString(httpCode).c_str());
      }
      http.end();
    } else {
      Serial.printf("[HTTP} 无法连接");
    }
  }
  延迟(10000);

更多回帖

发帖
×
20
完善资料,
赚取积分