#include <ThingSpeak.h>
#include <WiFi.h>
//Pin Details/
// WiFi Connection
const char ssid[] = "Wokwi-GUEST"; // your network SSID (name)
const char pass[] = ""; // your network password
WiFiClient client;
int a=45;
// Thingspeak settings
unsigned long channel = 1777605;
const char * apiKey = "4CBHJMFOXQ2JPTLS";
void setup() {
//* Define your pin details */
Serial.begin(115200);
Serial.println("Connecting...");
WiFi.begin(ssid,pass);
while(WiFi.status()!=WL_CONNECTED){
delay(5000);
Serial.print("..");
}
Serial.print("\n Wifi is Connected...");
ThingSpeak.begin(client);
}
void loop() {
//* Source code */
int x = ThingSpeak.writeField(channel,3,a,apiKey);
Serial.println(x);
if(x == 200){
Serial.println("Data is sucessfully Send it...");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
delay(200); // this speeds up the simulation
}