Skip to content

Keep Track of COVID-19 Outbreak in your country using ESP8266 12E (NodeMcu)

 

Hello there, I hope you are well and safe, this project uses ESP8266 12E or NodeMcu v1.0 to keep track of the virus outbreak in your country or the whole world.This project uses: ThingSpeak, especially the ThingHTTP App. And the data is retrieved from WorldOMeters.

Important !!

Please I want to inform you that after testing for a bit longer, the WorldOMeters website seems not keeping the order of the countries, so if you can access to your country data (Check update “#1 after reading the article) take it directly from there… it’s the same procedure, you copy the full address with “/” at the end, and then you look for the element to read.
The parse and data received are different but if you get the idea it will be easier for you to scrap data from a stable website.

Read the Update #1 below.

I Supposed that you have already installed ESP8266 boards on your Arduino IDE.

There are two codes below: One for using the Serial monitor only and one for the TFT RGB LCD I’ve used.

 

ThingSpeak stuff and data retrieve from WorldOMeters

First create an account in ThingSpeak if you haven’t. And to show you an example I’m gonna take Italy (Land of Arduino) as example.

1
When you get to the app and press “New ThingHTTP”

 

You’ll find a lot of fields to fill but those are the important ones, put a name to the thing, and copy that URL:

https://www.worldometers.info/coronavirus/

2

This field is also very Important, and we’ll see how to get that value

3

Now you go to WorldOmeters, the CoronaVirus meter https://www.worldometers.info/coronavirus/

Look for the country you want, and do this, I have a French computer. “Le computer”

4

Once you open the tool, go to the right and just hover over those elements in the red square until you select the correct data to get (check two pictures).

5

6

Press right click on the element of the correct value to get and Copy XPath

7

And now you go back to your ThingHTTP we called it “Italy cases” and paste it in Parse String, and press “Save ThingHTTP”.

8

You’ll see something like this, keep in mind the string I put inside the rectangle we gonna use it later in the code, it looks something like this:

/apps/thinghttp/send_request?api_key=12WW2L8UDXUZV0VA

9

So you do this for the other values too, in my example I’m reading the number of recovered people and also dead people… you can remove or add other data.In the video I did the 3 of them.

Code and some stuff

Here’s the code first: Download the code here

Here you can see the links that we got from ThingHTTP and we add them as “url1” “url2″…, I’m reading the data separately… some prefer to get one single data and extract all the values, but I prefer this method.

const char* url1 = "/apps/thinghttp/send_request?api_key=12WW2L8UDXUZV0VA";
const char* url2 = "/apps/thinghttp/send_request?api_key=LE11LAN099543GEG";
const char* url3 = "/apps/thinghttp/send_request?api_key=UW6VMKBE0W8M9OC3";

So the basic idea of the code is that first I get the data, and this is an example of the raw data received.

10

Those are the Raw data I receive from the 3 URLs, and every single one of them goes from “<td style…..” until </td>.So in the code to get just the numbers that are in the rectangles, I search in the string for the symbol ” > ” and I remove it +everything before it and I store it then I search for the symbol ” < ” and I remove it + everything after it, so the String will change like this.

11

Using the TFT RGB LCD

So this is how it looks, this display is very nice and big enough to display everything, Of course below you’ll find the wiring required for this, the libraries and the code.

Wiring

Wiring 1_bb

Libraries

Here you’ll find the two libraries needed for the display:

https://github.com/adafruit/Adafruit-ST7735-Library
https://github.com/adafruit/Adafruit-GFX-Library

Code

Here you can get the code (Google Drive): Download the code here

Result

Last

 

Update #1

So as I said above the website display is not stable, as it orders country’s depending on the number of cases, so here’s a first solution.

If you can access to your country’s page in the website it will be possible, let’s take Germany as example.

You click on the country in that table we’ve seen before or look for it.

https://www.worldometers.info/coronavirus/country/germany/

Go to the counter -> Right click -> Inspect

DEuth

Then you do the same as before, click to expand

DEuth_2

You paste it here “Parse String” (in ThingHTTP) as seen above

DEuth_3

And above instead of putting the general URL as we’ve seen before you put the URL specific to Germany.

DEuth_4

That’s all and in the code, instead of reading every data separately we read them all at once and we extract the numbers using some String functions.

Code with update

Download the code here.

And if you compare it with the previous code they are pretty much the same all you have to do is get data and extract it.

Result

Germany_2

The numbers below concerns Germany and above them are Italy’s, how did I switch it’s very simple just change the URL in ThingHTTP and you’ll get the country’s numbers.

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

Leave a Reply

%d bloggers like this: