Covid-19 Tracker
You don’t have to watch TV to know what the situation is in your country. In this tutorial, I will show you how to make Covid-19 Tracker. The data will refresh on the display automatically every 5 seconds. You need the Board NodeMCU and 1.8 “SPI display. In the sketch you must provide the name and password for your internet and ApiKey. Coronavirus data is downloaded from www.worldometers.info and processed by thingspeak.com.
I encourage you to visit the author of the project https://surtrtech.com/2020/03/25/keep-track-of-covid-19-outbreak-in-your-country-using-esp8266-12e-nodemcu/, here is the original program version.
Instructions:
List Elements:
- NodeMCU
- Display 1.8″ SPI ST 7735
- PCB Prototype board / BreadBoard
- Wires
- Header Female pins
Connection:
- First version is on prototypy pcb board
- Second version is on breadboard


CODE:
Download the latest version from the project author’s website or use mine sketch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
/* * ForbiddenBit.com * * http://arduino.esp8266.com/stable/package_esp8266com_index.json * * Author project: surtrtech.com */ #include <Adafruit_GFX.h> //Libraries required to use the Display #include <Adafruit_ST7735.h> #include <SPI.h> #include <ESP8266WiFi.h> //Use ESP8266 functions #include <ESP8266HTTPClient.h> #define TFT_CS 15 //Display pins #define TFT_RST 0 #define TFT_DC 2 // ---------------- CONFIGURE ------------------------------------------------------------- const char* ssid = "SSID"; //Your router SSID and password const char* password = "PASSWORD"; const char* url1 = "/apps/thinghttp/send_request?api_key=Y75JD33K3IOGHMCO"; // API KEY // ------------------ END ------------------------------------------------------------------ const char* host = "api.thingspeak.com"; //We read the data from this host const int httpPortRead = 80; int To_remove; //There are some irrelevant data on the string and here's how I keep the index //of those characters String Cases,Death,Recover,Deaths,Recovered,Data_Raw,CasesW,DeathW,RecoverW,Data_Raw_1,Data_Raw_2,Data_Raw_3; //Here I keep the numbers that I got WiFiClient client; //Create a WiFi client and http client HTTPClient http; Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); //Those things are for the display float p = 3.1415926; void setup() { Serial.begin(9600); //Start the serial communication and the display tft.initR(INITR_GREENTAB); 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()); } void loop() { 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) { Data_Raw = http.getString(); //Here we store the raw data string Data_Raw_1 = Data_Raw; Serial.print("Data_Raw: "); //I choosed to display it on the serial monitor to help you debug Serial.println(Data_Raw); To_remove = Data_Raw_1.indexOf(">"); //I look for the position of this symbol ">" Data_Raw_1.remove(0,To_remove+1); //I remove it and everything that's before To_remove = Data_Raw_1.indexOf("<"); //I look for the position of this symbol ">" Data_Raw_1.remove(7,37); //I remove it and everything that's after //Example: This is the raw data received <td style="font-weight: bold; text-align:right">63,927</td> //First we look for ">" and we remove everything before it including it //We stay with this 63,927</td> //We look for "<" symbol and we remove it + everything after //We keep only this 63,927 as string Cases=Data_Raw_1; Serial.print("Cases: "); //I choosed to display it on the serial monitor to help you debug Serial.println(Cases); Data_Raw_2=Data_Raw; To_remove = Data_Raw_2.indexOf("<span>"); Data_Raw_2.remove(0,To_remove+8); Data_Raw_3=Data_Raw_2; To_remove = Data_Raw_2.indexOf("</span>"); Data_Raw_2.remove(7,30); Deaths=Data_Raw_2; Serial.print("Deaths: "); Serial.println(Deaths); To_remove = Data_Raw_3.indexOf("<span>"); Data_Raw_3.remove(0,7); To_remove = Data_Raw_3.indexOf("<"); Data_Raw_3.remove(9,20); Recovered=Data_Raw_3; Serial.print("Recovered: "); Serial.println(Recovered); } } 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"); } Print_TFT(); //Display to the TFT LCD, this function will vary depending on your display delay(3000); while (WiFi.status() != WL_CONNECTED) //In case the Wifi connexion is lost { WiFi.disconnect(); delay(1000); WiFi.begin(ssid, password); Serial.println("Reconnecting to WiFi.."); delay(10000); } } void Print_TFT(){ tft.fillScreen(ST77XX_BLACK); tft.setTextWrap(false); tft.setCursor(45, 5); //Horiz/Vertic tft.setTextSize(2); tft.setTextColor(ST77XX_YELLOW); tft.print("USA"); tft.setCursor(15, 25); //Horiz/Vertic tft.setTextSize(1); tft.setTextColor(ST77XX_WHITE); tft.print("COVID-19 Tracker"); tft.setCursor(5, 45); //Horiz/Vertic tft.setTextSize(2); tft.setTextColor(ST77XX_BLUE); tft.print("Cases:"); tft.setCursor(10, 65); tft.print(Cases); tft.setCursor(5, 93); //Horiz/Vertic tft.setTextSize(2); tft.setTextColor(ST77XX_GREEN); tft.print("RECOVERED:"); tft.setCursor(15, 115); tft.setTextColor(ST77XX_WHITE); tft.print(Recovered); tft.fillRect(0, 138 , 48, 10, ST77XX_WHITE); tft.setCursor(7, 140); //Horiz/Vertic tft.setTextSize(1); tft.setTextColor(ST77XX_BLACK); tft.print("DEATHS: "); tft.setCursor(55, 140); tft.setTextColor(ST77XX_WHITE); tft.print(Deaths); } |