Nodemcu To Track Covid19: It's Not as Difficult as You Think
this will track number of COVID19 cases reported in India and Karnataka
- 16x2 I2C LCD Display
- NodeMCU Board
- 4 Female to Female Jumper Wires
- USB to Micro USB Cable
- Arduino IDE (Latest version)
- Liquid Crystal Display I2C Library
- Thingspeak Account
Connect the LCD Display with NodeMCU according to the circuit diagram shown below:
LCD GND to GND of NodeMCU
LCD VCC to 3V of NodeMCU
LCD SCL to D1 of NodeMCU
LCD SDA to D2 of NodeMCU
Create an API using Thingspeak
- Open the Website you want to get the data from in chrome or Firefox. For India, I’ll use www.mohfw.gov.in
- Select the part of the data you want and right-click on it, click on ‘Inspect’ after right-clicking.
- Now in the HTML layout window, you will find the selected part highlighted. Now right click on the highlighted part and go to ‘Copy’ and click on “COPY XPATH”.
- Login to your Thingspeak account under the name "Apps" select "ThingHTTP" you will arrive at the following page.
- Now create a new ThingHTTP by clicking on the button in Green.
- Give it a name. I’ll give it as “COVID19 Cases India” in the name field.
- Now paste the XPath copied in Step 3 in the “Parse String” field at the end of the page. Then to the same URL append “/text()” at the end.
- Now paste the website URL in the “URL” field that you had opened in Step 1. In my case, it is “www.mohfw.gov.in” .
- Save the ThingHTTP by clicking the button at the end of the page.
- you will get the API as shown in above Video.
- copy the API you have received and paste it in new tab. You must get the data as shown video
Flashing Arduino code to NodeMCU
- Include the following Libraries:
- ESP8266WiFi.h Library: https://github.com/ekstrand/ESP8266wifi
- I2C LCD Library: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library.git
- Arduino Code: https://github.com/techshiv/COVID19.git
- In the following code replace "SSID" and "Password" values with your WIFI and Password.
- now copy the 16 digit API key from ThingHTTP site and paste it in the “XXXXXXXXXXXXXX” part. Generate a different API key for different data and paste it in their respective section. Like I’ve done there for cases, death and recovered.
- Now connect your NodeMCU to your PC and select the board as NodeMCU 1.0 (Tools -> Board “NodeMCU 1.0 (ESP-12E Module)” -> NodeMCU 1.0 ).
- Now select the Right Port for your NodeMCU and upload the code by clicking the upload button.