Covid-19 Update Tracker Using ESP8266

Introduction: Covid-19 Update Tracker Using ESP8266

About: Master in Electronics Engineering

This is a project shows the current data of the coronavirus outbreak of various cities of states of India in realtime on OLED display. This Live status tracker helps you monitor realtime covid-19 update of your district. This project is completely based on realtime data collected from API. API provided by covid19india.org.

Supplies

  • ESP8266-01
  • OLED Display
  • USB to TTL converter
  • Wires
  • Xamp Software

Step 1: Get an API

For India, get an free api from postman. I got state wise api which returns a json array with the data of all the sates of India with the sub key we can access all the cities of all the states of India.

API I got--> https://api.covid19india.org/state_district_wise.j...

This returns json array on webpage. But ESP is not able to decode this, we need much simple json which can be sent to our esp. For that creating a php page to simplify the json array and taking only those cities which we require.

Step 2: Creating PHP Script

Download Xampp software form here https://www.apachefriends.org/download.html

Install xampp and click on start button of Apache module.

Step 3: Creating Php Script

Move to folder : C:\xampp\htdocs

Here create folder with any name, I created as Covid.

Inside that folder create a text file rename its extension to php.

Open that file in any text editor I'm using Notepad++.

Now write this php code.

<?php

$url = "https://api.covid19india.org/state_district_wise.json";

$json = file_get_contents($url);

$json = json_decode($json,true);

$amt_conf= $json['Maharashtra']['districtData']['Amravati']['confirmed'];

$amt_dead= $json['Maharashtra']['districtData']['Amravati']['deceased'];

$amt_recov= $json['Maharashtra']['districtData']['Amravati']['recovered'];

$mum_conf= $json['Maharashtra']['districtData']['Mumbai']['confirmed'];

$mum_dead= $json['Maharashtra']['districtData']['Mumbai']['deceased'];

$mum_recov= $json['Maharashtra']['districtData']['Mumbai']['recovered'];

$ngp_conf= $json['Maharashtra']['districtData']['Nagpur']['confirmed'];

$ngp_dead= $json['Maharashtra']['districtData']['Nagpur']['deceased'];

$ngp_recov= $json['Maharashtra']['districtData']['Nagpur']['recovered'];

$pune_conf= $json['Maharashtra']['districtData']['Pune']['confirmed'];

$pune_dead= $json['Maharashtra']['districtData']['Pune']['deceased'];

$pune_recov= $json['Maharashtra']['districtData']['Pune']['recovered'];

$value = array(

"Mumbai"=>array( "confirmed"=>"$mum_conf", "death"=>"$mum_dead", "recovered"=>"$mum_recov" ),

"Pune"=> array( "confirmed"=>"$pune_conf", "death"=>"$pune_dead", "recovered"=>"$pune_recov" ),

"Nagpur"=> array( "confirmed"=>"$ngp_conf", "death"=>"$ngp_dead", "recovered"=>"$ngp_recov" ),

"Amravati"=> array( "confirmed"=>"$amt_conf", "death"=>"$amt_dead", "recovered"=>"$amt_recov" )

);

$j = json_encode($value);

echo $j

?>

Step 4: Understanding the JSON Script

Step 5: Understanding PHP Script

Change name of state and city according to you.

Step 6: Testing PHP Script

access the page from browser.

http://localhost:8081/Covid/covid.php/

Covid is folder name

localhost:8081 --> Remove :8081 if your xampp is using default port.

Access page from lan connected device by replacing localhost to ip address of pc on which xampp is running.

Step 7: Wiring Together

While Uploading code to esp connect gpio 0 to ground.

Step 8: Uploading Code

Read code carefully change data wherever necessary.

Connect gpio0 to gnd, FTDI to 3.3v logic.

In Arduino IDE: select generic esp8266, select com port and click upload.

Attachments

Step 9: Results

Yeahh! We are done with our project.

For this project to work you need to turn on xampp server all the time so if you want it to run without pc to remain turn on, you can take hosting service where you place that php page and replace ip address in arduino code to url of your hosting. So now you can fetch record directly without local xampp server.

Try it.... Hope you like it and tell me how it is in comments down below....

Thank you...

Arduino Contest 2020

Participated in the
Arduino Contest 2020

Be the First to Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • First Time Author Contest

      First Time Author Contest
    • Backyard Contest

      Backyard Contest

    4 Comments

    0
    RishabhL
    RishabhL

    Reply 9 months ago

    Yes

    0
    RishabhL
    RishabhL

    Tip 1 year ago

    Turn off window firewall for this project.