Introduction: Live Covid19 Tracker Using ESP8266 and OLED | Realtime Covid19 Dashboard

About: Welcome to my Channel "Techtronic Harsh". I am Harsh Shah. This is an education channel and website in the area of Electronic, Electrical and Computer Engineering. Tutorials, Tips, Tricks, How It Wor…

Visit Techtronic Harsh Website : http://techtronicharsh.com

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.

Supplies

  • ESP8266
  • OLED Display
  • Jumper Cables

Step 1: Schematics :

Step 2: 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 .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 (Image) , 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.
  3. Upload The Code. That’s it!!

Step 3: Source Code :

/*
© 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

*/

Step 4: Working :

Make the connections as per circuit diagram and upload the code after selecting proper board and COM Port. If it shows error make sure you have added the library as per the instruction given above.

If it takes Much time to Run on OLED, Make Sure You Have Properly connected to internet services i.e Your WiFi or Hotspot.