When run on an ESP8266 microcontroller, this code does the following:
- Connects to the configured 2.4GHz WiFi network
- Sends an HTTP GET request to two endpoints and retreives:
- Updated Coronavirus data for the whole world
- Updated Coronavirus data for a specific countrt
- Parses the JSON response and extracts:
- Number of cases
- Number of deaths
- Displays the extracted information on the OLED display
- Sleeps for 10 minutes
- Goto 2
The data displayed originates from two endpoints:
https://corona.lmao.ninja/v2/all
- returns a JSON object with updated Coronavirus data for the whole worldhttps://corona.lmao.ninja/v2/countries/COUNTRY_NAME
- returns a JSON object with updated Coronavirus data for the country name after the last slash
The following code changes need to be made prior to compiling and uploading to the ESP8266:
- Line 34 - enter the required WiFi network name (the ESP8266 can connect only to 2.4GHz networks, not 5GHz ones)
- Line 35 - enter the required WiFi network password
- Line 37 - enter the required country name
- Line 98 - enter the required country name
- ESP8266 - a low-cost WiFi microchip, with a full TCP/IP stack and microcontroller capability. Basically, the brains of this project
- SSD1306 - a monochrome 0.96" 128x64 IIC OLED graphic display
- Changing the sleep time requires updating the value passed to the delay function on line 105
- Parsing a different parameter from the JSON response requires updating the name of the key in either line 60, 61, 73 or 74 (in order to see the possible keys, you can open the URL in your browser and review the response)
- Replacing the provided endpoints with different ones requires updating the URL values in lines 37 and 38