#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "TELCO_EFRAIN";
const char* password = "MecDan18";
const char* serverUrl = "http://192.168.101.8:3000/api/wit-response"; // Cambia <IP_DEL_SERVIDOR> por la IP del servidor Angular
void setup() {
Serial.begin(115200);
// Conectar a WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Conectando a WiFi...");
}
Serial.println("Conectado a la red WiFi");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(serverUrl);
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
String response = http.getString(); // Lee la respuesta como una cadena de texto
Serial.println("Respuesta del servidor:");
Serial.println(response);
// Aquí puedes procesar la respuesta según necesites
} else {
Serial.println("Error al hacer la solicitud HTTP");
}
http.end();
}
delay(10000); // Espera 10 segundos antes de la siguiente solicitud
}