IoT DISPLAY

 





/* ********** THE CODE BEGINS HERE ************************ */

#include <ThingSpeak.h>               // add library

#include <ESP8266WiFi.h>


#include <LiquidCrystal.h>

const int RS = D2, EN = D3, d4 = D4, d5 = D5, d6 = D6, d7 = D7;

LiquidCrystal lcd(RS, EN, d4, d5, d6, d7);


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("WIFI_SSID", "WIFI_PASS");                 // write your  personal 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;

 }

}

/* ******************CODE END *********************** */


Comments

Popular posts from this blog

IDE SETUP FILES

NON-SERVER CONTROLLER

Print String on 16X2 LCD