#include "ThingSpeak.h"
#include "WiFi.h"
const int LM35 = A4;
char ssid[] ="WOKWI-Guest";
char pass[] = "";
WifiClient client ;
unsigned long myChannelNumber = 2629473;
const int FieldNumber = 1;
const char* myWriteAPIKey = "M045ZN1BWC1O52XD";
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop()
{
// put your main code here, to run repeatedly:
if(WiFi.status()!= WL_CONNECTED)
{
Serial.print("Attemptig to connect to SSID : ");
Serial.println(ssid);
While(WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid,pass);
Serial.print(".");
delay(5000);
}
Serial.println("\n Connected. ");
}
int ADC ;
float temp;
ADC = analogRead(LM35);
temp = (ADC *3);
temp = (temp/10);
Serial.print("Temperature = ");
Serial.print(temp);
Serial.println("*C");
delay(1000);
ThingSpeak.writeField(myChannelNumber,FieldNumber,temp,myWriteAPIKey);
delay(1000);
}