Covid19 Stat IoT Display

Introduction: Covid19 Stat IoT Display

The world currently in the coronavirus pandemic and like many other countries its lockdown in India too, so I got this idea to create an IoT display that will give a realtime update of Corona Statistic of the country. I use an API that provides data of India, But you can use any API with a little change in code.

Step 1: Things Needed

Here are the things that you will need to make IoT display:

  • NodeMCU (ESP8266)
  • 16x2 LCD module (I2C)
  • Breadboard (optional)
  • Some Wires/ Jumpers
  • USB cable

Step 2: Connections

The connections are pretty easy. There is only 4 wire to connect. You can use a breadboard to place the esp8266 in it and then connect to the LCD module or you can just use direct female to female jumper wires to connect.

The connections are (ESP-> LCD):

  1. VIN -> VCC (for 5V)
  2. GND -> GND
  3. D2 -> SDA
  4. D1 -> SCL

Now just connect the esp8266 with the USB cable to PC, now we just need to upload the code.

Step 3: Coding

Now, this is the most important part.
Many of you will have questions in mind that how this works?

So, It first connects to wifi and then connects to an API to collect JSON data, then it decodes the JSON data and stores those values in a variable, then the LCD displays the values and this continues in a loop.

The API I used is http://coronago.xyz/api/data.json, that gets its data from https://www.covid19india.org/, It provides data only for India, But there are many API for other countries, you can use any API, but make sure it can be accessed by HTTP.

First, you need to install ESP8266 board support for Arduino IDE. Follow this tutorial.

The second thing to do is to install all required Libraries, you can easily install them from the Arduino Library Manager.

Then open code and change wifi credentials and upload the code.

the code is here in my GitHub repository - https://github.com/Soumojit28/covid19-iot-display.

Step 4: Code Explanation and Using Other API

The code is pretty simple

In the void setup part it initializes the LCD module and displays the staring message then it connects to the wifi network.

In the loop part, it fetches the JSON data from API and decodes ad store it in a variable then it displays those in the serial monitor and the LCD.

for using another API you have to change the address in this line of the code

http.begin("http://coronago.xyz/api/data.json");  //API

Another thing the API must work with an HTTP connection, HTTPS connection will not work in this code and you will get a -1 error.

The API returns JSON data like this

{"confirmed":"1199","active":"1068","recovered":"102","deaths":"29","lastupdated":"30\/03\/2020 15:07:25"}

Now This next code just decodes the JSON and store values in the variable, this totally depends on the API and JSON data it returns. But it's easy to change, for more info you can check this tutorial.

StaticJsonBuffer<300> JSONBuffer;   //Memory pool<br>  JsonObject& parsed = JSONBuffer.parseObject(payload); //Parse message
  confirmed = parsed["confirmed"]; 
  recovered = parsed["recovered"];
  deaths = parsed["deaths"];
  current_active = parsed["active"];

After that the code just displays the variables in the serial monitor and in the LCD.

Serial.print("confirmed: ");
Serial.println(confirmed); Serial.print("recovered: "); Serial.println(recovered); Serial.print("currenty_active: "); Serial.println(current_active); Serial.print("deaths: "); Serial.println(deaths); if(httpCode==200){ //display the data in lcd lcd.clear(); lcd.setCursor(0,0); lcd.print("Confirmed: "); lcd.print(confirmed); lcd.setCursor(0,1); lcd.print("Deaths: "); lcd.print(deaths); delay(2500); lcd.clear(); lcd.setCursor(0,0); lcd.print("Active: "); lcd.print(current_active); lcd.setCursor(0,1); lcd.print("Recovered: "); lcd.print(recovered); delay(2500);

}

Step 5: Conclusion

This is a great project to monitor the stats for all the time, and can you build it to pass you time in this lockdown situation.

If you need any help you can ask me via comments or you can open an issue in my Github

https://github.com/Soumojit28/covid19-iot-display for any code related problems.

Thank you.

Be the First to Share

    Recommendations

    • Stone, Concrete, Cement Challenge

      Stone, Concrete, Cement Challenge
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Water Speed Challenge

      Water Speed Challenge

    2 Comments

    0
    KarloHorcicka
    KarloHorcicka

    1 year ago

    Hey! I really like this instructable and I'd like to recreate it but i have been presented with some problems. The first one is the "StaticJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6" problem while the second one is that I don't know how to get the API. Can you please help me?