ESP32 Dev Kit v1 with two OLED screens running Micropython, displaying Covid Vaccination Statistics retrieved from a public API.
I am trying to learn new things and there is no better way to learn new things than by doing it. What I wanted to do was create a little clock that would display some Covid related statistics, specifically the number vaccines that have been distributed and the number of people that have been vaccinated.
I am going to use a basic ESP32 based Dev Kit with two OLED screens and battery power it. It will connect to a Public API to retrieve the COVID vaccination statistics and display it on the screen.
When I started this project there was no public API available with the COVID Vaccination statistics so for this purpose of this project I manually retrieve the data from the CDC website and add it to a JSON Rest Server that I will connect to from the ESP32. For more information on how to set that up you can check this out my article on How to setup a JSON REST API Server on Heroku or take a look at my Github Repo, How to setup a local and remote JSON REST API Server in ten-ish easy steps.
For now you could just use my JSON Server for it but I am not sure how long that will keep working.
- ESP32 Dev Kit v1
- .96″ OLED Display
- Micro Switch
- A Li-Ion Battery
- TP4056A Li-Ion Battery Charging Module
- MCP1700-3302E Voltage Regulator
- 1000uF 16V electrolytic capacitor and a 100nF ceramic capacitor
- 82K Ohm and 28K ohm resistors
I will provide this Fritzing diagram for the setup. However I don’t guarantee anything and am not very experienced with electronics so don’t blame me if the diode on your ESP32 Dev board starts smoking or you blow up the USB port on your brand new Mac Book M1.
Note: In order for the displays to work you have to change the address of the second display. On the displays I used you can do that by moving the “IIC Adress Select” SMD Resistor.
main.py ssd1306.py gfx.py config.py
And you are set!
The Git Repo has a file called
example.config.py just rename that file to
config.py and update it with your Wifi SSID and Password.
Depending on the ESP 32 board you use and how you wire it you can also update the PINS for any onboard or remote LED and the PIN for the ADC reading the voltage of the battery.
Kyle Redelinghuys) at the Covid 19 API said he will be adding COVID Vaccination Statistic data to his API, once he does that, I will add information on how to use that API. But for now you can use my JSON Server. For this you will also have to update the API_URL to:
This is the driver for the OLED screens
This is a library that I used to draw the battery indicator and the timer at the bottom of each OLED screen.
This is your main “application”. Refer to the file itself for fairly detailed comments on what each line does.
NOTE: The latest version of this write up will be on Github, there might be changes since I wrote this blog post. Check it out the Git Repo for the most up-to-date information.