//Tech Trends Shameer
//Read Data from Google SpreadSheet and display in LCD Display
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address
//Enter WIFI Credentials
const char * ssid = "Wifi Username"; // Enter your Wifi Username
const char * password = "Wifi Password"; // Enter your Wifi Password
String GOOGLE_SCRIPT_ID =
"AKfycbwl3Bh81XoOxNoEsBRlWhPU4zH2kzfm7QhkV2hlouigWhn4E46b";
//---------------------------------------------------------------------
const int sendInterval = 50;
String message = "Welcome";
int x;
int len=0;
int k=0;
WiFiClientSecure client;
void setup()
{
[Link](9600);
[Link]();
delay(10);
//--------------------------------------------
[Link](WIFI_STA);
[Link](ssid, password);
[Link]("Connecting to Wi-Fi");
while ([Link]() != WL_CONNECTED)
{
[Link]();
[Link]("Waiting for Wifi");
delay(500);
[Link](".");
}
[Link]();
[Link]();
[Link]("Wifi Connected");
[Link]("OK");
//--------------------------------------------
}
void loop()
{
int inc =0;
if(k==0)
read_google_sheet();
len =[Link]();
for (int a=15; a>=-len;a--)
{
[Link]();
[Link]();
[Link]("Smart Display");
if(a>=0)
{
[Link](a,1);
[Link]([Link](0,15));
}
else
{
inc++;
[Link](0,1);
[Link]([Link](inc,len));
}
delay(400);
}
k++;
if(k>2)
k=0;
}
void read_google_sheet(void)
{
//------------------------------------------------------------------------------
-----
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
client->setInsecure();
HTTPClient https;
String url="[Link]
[Link]("Reading Data From Google Sheet.....");
[Link](*client, url.c_str());
//------------------------------------------------------------------------------
-----
//Removes the error "302 Moved Temporarily Error"
[Link](HTTPC_STRICT_FOLLOW_REDIRECTS);
//------------------------------------------------------------------------------
-----
//Get the returning HTTP status code
int httpCode = [Link]();
[Link]("HTTP Status Code: ");
[Link](httpCode);
//------------------------------------------------------------------------------
-----
if(httpCode <= 0){[Link]("Error on HTTP request"); [Link](); return;}
//------------------------------------------------------------------------------
-----
//reading data comming from Google Sheet
String payload = [Link]();
[Link]("Payload: "+payload);
//------------------------------------------------------------------------------
-----
if(httpCode == 200)
message= payload;
//------------------------------------------------------------------------------
-------
[Link]();
}