One of things I wanted to accomplish when I began learning more about electronics was to build a small device from the ground up. This would include sourcing all parts, writing the necessary code, and designing and 3D printing an enclosure for the device. Given the state the world at this time, as my first foray into electronics design, I decided to make a little device to keep track of US COVID-19 stats.
Starting off small, I used a micro-controller that came with everything and the kitchen sink. The Wemos LOLIN D32 is a fantastic little piece of electronics that cost around $5. It's a dev board based around the ESP32-WROOM-32 module and is compatible with the Arduino platform. and comes with WiFi and Bluetooth out of the box. Perhaps a little overkill for what I'm building, but it allowed me to get up and running very quickly.
The MSP2402 screen is an 2.4 inch TFT LCD Screen with a resolution of 320x240 pixels. I chose a larger screen so that I can could make something large enough for "at-a-glance" stats that I could put on a shelf somewhere.
All major pieces were connected together on a protoboard using JST connectors and pin headers so that future revisions can reuse the same components.
The code for the project is available on GitHub.
The project utilizes a couple useful utilities to make development a lot easier. First and foremost is the PlatformIO IDE plugin for VS Code. This brings some modern niceties that aren't available with the standard Arduino IDE such as dependency version management, a command line based build system, and the ability to use the code editor of your choice.
For the implementation itself, I used:
The basic loop function would look like something below:
bool updateScreen = false;
void loop() {
if (wifi.run() == WL_CONNECTED) {
unsigned long currentTime = millis();
if (currentTime - LAST_UPDATED_TIME >= UPDATE_TIME_MS) {
LAST_UPDATED_TIME = currentTime;
update_tracker()
}
}
if (updateScreen) {
render_stats();
}
}
We want to make sure we have an internet connection (wifi.run()
) and if everything
looks good, we can go ahead and make a request to the API. If anything has changed
in the stats, we'll set a flag to update the screen. Once that request is done,
if the screen update flag is set, we can run through the code to re-render the
contents of the screen.
All in all, the code was very straightforward and pretty similar to how you would build a similar stats tracker in any other language/platform.
Now for the hardware.
To keep track of all the different wires, I used kicad to build out a schematic based on the breadboard prototype I had built. As I get better at kicad, my hope is eventually turn some of these schematics into actual PCBs that can be printed, but for the time being, it's a handy way to visualize the connections.
For this first build, I left out the button which allows you to jump to different screens, but the code and schematic still handles this.
Below are some photos of the final soldered result:
For the enclosure design, I settled on using Shapr3D for the iPad. It is a fantastic application that has everything I need as a hobbyist to get things done. Since the enclosure is nothing more than a simple rectangular box, diving into more complex tools like Fusion 360 or AutoCAD just didn't seem like a lot of fun.
This was my first enclosure that was designed from scratch, and is comprised of two large halves that are screwed together. The files are available here for download.
I used my MonoPrice Maker Select v2 to print out the enclosure and test prototypes before finally putting everything together.
Here's a video fo the COVID tracker booting up and loading the data
Some things I would like to work on for v2 of this enclosure: