ESP32 Dev Kit v1 with two OLED screens running Micropython, displaying Covid Vaccination Statistics retrieved from a public API.

Why?

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.

Hardware Setup

  1. ESP32 Dev Kit v1
  2. .96″ OLED Display
  3. Micro Switch
  4. A Li-Ion Battery
  5. TP4056A Li-Ion Battery Charging Module
  6. MCP1700-3302E Voltage Regulator
  7. 1000uF 16V electrolytic capacitor and a 100nF ceramic capacitor
  8. 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.

Software Setup

The base setup for your device is the same as I have described before here. Once you have your board configured with MicroPython upload the following files from the Git Repo

main.py
ssd1306.py
gfx.py
config.py

And you are set!

config.py

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: https://my-json-server.typicode.com/cashoefman/api-server/counts.

ssd1306.py

This is the driver for the OLED screens

gfx.py

This is a library that I used to draw the battery indicator and the timer at the bottom of each OLED screen.

main.py

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts