#include <WiFi.h>
#include "ThingSpeak.h"
const char* WIFI_NAME = "Wokwi-GUEST";
const char* WIFI_PASSWORD = "";
const int myChanne1Number = 2379415;
const char* myApikey = "TYKKWFKZ0JZJ2J4R";
const char* server = "api.thingspeak.com";
WiFiClient client;
void setup(){
Serial.begin(115200);
WiFi.begin(WIFI_NAME, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED){
delay(1000);
Serial.println("WiFi not connected");
}
Serial.println("WiFi connected!");
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop() {
float temperature = 20;
float humidity = 30;
ThingSpeak.setField(1, temperature);
ThingSpeak.setField(2, humidity);
int x = ThingSpeak.writeFields(myChanne1Number, myApiKey)
Serial.println("Temp: " + String(temperature) + "°C");
Serial.println("Humidity: " + String(humidity) + "%");
if (x == 200){
Serial.println("Data pushed successfully");
}else {
Serial.println("Push error: " + String(x));
}
Serial.println("---");
delay(15000);
}