World’s Live COVID19 Dashboard Using Esp8266 and OLED

Introduction :

Everywhere there’s a huge outbreak of the Novel Corona Virus (COVID19). It became necessary to keep a watch on the current scenario of COVID-19 in the World.

So, being at home, this was the project I thought of  “World’s Live Covid19 Dashboard” – A Dashboard that provides realtime updates about the COVID-19 state of world. No more need to keep the TV on or keep watching at various websites.

The design of the project was not the important part. But making something useful, using the components that were handy was the challenge. This project will surely help you build a simple dashboard interface to keep you updated.

Components :

  • ESP8266
  • OLED Display
  • Jumper Cables

Schematics :

OLEDESP8266
  
GNDGND
VCC3V3
SCLD1 (GPIO5)
SDAD2 (GPIO4)

Setting Up :

  1. Visit the Realtime Covid19 Dashboard’s Website. Here I am Using https://trackcorona.live .
  2. Login/Sign Up to https://thingspeak.com .
  3. Go to App and Create new ThingHttp Action.
  • Give the Name of Your Choice, URL ( https://trackcorona.live ), Method as GET and  in Parse String, you need to paste the XPath from the trackcorna.live website of the required field you need to show.

In Above Example, I am Parsing String For Confirmed Cases, what all you need to do is

  • Right Click on Number of Confirmed Cases > Inspect,
  • Again Right Click in the Code > Copy > CopyXPath
  • Paste This in Parse String field of ThinkHttp Action and Save It.
  • Similarly, do this for all Recovered, Death, Fatality Rate and Death Rate.
  • Visit the Source Code and Replace SSID with your Wifi Name, Password with Your Wifi Password and API key with your ThingHttp API.
  • Upload The Code. That’s it!!

Source Code :

Note :

  • Remove Tx / Rx Pins of Arduino while Uploading the Code.
  • Install the Required Library.
/*
      © Techtronic Harsh

    Youtube : http://bit.ly/33kxOOQ
    Instructables : https://www.instructables.com/member/...
    Instagram : https://instagram.com/techtronicharsh
    Website : http://techtronicharsh.com
    Telegram : https://t.me/techtronicharsh

*/
#include <ESP8266WiFi.h>        //Use ESP8266 functions                                              
#include <ESP8266HTTPClient.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);


                                                                       
const char* ssid = "*******";                 //Your router SSID i.e WiFi Name                             
const char* password =  "*******";            //Your WiFi Password
const char* host = "api.thingspeak.com";      //We read the data from this host                                   
const int httpPortRead = 80;                                           
 
/*
             Just Change the API Key With Your API via ThingHttp
*/                              
const char* url1 = "/apps/thinghttp/send_request?api_key=TGC4KNQ98REOA4JH";     //Confirmed  
const char* url2 = "/apps/thinghttp/send_request?api_key=Y0ALN1QGDTNLLNNM";     //Recovered
const char* url3 = "/apps/thinghttp/send_request?api_key=0J24MB3W9F9Q0E7M";     //Death
const char* url4 = "/apps/thinghttp/send_request?api_key=R2BKR1DRVS5YT2PH";     //Recovery Rate 
const char* url5 = "/apps/thinghttp/send_request?api_key=VYMVMGK9S8W21EXQ";     //Fatality Rate

String Cases,Death,Recover,Recoveryrate,Deathrate;

WiFiClient client;                          //Create a WiFi client and http client                                                     
HTTPClient http; 

void setup() {
  
  Serial.begin(9600);            //Start the serial communication 
  WiFi.disconnect();             //Disconnect and reconnect to the Wifi you set                                                 
  delay(1000);                                                                  
  
  WiFi.begin(ssid, password);                                                   
  Serial.println("Connected to the WiFi network");   //Display feedback on the serial monitor                                        
  Serial.println(WiFi.localIP()); 
  display.begin(); 
  display.display();
  delay(1000);

  display.clearDisplay();
  display.display();

  display.setTextSize(1);
  display.setTextColor(WHITE);

}

void loop()                                                                      
{
                                                                                        
  
//Reading 1: Reading of Confirmed Cases

    if( http.begin(host,httpPortRead,url1))        //Connect to the host and the url                                      
      {
        int httpCode = http.GET();                 //Check feedback if there's a response                                                  
        if (httpCode > 0)                                                              
        {
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 
            {                
              Cases = http.getString();   
              Serial.print("Confirmed Cases: ");  
              Serial.println(Cases);                                               
              display.setCursor(0,0);
              display.println("   COVID19 LIVE");
              display.println("");
              display.println("Confirmed Cases : ");
              display.println(Cases);
              display.display();
              delay(4000);
              display.clearDisplay();  
            }
        }
        else        //If we can't get data
        {
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        http.end();                                                                 
      } 
    else            //If we can't connect to the HTTP
      {
        Serial.printf("[HTTP} Unable to connect\n");
      }


//Reading 2: Reading of Recovered

      if( http.begin(host,httpPortRead,url2))                                              
      {
        int httpCode = http.GET();                                                      
        if (httpCode > 0)                                                               
        {
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 
            {                             
              Recover = http.getString();   
              Serial.print("Recovered: ");
              Serial.println(Recover);
              display.setCursor(0,0);
              display.println("   COVID19 LIVE");
              display.println("");
              display.println("Recovered : ");
              display.println(Recover);
              display.display();
              delay(4000);
              display.clearDisplay();                                                                        
            }
        }
        else 
        {        
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        http.end();                                                                 
      } 
    else 
      {
        Serial.printf("[HTTP} Unable to connect\n");
      }

//Reading 3: Reading of Deaths

      if( http.begin(host,httpPortRead,url3))                                              
      {
        int httpCode = http.GET();                                                      
        if (httpCode > 0)                                                               
        {
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 
            {                              
              Death = http.getString();   
              Serial.print("Deaths: ");
              Serial.println(Death);       
              display.setCursor(0,0);
              display.println("   COVID19 LIVE");
              display.println("");
              display.println("Deaths : ");
              display.println(Death);
              display.display();
              delay(4000);
              display.clearDisplay();                                                                                                                                                                       
            }
        }
        else 
        {
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        http.end();                                                                 
      } 
    else 
      {
        Serial.printf("[HTTP} Unable to connect\n");
      }

//Reading 4: Reading of Recovery Rate

      if( http.begin(host,httpPortRead,url4))                                              
      {
        int httpCode = http.GET();                                                      
        if (httpCode > 0)                                                               
        {
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 
            {                              
              Recoveryrate = http.getString();                 
              Serial.print("Recovery Rate : ");
              Serial.println(Recoveryrate);
              display.setCursor(0,0);
              display.println("   COVID19 LIVE");
              display.println("");
              display.println("Recovery Rate : ");
              display.print(Recoveryrate);
              display.println(" % ");
              display.display();
              delay(4000);
              display.clearDisplay();                                                                                                                                                                        
            }
        }
        else 
        {
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        http.end();                                                                 
      } 
    else 
      {
        Serial.printf("[HTTP} Unable to connect\n");
      }

//Reading 5: Reading of Death Rate

      if( http.begin(host,httpPortRead,url5))                                              
      {
        int httpCode = http.GET();                                                      
        if (httpCode > 0)                                                               
        {
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 
            {                   
              Deathrate = http.getString();  
              Serial.print("Fatality Rate : ");
              Serial.println(Deathrate);  
              display.setCursor(0,0);
              display.println("   COVID19 LIVE");
              display.println("");
              display.println("Fatality Rate : ");
              display.print(Deathrate);
              display.println(" % ");
              display.display();
              delay(4000);
              display.clearDisplay();  
              display.display();                                                                                                                                                                                  
            }
        }
        else 
        {
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        http.end();                                                                 
      } 
    else 
      {
        Serial.printf("[HTTP} Unable to connect\n");
      }
   
    while (WiFi.status() != WL_CONNECTED)     //In case the Wifi connection is lost                                    
      { 
        
        WiFi.disconnect();                                                        
        delay(1000);                                                             
        
        WiFi.begin(ssid, password);                                              
        Serial.println("Reconnecting to WiFi.."); 
        
              display.setCursor(0,0);
              display.println("   Techtronic Harsh");
              display.println("");
              display.println(" Connecting.... ");
              display.display();
              delay(10000);                                                             
              display.clearDisplay();  
              display.display();       
       
      }

} 
/*
      © Techtronic Harsh

    Youtube : http://bit.ly/33kxOOQ
    Instructables : https://www.instructables.com/member/...
    Instagram : https://instagram.com/techtronicharsh
    Website : http://techtronicharsh.com
    Telegram : https://t.me/techtronicharsh

*/  
Close Bitnami banner
Bitnami