我在Arduino IDE中使用httpclient lib,但是监视器中没有有效的响应,因此效果不佳!这是非常简单的代码:
#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);
}
我使用link
的示例示例图片link
工具:arduino uno,esp8266,面包板,一个led