#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Familia Ramirez Rodriguez";
const char* password = "35354681julu";
const String thingSpeakReadURL = "https://api.thingspeak.com/channels/2744371/fields/1.json?api_key=UDDT4RKHJQJ20PUE&results=2";
void setup() {
Serial.begin(115200);
// Conectarse a Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Conectando a WiFi...");
}
Serial.println("Conectado a WiFi");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(thingSpeakReadURL);
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println("Respuesta de ThingSpeak:");
Serial.println(payload);
} else {
Serial.println("Error en la solicitud HTTP");
}
http.end();
delay(20000);