Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
arduino到ESP8266获取httpclient问题_Arduino_Httpclient_Esp8266 - Fatal编程技术网

arduino到ESP8266获取httpclient问题

arduino到ESP8266获取httpclient问题,arduino,httpclient,esp8266,Arduino,Httpclient,Esp8266,我在ArduinoIDE中使用了lib,但在monitor中并没有有效的响应,所以它不能正常工作!这是非常简单的代码: #include <SoftwareSerial.h> #include <Bridge.h> #include <HttpClient.h> #define RX 10 #define TX 11 String AP = "SSID"; String PASS = "password"; SoftwareSerial esp8266(

我在ArduinoIDE中使用了lib,但在monitor中并没有有效的响应,所以它不能正常工作!这是非常简单的代码:

#include <SoftwareSerial.h>
#include <Bridge.h>
#include <HttpClient.h>

#define RX 10
#define TX 11

String AP = "SSID";
String PASS = "password";

SoftwareSerial esp8266(RX,TX);

void setup() {
  Serial.begin(9600);
//  Serial.println("Serial init");
  esp8266.begin(115200);

  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop() {
  HttpClient client;
  client.get("http://server-address/led.txt"); // just 1 or 0

  while (client.available()) {
    char led = client.read();
//    Serial.println("=> "+led);

    if(led == '1') {
      digitalWrite(13, LOW);
    } else {
      digitalWrite(13, HIGH);
    }

    delay(1500);

  }

  Serial.flush();
  delay(1500);
}
#包括
#包括
#包括
#定义RX 10
#定义TX 11
字符串AP=“SSID”;
字符串PASS=“password”;
软件串行esp8266(接收、发送);
无效设置(){
Serial.begin(9600);
//Serial.println(“Serial init”);
esp8266.开始(115200);
pinMode(13,输出);
数字写入(13,低);
}
void循环(){
HttpClient;
client.get(“http://server-address/led.txt“”;//只有1或0
while(client.available()){
char-led=client.read();
//串行打印项次(“=>”+led);
如果(发光二极管='1'){
数字写入(13,低);
}否则{
数字写入(13,高);
}
延迟(1500);
}
Serial.flush();
延迟(1500);
}
我使用的示例

形象


工具:arduino uno、esp8266、试验板、一个led

使用ESP8266Webserver.h库尝试您的代码您还可以从

Bridge-library的什么用途中查看代码示例?计划与arduino Yuún合作,与32u4和AR9331通信,并使用硬件串行(arduino中的Serial1类)。您缺少所有告诉ESP8266您想做什么的AT命令,示例可在您发布的链接中找到。如果不先连接到网络,则无法发出HTTP GET请求。