0
我一直试图在我的ESP8266上获取天气信息以在OLED显示屏上显示它们。ESP8266 Arduino IDE JSON HTTP请求
if (!client.connect("api.apixu.com", 80)) {
Serial.println("connection failed");
return;}
client.print("GET " + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Content-Type: application/json\r\n" +
"Connection: close\r\n\r\n");
char c[1024];
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
c[0] = client.read();Serial.print(c);}
这是我的代码,用于请求和阅读JSON内容。但无论我尝试,代码都不会进入while循环。
有人能发现错误吗?
预先感谢您! :d