Most of my previous posts have been focused on software topics. I’m going to stray a little into hardware for this article. At the end of 2022 I made a promise to myself to learn how to use KiCad so that I could design my own printed circuit boards. I have some experience with electronics and I thought that I could design some relatively simple PCBs for my own use. I found this 100 minute YouTube tutorial and it provided enough practical info to get me started. This blog post is not about learning KiCad; instead I’m going to walk through all of the steps and equipment necessary to build my Pocket CO2 sensor project. The KiCad files and firmware can be found here.

Surface Mount Soldering is Easy?

After seeing videos of professional makers such as Seon “Unexpected Maker” Rozenblum use pick-n-place machines to build complex PCB boards using impossibly small components, I wrongly assumed that SMD soldering required expensive equipment and lots of expertise. To get to Seon’s level, you do need expensive equipment and lots of expertise, but there are much simpler SMD PCB projects that can be done with inexpensive tools and very little experience. Over the years, I had tried at various times to work with some SMD components on tinned proto-boards using a fine tip soldering iron. I was able to clumsily solder a few 0603 components and destroy/remove others, but it frequently resulted in frustrating failures. What made it much easier was my first new piece of equipment – the hot air rework station. It sounds more impressive than it is; more akin to a high temperature hair dryer.  I purchased one of these 858D clones (see below) for about $35. There are many variants of this in the market, but they’re all very similar. It has a knob to control the fan speed, buttons to raise or lower the temperature and a heat ‘wand’ on a short cable. For safety, there’s a magnetic switch which turns off the heater when it’s sitting in the holster.

With only the hot air gun and a good pair of tweezers, it’s possible to solder or rework (simple) SMD PCBs with minimal frustration. This is just the “getting started” tool and certainly not the best or only one for  SMD hobby work. If you don’t have a lot of extra space or budget for the more advanced tools, then at least you can get a feel for it without investing too heavily. There is a long list of tools people use for working with surface mount components such as reflow ovens, hot plates, pick-n-place machines, microscopic cameras, suction pick-up pens, and on and on. I don’t have the space or budget for them, so I make do with the hot air gun and I recently added an inexpensive ($40) hot plate:

The reason I say that it’s easy (compared to through hole soldering), is that part placement or removal goes much quicker. Once solder paste is applied and components are in place, a few seconds under the hot air flow and you can solder the whole board at once. Removing parts is just as simple – blast them with hot air and they slide right off the board.

Component Choices

It’s useful to explain why I chose each specific component and size. I’ve been on a sort of mission for the last several years to have some useful knowledge about the entire electronics market – cost, capabilities, availability. I recently became aware of low cost RISC-V MCUs from and decided to try using them in some projects as a learning experience. With that as a starting point, the goals of the Pocket CO2 project were to keep BOM costs as low as possible and have a device that fits easily in tight jeans pockets. I generally looked for the smallest and least expensive parts for this project. Here’s a rundown of each component I chose and why:

MCU – CH32V003

The TSSOP20 version of this chip is relatively easy to solder (compared to the QFP/QFN), has plenty of exposed I/O and cost me about 17 cents each for Qty. 50. It has plenty of speed and enough internal RAM/FLASH to do quite a few tasks, so it seemed like a good choice. After writing the firmware, I’m hitting the 16K FLASH limit and would like to have more space, but 16K is the only choice for this chip. The next version of this device will move up to the 48 cent CH32V203.

Sensor – SCD40

I’ve tested Sensiron’s SCD40, SCD41 and a MH-Z19B. The SCD40 is the smallest and lowest cost true CO2 sensor I could find. There are a lot of tiny/cheap VOC (volatile organic compound) sensors that claim to report “eCO2” values. I wrote about these in another blog post. The SCD4x delivers reliable results, doesn’t use too much power and as a bonus, includes a temperature and humidity sensor. The only down side is the SMD footprint is unnecessarily difficult.

Display – SSD1306 128×64 OLED

This is my go-to display for several reasons: day/night readability, low cost, low power usage, fast display update, multiple suppliers, multiple color choices, and simple I2C communication. For this project, the breakout board version saved me some soldering headaches and was about the same price as the raw display panel. It also allowed me to reduce the 2D size of this project by having the display board sit on top of most of the other components.

Power Source – 3.7V LiPo Battery

I was hoping to run this board from a coin cell battery for improved safety. It’s not possible to run the SCD40 from a coin cell because it has brief power spikes up to 250mA. The internal resistance of disposable coin cells prevents them from sourcing that much current. LiPo batteries can handle huge current spikes without the voltage sagging. The average power use of the sensor can be under 1mA in low power mode (samples once every 30 seconds). I support this mode with a menu option called “low power mode”. In this mode, the display is off until you press a button and then it will show the data for 5 seconds and turn off again. I also reduced the default MCU clock from 48Mhz to 8Mhz; this allows it to consume only 1.8mA while running; RISC-V 32-bit @8Mhz is still plenty of speed to do the job. The OLED display uses only 2-4mA when lit because less than half of the pixels are on. In continuous mode (samples every 5 seconds), and the display lit constantly, it averages about 8mA of total current draw. A 200-400mAh battery will be a good size for this project.

3.3V LDO Regulator – WL9005S5-33R

LCSC had this part on sale for 3 cents when I bought them. It uses a common SOT23-5 footprint and has quiescent current that’s not too terrible. I don’t feel too bad about using a mediocre LDO for this project because the power switch completely disconnects the battery.

LiPo Charge Controller – TP4057

This chip is small, cheap and does the job of managing/protecting the charging of the battery from the USB 5V power. It only needs 1 resistor to set the maximum charge current and provides 2 LED outputs to indicate charging/charged.

The Rest

I think 0603 SMD parts are a good balance between “take up a small amount of board real estate” and “too small to see”. They’re also very affordable from sources like LCSC.

The components needed except for the 0603 LEDs, resistors and capacitors

Applying Solder Paste

This is where personal choice will probably guide how you do things. I use 60/40 tin/lead solder paste because it melts at a lower temperature and generally reacts well to the HASL (hot air solder leveling) finish I choose for my PCBs. Many of the SMD components have limited temperature tolerance, so reducing the solder melt temperature protects them from getting damaged. The SCD40 soldering instructions tell you to use a relatively low temperature and avoid hitting the permeable membrane on top.

The next choice is whether or not to use a stencil to apply the paste. I’ve successfully used stencils on some of my boards, but I’ve been going for minimum cost on my latest PCBs by skipping the stencil. I’ve gotten good results doing it by hand because I can control how much solder paste is applied. Too much paste can cause tiny pads to short together. I mix the paste with additional flux (it already has flux, but more is better). This makes it less viscous and easier to spread. I use solderless breadboard wire as a solder “paintbrush” to apply it to the PCB (see photo below).

Once the paste is applied, The components can be placed on the board with a tweezer. The more difficult ones are LEDs or diodes. They only work in one direction, so I test them with a 3V power source before placing them. It’s hard to see the polarity marker with the naked eye. I don’t have a microscope, so I use my phone camera at 3-10x zoom to see if all of the pins are lined up with the pads. 0603 resistors and capacitors can be skewed or off-center a little, but the micro-b USB socket and TSSOP20 footprint of the MCU need to be placed with high precision to not short or miss the tiny pins.

Baking / Reflow

Once the components have been placed on the board, they mostly stay in place because of the viscosity of the solder paste. There’s no hurry to bake the board because the paste doesn’t dry in air. For this build, I also use a hot plate and set it to 150C. It gets the solder close to its melting point, then I can blow hot air on each set of pins to melt the paste. You’ll see the solder paste go from dull to shiny when the solder melts. With the hot plate as a pre-heater, the melting occurs quickly. Without the hot plate, you need to keep the hot air blowing on the spot a bit longer to heat up the PCB first. Make sure you have a silicone rubber mat or other heat resistant surface as your work area. When everything has been melted, I let the hot plate cool down (it does this rather slowly), before removing the board. You probably noticed that I didn’t solder the SCD40 in place yet. If there’s a defect on the PCB or I messed something up badly, I don’t want to risk soldering an expensive part. It’s easy enough to solder just one additional part after everything checks out. If I have to remove the SCD40 to use on another board, it may get damaged in the process of soldering/de-soldering it multiple times.

Inspection / Pre-Power Testing

After the board cools, I use isopropyl alcohol to clean off excess flux. The soldered pins may not look very shiny even though the joint is soldered well. Touch each component to make sure it’s soldered down. Using less flux will get shinier results, but it won’t allow the solder to flow as easily towards the pads/pins. Next I visually inspect the board for any obvious shorts or problems. If there is excess solder, I can add a little flux to the spot and melt it with my fine tip soldering iron. I can usually get rid of little solder bridges this way. Once things all look good to the eye, then I use a continuity tester to make sure that GND/3V/5V are not shorted. I then proceed to test various connections on the board (e.g. GPIO pins to buttons). If everything looks good, then I solder on the 3-pin programming header and try to load firmware onto the CH32V003. Here’s what I found for this specific build:

– Program loaded successfully using the WCH-LinkE SWDIO programmer

– Running the code for the first time revealed that one of the indicator LEDs wasn’t working. The resistor next to it had one side not soldered well.

– Next, connected USB 5V to check the battery charging circuit. Neither charge nor ready LEDs lit. Again, the resistor next to them was not soldered well.

– After fixing the resistor with the soldering iron, charge+ready LEDs both light.

– Soldered PH2.0 connector, connected battery and checked current draw with low battery connected. I selected a max current of 300mA with a 3K resistor on the TP4057. The current meter showed 298mA; all is well.

– Placed the OLED breakout (unsoldered) into the pin sockets, powered up the board and the display showed the menu correctly. Nice :)

Conclusions so far: I should have used more solder paste on the resistors. A tiny dot of diluted paste wasn’t sufficient to make solid connections. Luckily the board isn’t that dense and I was able to reach the problems with my soldering iron without disturbing nearby parts.

Final Steps

Now that the main parts are tested, it’s time to attach the SCD40 and display. I’m using parts I recovered from an early version of the board; I damaged them a bit when removing them, so they have a slight burnt tinge. Some early attempts with the SCD40 (with stencil) failed to solder correctly. I believe the problem was too much solder and shorts forming underneath. The last few times I soldered it with much less solder and it succeeded. Here’s a photo of my solder paste application for the SCD40. Just a dot on each pad and a glob for the ground plane. You can see why I’m not pleased with Sensiron’s footprint – there are only 5 unique pins, the rest are no-connect / not used. A much simpler footprint could have been done with the same 5 connections and the same physical and thermal properties.

I use plenty of kapton tape when reworking a single part. This serves to block some of the heat from the parts I don’t want to re-flow. In the photo below, I’ve placed the SCD40 very carefully with a tweezer and surrounded the nearby components with tape. Now it’s ready to heat.

I set my heat gun for 280C. I didn’t want to use the hotplate because of the plastic parts on the bottom side. I overdid it a bit with the hot air. The soldering job was successful, but I toasted the top membrane a bit. I added masking tape to the back of the OLED PCB to make sure that the components don’t make electrical contact with anything on my PCB:

It works!

The differing pixel brightness is due to the OLED display framerate sync being different from my camera’s. It’s not easy to get good photos of OLED displays. However, the upper left corner of the display got slightly damaged when I desoldered it from the older board. The big metal piece sticking out of the USB socket is the magnetic coupling I like to use on all of my devices. Think of it like “magsafe” for everything. I found these magnetic USB cables over 3 years ago and have been very pleased with them. They’re reversible, have power+data and hold well.

Closing Thoughts

This project was and is still is a personal/family one; I didn’t conceive of it in the hopes of selling it. I like to share my personal projects as open source once they get to a stable/working state and if it’s useful, a blog post to go with it. I think this deserved some words written about it from the lessons I learned when building it and when I forget some of these details I can return here to be reminded. It was certainly satisfying to go from concept to design to working project with both hardware and firmware (making HW is quite new to me). I’m encouraged to try making more elaborate/complex projects in the future.

Things I like:

– The size is cute+practical

– It functions as I envisioned

– The vibration motor was a good addition that allows sight-free usage + a timer alert

– The battery life is good for its use case

– The BOM cost is low

– It’s not difficult to assemble

Thanks for reading to the end…

Read More