`Can’t I check if I can get the value of api from the serial monitor?
`#include <ESP8266WiFi.h>#include <ESP8266HTTPClient.h>
const char* ssid = "SKU_GUEST";const char* password = "";const char* serverAddress = "http://10.31.11.202:8080/api/receipt?orderId=68";
void setup() {Serial.begin(9600);WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(1000);Serial.println("Connecting to WiFi...");}Serial.println("WiFi connected");}
void loop(){if (WiFi.status() == WL_CONNECTED) {WiFiClient client; // WiFiClient 객체 생성HTTPClient http;http.begin(client,serverAddress);int httpCode = http.GET();if (httpCode > 0) {if (httpCode == HTTP_CODE_OK) {String payload = http.getString();// Output only the body (excluding headers)int bodyIndex = payload.indexOf("rnrn") + 4;String body = payload.substring(bodyIndex);Serial.println("Response body:");Serial.println(body);}} else {Serial.printf("HTTP GET failed, error: %sn", http.errorToString(httpCode).c_str());}http.end();}delay(5000); // Wait 5 seconds before making the next request}`
error message: User
. Variables and constants in RAM (global, static), used 28360 / 80192 bytes (35%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1508 initialized variables
╠══ RODATA 1092 constants
╚══ BSS 25760 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59747 / 65536 bytes (91%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 26979 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 255604 / 1048576 bytes (24%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 255604 code in flash
esptool.py v3.0
Serial port /dev/cu.usbmodem21201
Connecting……..…..…..…..…..…..….._____
A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header`
주형록 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1