0% found this document useful (0 votes)
13 views1 page

Io TDispaly Code

The document describes code for connecting an ESP8266 WiFi module to ThingSpeak to read string field data and display it on an LCD. The code connects to WiFi, initializes ThingSpeak and reads a string field, displaying any updates on the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Io TDispaly Code

The document describes code for connecting an ESP8266 WiFi module to ThingSpeak to read string field data and display it on an LCD. The code connects to WiFi, initializes ThingSpeak and reads a string field, displaying any updates on the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <ThingSpeak.

h>
#include <ESP8266WiFi.h>

WiFiClient client;
unsigned long counterChannelNumber = 1029806; // Channel ID
const char * myCounterReadAPIKey = "1YZAWOVHNTTYXVA3"; // Read API Key
const int FieldNumber1 = 1; // The field you wish
to read
String presentStr,previousStr = " ";

void setup()
{
lcd.begin(16, 2);
Serial.begin(115200);
Serial.println();

WiFi.begin("POCO PHONE", "9004652173"); // write wifi name &


password

Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
}

void loop()
{
presentStr = ThingSpeak.readStringField(counterChannelNumber, FieldNumber1,
myCounterReadAPIKey);
if(presentStr != previousStr)
{
lcd.clear();
Serial.println(presentStr);
lcd.setCursor(0, 0);
lcd.print(presentStr);
previousStr = presentStr;
}
}

You might also like