Once I have successfully built the prototype with the Raspberry Pi Zero, I knew for the final version I would need to use something more accessible. The choice was obvious for me -ESP32...
I had some ESP32 Dev boards lying around, so it wasn't hard to start. I can code something, but I wouldn’t say I'm a real coder. I knew it may be a challenge, but didn't see any reason, why it wouldn’t work straight away.
“Well... it wasn't as simple after all as I originally thought... I had a previous experience with ESP32, but not enough to make it as smooth as I wanted.”
You’ll be posting loads of engaging content, so be sure to keep your blog organized with Categories that also allow visitors to explore more of what interests them.
The painful journey
As I mentioned, I'm more hardware, than software-oriented, but if I know something at least on the beginner level it's Python. I knew it's possible to use MicroPython on ESP32, so I thought, this may be a great project to earn some skills.
It was a great choice. Fairly easy I have figured out, how to flash a MicroPython firmware to ESP32 and shortly after I had a few lines of code running.
The first problems occurred when I wanted to add the font. I have made the .BMP images of each digit in Photoshop and then with another Python code, I have to convert that .BMP to NumPy array (0 and 1). Where 1 is pixel ON and 0 is pixel OFF... That was working fine and thanks to that I was able to create not only numbers but logos and currency as well.
When I added more than 3 digits I run into the memory error. Fine, I thought Just need to get another ESP32 with bigger memory. After all, each digit was just a huge array of 32-bit integers.
“Here is the time, where my lack of proper experience showed up.”
First, it took me a while to figure out which ESP32 module I want. There are many... so many of them... ESP32-WROOM-32D, ESP32-WROVER-B, ESP32-WROVER-IB, ESP32-WROOM-32U, ESP32-WROVER-I, ESP-WROOM-32 and many many others... Which one I should want?
From the beginning, I knew I would like to connect an external antenna, as I knew the standard onboard PCB antenna may not be strong enough deep inside the aluminium frame and I wanted to be sure, everyone can connect to the WiFi easily. Took me a while, but soon I started to understand the difference between the WROOM and WROVER, what's 32D and 32U and what's the difference between the B and IB version (it's the antenna connector).
So I ordered a couple of ESP32-WROOM-32U. Cute small module with external antenna connector only. Perfect... at least I thought so...
Since I knew about the memory issues, I bought the first 4MB version, 8MB version, 16MB version and even 32MB flash memory... Still had the same issue...
I was stupid. I wasted 2weeks on this... Thankfully some guy on StackOverFlow finally explained to me, flash memory had nothing to do with the PSRAM... And PSRAM is what I wanted.
In my defence, it's pretty confusing for the beginner. What's Flash Memory, PSRAM, SRAM, SPIRAM, ROM etc with the combination of another 20 differently shaped modules I mentioned before??
Now I know. But it took me 2weeks. On another side, that's how learning looks like in the real world I guess... Need to get your hands dirty and learn from your own mistakes.
Somewhere I read Espressif released a brand new ESP32-S2 module. (Another confusing label 🙄)
It does have only one core, WiFi, no BLE (I didn't need that anyway) but it has 2MB PSRAM and most importantly native USB support. Perfect match!!! I immediately fell in love with this chip. Its price and capabilities are exactly what I needed for this project. Finally the code work. I have switched from MicroPython to CircuitPython from Adafruit, as they have direct support with tons of libraries for this chip. Thanks to the native USB, after firmware flash I can plug MoonClock into the PC and update the WiFi credentials or whole code without all the annoying UART modules. And you can too. Remember, it's open-source. To be precise I'm using ESP32-S2-WROVER-I.
17th Jun 2021