rpine lab Tech Blog

Tech blog covering a wide range of topics, including my hobby of programming (web and backend), setting up a home lab, and electronics projects using microcontrollers.

🧩Ordering a CH32V003 Expansion Board with JLCPCB's PCBA Service

Ordering a CH32V003 Expansion Board with JLCPCB's PCBA Service
Table of contents
🤖
This article was AI-translated. Some nuances may differ from the original Japanese version.
[PR]

JLCPCB provided a coupon for PCB fabrication and assembly for the production of this article.

JLCPCB

Image in a image block

JLCPCB is a company based in Shenzhen, China, that offers printed circuit board (PCB) manufacturing, assembly, and related services. With these services, even individuals can prototype electronic boards at a relatively low cost.

In a previous article, I ordered bare PCBs only from JLCPCB.

JLCPCB official site: https://jlcpcb.com/jp?from=rpinelab

Overview of the Expansion Board

I used JLCPCB's PCB assembly service (PCB Assembly, PCBA) to build an expansion board for the CH32V003 prototype board covered in the previous article.

To try out the built-in peripherals of the CH32V003 microcontroller (I2C, timers, ADC), I packed sensors, a rotary encoder, and other parts onto a single board.

The expansion board in KiCad's 3D viewer
The expansion board in KiCad's 3D viewer

Features

  • Pin sockets for plugging in the CH32V003 prototype board (the one built in the previous article)
  • External power input (DC jack and screw terminal block)
  • DC-DC converter with a 5 V output
  • I2C temperature and humidity sensor (AHT30) and 6DoF IMU (LSM6DS3TR-C)
  • Socket for an I2C OLED display module
  • 5 RGB LEDs (WS2812B)
  • Rotary encoder (with push switch)
  • Piezo speaker
  • R/C servo motor connector
  • External supply voltage monitoring (ADC)
  • General-purpose pin (AUX)
  • Mounting holes for M3 screws

Pin Assignment

PinFunctionConnected to
PA1GPIO / ADCGeneral-purpose pin (AUX)
PA2ADCExternal supply voltage monitoring
PC0TIM2 CH3RC servo
PC1, PC2I2C (SDA, SCL)Temperature and humidity sensor, IMU, OLED
PC3GPIO (external interrupt)IMU INT1
PC4, PC7TIM1 CH1, CH2Encoder phase A, phase B
PC5GPIOEncoder push switch
PC6SPI MOSIRGB LEDs
PD6TIM2 CH3 (remapped)Piezo speaker

The RC servo and the piezo speaker use the same TIM2 channel (CH3), so only one of them can be used at a time.

Note that on the boards I actually received, a footprint mistake swapped the connections of PC4 and PC5 (encoder phase A and the push switch). (Described later in the testing section.)

Circuit Design

Software Used

  • KiCad 10.0
  • KiCAD JLCPCB tools 2026.04.03: a KiCad plugin that outputs production files for JLCPCB

Power Supply

Power supply circuit
Power supply circuit

External power comes in through the DC jack or the screw terminal and is protected against reverse connection by a P-channel MOSFET. From there, a synchronous DC-DC converter (AP63205WU, fixed 5 V output) generates 5 V.

A jumper selects whether the 5 V used by the servo and the RGB LEDs on the board comes from the external supply or from USB. So that the prototype board also runs from the external supply alone, 5 V is fed to the prototype board's VBUS through a Schottky diode.

I2C Sensors and Display

The temperature and humidity sensor (AHT30), the 6DoF IMU (LSM6DS3TR-C), and the OLED module (SSD1306-based) are connected to the same I2C bus. They are powered from the prototype board's +3.3 V supply, so all I2C signal levels are 3.3 V. 10 kΩ pull-up resistors are fitted.

🌏
The OLED module I used is sold by Akizuki Denshi, an electronics parts shop in Japan (product page, in Japanese).

According to the datasheet of the temperature and humidity sensor (AHT30), cutting out the board around the IC is recommended so that heat conduction does not affect the reading and the surrounding environment is measured correctly. Drawing a closed outline on the Edge.Cuts layer, the same layer used for the board outline, makes that area get routed out by CNC.

Looking at the delivered boards, some traces ran quite close to the edge of the cutout. Next time I will leave a little more clearance between traces and the routed edge.

The cutout drawn on the Edge.Cuts layer
The cutout drawn on the Edge.Cuts layer

RGB LEDs

Circuit around the RGB LEDs
Circuit around the RGB LEDs

Five WS2812B LEDs are daisy-chained. They are powered from 5 V, but the data signal is fed in at 3.3 V as is. (The WS2812B-V6 I selected for assembly accepts a 3.3 V input.) The data line has a series resistor (330 Ω) and a pull-down resistor (100 kΩ), plus an LED for confirming that a signal is being output.

Rotary Encoder

Circuit around the rotary encoder
Circuit around the rotary encoder

I used a surface-mount encoder (EC11J1525402) and read phases A and B with TIM1 in encoder mode. Phase A, phase B, and the push switch each have a debounce circuit made of a resistor and a capacitor.

Piezo Speaker and RC Servo

Circuit around the piezo speaker and RC servo
Circuit around the piezo speaker and RC servo

The piezo speaker is driven directly from a microcontroller pin through a series resistor (1 kΩ).

For the RC servo there is a 3-pin header, with a series resistor (330 Ω) on the signal line and a 10 µF capacitor on the supply. Just in case, an electrolytic capacitor can be added to the supply later.

External Supply Voltage Monitoring

Voltage divider
Voltage divider

The external supply voltage is divided by 100 kΩ and 22 kΩ and measured with the ADC on PA2. A 100 nF capacitor is also placed there for smoothing.

Vmon=22 kΩ100 kΩ+22 kΩVextV_{\rm mon} = \frac{22\ \rm k\Omega}{100\ \rm k\Omega + 22\ \rm k\Omega} V_{\rm ext}

With this divider ratio, the ADC input voltage reaches 3.3 V (the upper limit) when the external supply is 18.3 V.

Board Layout

Board layout
Board layout

Component Placement

The board has two layers, with components grouped by function. All surface-mount parts are on the top side, so PCBA assembly is needed on one side only.

Routing

Power traces (+5 V and +3.3 V) are 1 mm wide, and the other signal traces are 0.25 mm. The board has room to spare, so routing was not difficult. For GND, ground pours cover both sides. (The fill is hidden in the image.) I placed plenty of vias so that no part of the ground pour is left isolated.

Silkscreen

Next to each part I printed its function name and the name of the microcontroller pin it connects to. When writing a program, the pins can be identified without opening the pin assignment table.

Selecting Parts for PCBA

Parts used for PCBA have to be chosen from the JLCPCB parts library, so check which parts are available at the very start of the design.

JLCPCB's PCBA comes in two types, Economic and Standard, and some parts are supported only by Standard PCBA. The LSM6DS3TR-C and AHT30 used here are such parts, so I selected parts on the assumption of ordering Standard PCBA.

With Standard PCBA, a feeder loading fee is charged for each type of part to be assembled. (Reference: PCB Assembly Cost: What Does the Price Include? - JLCPCB) Parts are classified as Basic (common parts such as chip resistors and MLCCs) or Extended (the large majority of other parts), but with Standard PCBA the fee applies to both in the same way.

For resistors and small-value capacitors, I chose Basic parts in the 0402 size (1005 metric). There are so many candidates for common parts like these that narrowing them down is tedious, so unless there is a particular reason, choosing from the Basic parts is fine. On boards I plan to assemble by hand I mainly use the 0603 size (1608 metric), but since this is PCBA I went for the smaller size without worrying about it. For the large-value capacitors used around the power supply and elsewhere, I picked larger sizes (0805 and 1206) from the Basic parts as appropriate, taking DC bias into account.

For the remaining parts, choosing ones with relatively large stock and a low unit price should be fine.

Saving Cost by Combining with Hand Assembly

This time I had all surface-mount parts assembled by PCBA, but another option is to keep the cost down by hand-assembling some parts, such as those supported only by Standard PCBA.

With the other type, Economic PCBA, no loading fee is charged for Basic and Promotional Extended parts. (Reference: PCB Assembly FAQs - JLCPCB) However, parts supported only by Standard PCBA cannot be assembled.

Pros:

  • Ordering Economic PCBA greatly reduces the assembly cost
  • The fewer part types you have assembled, the lower the loading fees

Cons:

  • Parts for hand assembly have to be bought separately, from DigiKey for example, if you don't have them on hand
  • ICs with terminals on the underside and similar parts are hard to add afterwards by hand soldering (reflowing them yourself is an option)

Note that resistors and capacitors, which are used in large numbers, incur no loading fee even with Economic PCBA if chosen from the Basic parts, so they can be left to PCBA as they are. Only the parts used in small numbers need to be hand-assembled.

On this board, the parts supported only by Standard PCBA (LSM6DS3TR-C and AHT30) happened to be exactly the parts that are hard to hand solder, so I did not take this approach.

Preparing the Production Files

Installing the Plugin

The production files are prepared with the KiCad plugin KiCAD JLCPCB tools.

  1. Open the Plugin and Content Manager from the KiCad start screen
  2. Click "Manage…" on the repository tab and add the following URL as a repository
    https://raw.githubusercontent.com/Bouni/bouni-kicad-repository/main/repository.json
  3. Select the added repository and install KiCAD JLCPCB tools from the list

For details such as installing with git, see the README of the repository.

Assigning Parts with KiCAD JLCPCB tools

Using the KiCAD JLCPCB tools plugin, assign a JLCPCB part number (a number starting with C) to each component.

A JLCPCB icon is added to the toolbar of the PCB editor; clicking it opens the part assignment screen below. The plugin can search the JLCPCB parts library and also shows the stock quantity and the Basic/Extended classification.

Main screen of KiCAD JLCPCB tools (assignment status of each component)
Main screen of KiCAD JLCPCB tools (assignment status of each component)

If the component value (for resistors, the resistance without the ohm unit, such as 47k; for capacitors, the capacitance including the farad (F) unit, such as 100nF) and the footprint size are set in the schematic beforehand, suitable search keywords are filled in automatically on the assignment screen, which speeds up the work. For other components too, the value is entered automatically as the search keyword, so setting the part name as the value makes assignment more efficient.

Assignment screen for a chip resistor (value set to "1k" and footprint set to a 0402 resistor footprint)
Assignment screen for a chip resistor (value set to "1k" and footprint set to a 0402 resistor footprint)

Excluding Hand-Soldered Parts

Through-hole parts to be hand soldered and parts that will not be fitted are excluded from both the BOM and the POS (component positions) in the plugin.

Generating the Production Files

Pressing the Generate button in the plugin outputs the three files needed for the order, the Gerber files (ZIP), the BOM (CSV), and the CPL (CSV), into the jlcpcb/production_files folder of the KiCad project.

Ordering PCBA

Uploading the Gerber files and setting the PCB specifications are the same as in the previous article, so this section covers the steps specific to PCBA.

The only PCB specification I changed this time was the board color, from the default green to blue.

🌏
The screenshots of the JLCPCB site in this article show the Japanese version of the site. The item names in the English UI may differ slightly from the wording used here.

PCBA Settings

Enable "PCB Assembly" below the PCB specifications and set the PCBA type, the assembly side, and the quantity. I chose Standard PCBA, top side only.

As for the quantity, the minimum for PCB fabrication is 5 boards, but for PCBA you can choose from 2. This is an evaluation board purely for my own use and I don't need 5 finished boards, so I set the PCBA quantity to 2. In that case, the remaining 3 boards are delivered unassembled together with the assembled ones.

PCB Assembly settings
PCB Assembly settings

Uploading the BOM and Placement Data

Upload the BOM and CPL files output by the plugin. After uploading, the part matching results are displayed.

BOM and CPL upload screen
BOM and CPL upload screen

I had included "eval", for evaluation board, in the KiCad project name, and at upload I got an error saying that the file name contains "eval".

As a quick fix, the output file names can be changed by hand, but since I may regenerate the production files many times from now on, in the end I dealt with it by changing the KiCad project name (eval → evl).

Checking Component Placement

Check positions and orientations in the preview that shows the parts placed on the board. Any part with the wrong orientation needs to be corrected. Pay attention to the pin 1 position and polarity marked in pink, and to how the pads line up with the IC leads. Corrections are especially likely to be needed when you use footprints you made yourself.

Parts can also be corrected individually on this preview screen, but those corrections are lost if you redo the quote for the board, so fix them with corrections in KiCAD JLCPCB tools and upload again.

Checking rotation in the placement preview (Q1 in the center and U3 at the top right are rotated incorrectly)
Checking rotation in the placement preview (Q1 in the center and U3 at the top right are rotated incorrectly)
Checking diode polarity (+ is the anode and - is the cathode; these are correct)
Checking diode polarity (+ is the anode and - is the cathode; these are correct)
  1. Open the part assignment screen of KiCAD JLCPCB tools again, and in the right-click menu of the part whose rotation you want to fix, click one of "Add Correction by name / reference / package". These apply the correction to parts with a matching part name (value), reference, or package name, respectively.
    Image in a image block
  2. Enter 90, 270, 180, or another value in Rotation according to the angle you want to correct, and click "Save".
    Image in a image block
  3. After correcting all the parts, generate the production files again and re-upload the CPL file with the BOM/CPL upload button on the bill of materials tab.
    Confirming that the orientation is now correct
    Confirming that the orientation is now correct
Component placement preview (after correcting the orientations)
Component placement preview (after correcting the orientations)

Quote and Order

Check the price breakdown, select a product description, and save to the cart. For the product description I selected "DIY Hobby Circuit Board".

This time the PCB was $9.30 and Standard PCBA was $97.78. The setup fee ($25.75) and the feeder loading fee ($38.75) make up a large share of the PCBA price.

Price breakdown and product description selection
Price breakdown and product description selection
Cart screen
Cart screen

After Ordering

Additional Option

Notice about Bake Components (quote screen)
Notice about Bake Components (quote screen)

When I got to the quote screen, a notice said that the Bake Components option would be required for one of the parts used, the RGB LED (WS2812B).

Parts listed with an MSL Level of 5 or higher in the parts library require baking (Bake Components) as a rule
Parts listed with an MSL Level of 5 or higher in the parts library require baking (Bake Components) as a rule

The additional fee is fixed only after the post-order review is finished, so it was not included in the quoted amount at the time of ordering.

Some days later I received an email saying that the review of the additional option was complete. Following the instructions, I paid the additional fee ($7.94, as estimated beforehand) from the order history screen.

Query Email About PCBA

I received a query email about the placement of some parts. It asked me to tell them the correct orientation of the piezo speaker and the WS2812B.

The piezo speaker has no polarity, but it does have an orientation because of the direction of the opening where the sound comes out. The silkscreen was just a plain rectangle and the orientation was unclear, which I think is why they asked.

For the WS2812B, the KiCad library footprint already marks pin 1 and the notch position on the silkscreen, so there should be no mistake, but they asked anyway.

When placing parts with polarity (orientation), a silkscreen that makes the orientation clear should save you the trouble of answering follow-up questions.

X-ray Inspection Images

Before shipping, I received an email saying that the X-ray inspection results were available. Checking the order history, there were inspection images for the 2 boards sent to PCBA assembly, which I assume are from the final PCBA inspection.

X-ray inspection image
X-ray inspection image

The Delivered Boards

The boards arrived about 7 days after ordering. The cardboard box contained 2 assembled boards and 3 unassembled boards, wrapped in cushioning material.

The box as delivered
The box as delivered

Checking the Assembled Boards

Unassembled board
Unassembled board
Assembled board
Assembled board

The boards arrived with all surface-mount parts assembled. At a glance, the assembly looks fine.

As also noted on the quote screen, tabs for PCBA production are added at both ends. They are V-scored, so they can be snapped off easily with needle-nose pliers or similar.

Fitting Parts by Hand Soldering

The board mounted on a PCB holder stand
The board mounted on a PCB holder stand

Most parts were already assembled by PCBA, and only the remaining through-hole parts are hand-assembled.

Parts I hand-assembled:

  • DC jack (external power)
  • Pin sockets (for the existing microcontroller prototype board and the I2C OLED module)
  • Pin headers (for the servo, AUX, and the 5 V source selection jumper)

Parts I left unfitted:

  • Terminal block: power can be supplied through the DC jack
  • Electrolytic capacitor: not fitted until it is needed

To make soldering easier, I tried out a PCB holder stand. As in the photo, it clamps the board in place and lets you rotate it between front and back. The stand itself is made of metal and fairly heavy, so the work was stable.

With the through-hole parts fitted
With the through-hole parts fitted

Testing

After a simple continuity check with a multimeter, I used a DP100 (a portable variable power supply that runs from USB PD) to apply 7.2 V (assuming a 2-cell Li-Po battery) to the external power terminal and confirmed that the DC-DC converter outputs 5 V.

Running the test program
Running the test program

Next, I plugged the prototype board and the OLED module into the pin sockets and flashed a test program. I first wanted to see whether the assembled parts work, so I had Claude Code write the program from the pin assignment table. The framework is ch32fun.

The RGB LEDs, the I2C sensors (IMU and temperature and humidity sensor), and the piezo speaker assembled by PCBA all worked.

The encoder, however, behaved strangely, so I checked the circuit in KiCad and found a pin assignment mistake. When I made the KiCad footprint for the prototype board myself, I apparently got the pin numbering order of the pin sockets wrong, and pins 10 and 11 were reversed. The pin numbers on the schematic side are of course correct, so the signals assigned to those pins, encoder phase A and the push switch, ended up routed to each other's pins.

I plan to count the encoder with the TIM1 peripheral, but the pin it was swapped onto has no timer channel assigned, so swapping them in software is difficult.

Fortunately there are series resistors for the debounce circuits, so the signals can probably be swapped by running enameled wire from the resistor pads, without cutting any traces. (I am putting the fix off until I finish experimenting with the other functions.)

Pins 10 and 11 are in reversed order
Pins 10 and 11 are in reversed order

Another thing I noticed during testing was a high-pitched noise coming from the circuit while the program was running. The source is probably the DC-DC converter, but its switching frequency is 1.1 MHz, which by simple reasoning should be outside the audible range. From what I found, when the converter switches to a mode meant to keep the conversion efficiency from dropping at light load, the effective switching frequency falls into the audible range and the inductor and capacitors can make noise.

This time, with driving a servo motor in mind, I had chosen a DC-DC converter with headroom in its maximum current (2 A continuous). As a result, when the load current is small, as it was during testing, it appears to switch to PFM mode (variable-frequency mode).

References (in Japanese):

Impressions of JLCPCB's PCBA

What Went Well

  • Parts in packages that are hard to hand solder, such as LGA, arrive already assembled
  • The PCBA quantity can be smaller than the number of boards, which makes it easy to build just a few for evaluation
  • With the KiCad plugin, preparing the production files, including part assignment, takes little effort

Things to Watch Out for

  • If the KiCad project name (the production file name) contains "eval", the upload fails with an error
  • The fee for the additional option (Bake Components) is not fixed until the post-order review is finished, so it is paid afterwards
  • You may be asked about part orientation, so use a silkscreen that makes the orientation clear

Summary

I built an expansion board for the CH32V003 prototype board using JLCPCB's PCBA. I confirmed the 5 V output of the DC-DC converter and got the RGB LEDs, the temperature and humidity sensor, the IMU, and the piezo speaker working. For the encoder, pins 10 and 11 were reversed in my self-made footprint, so the wiring still needs to be fixed.

I plan to cover how to use each function on the expansion board in separate articles.

References

If you found this article helpful, please consider supporting me!