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