Every once in a while I end up requiring more IO for a prop than my boards have headers for. I've had "make an IO expander for your ecosystem" on the to-do list for a while, but due to time limitations I've always opted to grab prebuilt solutions to expand my IO, such as a MCP23017 board. Thanks to a recent commission and a sponsor from PCBWay, I pulled this out of the idea box and made it.
Choosing a Solution
Recently I had a client request a full escape room build. Multiple portions of the escape room require more IO than my current boards allow. In the past, I have also had use cases requiring several analog inputs, such as a large array of knock sensors. Looking at some of the solutions for dedicated SMD devices for analog, the price range for such chips ranged between $4-$12 and 4-8 analog inputs with a decent resolution.
Not liking those options, I turned to microcontrollers for their analog offerings. All of the microcontrollers I'm familiar with thus far are lackluster. The Arduino line has low resolution, the RP2040 also has low resolution, and the Espressif microcontrollers are "estimated" analog values and are the least accurate of them all. So, I dug deep into my plastic bin of "microcontrollers I vaguely remember using at one point". Investigating and checking each board out of the bin, I landed on the notorious "Blue Pill" board.
Small bit of history of the Blue Pill board if you're curious:. The Blue Pill board is an STM32 microcontroller cloned from the original design of the [Maple board by Leaflabs](https://www.leaflabs.com/maple/). This was the first board design from Leaflabs in 2009. An Arduino core was created to enable programming via Arduino IDE, and it immediately became a smash hit for hobbyists interested in transitioning from Arduino's 8-bit architecture to a more modern 32-bit architecture. Suffering from its success, clones began to emerge from China at an incredibly low price point with a blue PCB and counterfeit components. However, with the Blue Pill board costing around $1.50 and working "with just a few issues", it took off harder than the Maple boards. Even in 2024, these boards are still floating around while the Maple board retired in 2015.
The microcontroller hosted on these boards is the STM32F103C8. Thanks to its popularity, it's produced in high volumes and is extremely affordable at less than $1 per chip. In terms of features and performance today, it is an average microcontroller perfectly capable of handling any regular task. It's capable of 12-bit analog resolution, which is pretty decent, and especially so for its price. There are two ADCs each with 10 channels, but they share the same pins, putting the microcontroller up to a total of 10 analog inputs (actually 15, but I'll discuss that later). Board to board communication is possible with the device through I2C, UART, SPI, and CAN. It also supports DMA over analog, which means analog sampling can occur in the background without affecting the speed of the rest of the system.
The downside to choosing a microcontroller as an analog solution over a dedicated chip is development time. A dedicated IC needs less components compared to a microcontroller. Going even further, you can also buy fully complete solutions with no development required if you're willing to pay for it. Also, significantly less programming is required to interface with a dedicated IC compared to a microcontroller. That extra couple of dollars you'll spend on the dedicated IC may make up for the time, depending on your situation. My goal is to push down the hardware cost to a minimum to make replacements less impactful and to future-proof the idea of selling boards. Since I can program, design, and execute these solutions, I choose to develop it. This also gives me the freedom of deciding how it will operate.
Designing the PCB
In order to use the STM32F103C8 in a design, a few passive components are required. When working with analog, extra care must...
Read more »