UIAPduino Pro Micro CH32V003 V1.4General Availability
Overview
- Adopt CH32V003 Running at 48 MHz, And Support Coding in Arduino IDE.
- Is Supplied Power and Written Program with Single USB Type-C.
- Act as a USB 2.0 Low-speed Device, Which Means the HID Device Can Be Made.
- Protect Your USB Port Powerfully by On-Board Fuses.
- Has Selectable Power Supply from 3.3 V or 5 V for the Microcontroller.
- Can Be Connected by H: 2.0 mm / P: 2.54 mm ConthroughⓇ when CN2 Is Not Mounted.
- Can Be Mounted Like a Surface-Mount Device, Because of Flat Bottom.
- Is Open-Source Software and Open-Source Hardware.
- Is RoHS Compliant , Designed in Japan and Lifetime Warranty.
Getting Started
Never plug the board into a USB port until instructed to do so to reduce the risk of a short circuit.
Let's write the program (sketch) to blink the LED and confirm that the LED blinks on the board.
Verified Environment
- OS: Windows 10 / Windows 11 / Ubuntu 22.04 LTS / Ubuntu 24.04 LTS
- USB Host: USB 2.0 Type-A / USB 3.2 Type-C
- Arduino IDE: 2.3.2 / 2.3.3 / 2.3.4
Windows
Board Adding and Sketch Writing
Start Arduino IDE and add https://github.com/YuukiUmeta-UIAP/board_manager_files/raw/main/package_uiap.jp_index.json
to Preference -> Additional boards manager URLs. Search for uiap
on Tool -> Board -> Boards Manager and install UIAPduino
.
Select to Tool -> Board -> UIAPduino -> Pro Micro CH32V003. All other settings are default. Open the example sketch that blinks an LED on File -> Examples -> 01.Basics -> Blink and add #define LED_BUILTIN 2
before setup()
.
// Define on board LED pin before setup()
#define LED_BUILTIN 2
// the setup function runs once when you press reset or power the board
void setup() {
...
While pressing the reset button, connect the board to a USB port of your computer and then immediately release the reset button. After waiting for the device to be set up, write the sketch by using Upload
button in the Arduino IDE. When the message Image written.
is displayed, writing is complete.
Even on the same computer, writing may be unable from some USB ports. If writing is unable, try using a different USB port. Also, Dedicated USB cable for power supply cannot write and communicate.
Check Working
There are 3 ways to run the program: A, B, or C.
- Press the reset button after writing.
- Connect to a USB port without pressing the reset button.
- Connect to a commercially available USB charger (AC adapter).
When the orange diode in the center of the board turns on and off repeatedly every second during any one of the steps, it is working properly. To Re-write the program, it needs to disconnect the board from the USB port and hold the reset button while replugging it to a USB port.
There is also a way to switch operating modes without replugging into a USB port: Seamless Switch
Linux
Follow the same operation as for Windows, and after installing the UIAPduino board, run the following command. Note that writing from Arch Linux is unstable.
# Do this command after UIAPduino board was installed.
sudo ln -s ~/.arduino15/packages/UIAP/tools/minichlink-2982dfd/1.0.0/99-minichlink.rules /etc/udev/rules.d/99-minichlink.rules
# Reboot or do this command if needed.
sudo udevadm control --reload-rules
If you can't write due to minichlink, build it for your environment and replace to ~/.arduino15/packages/UIAP/tools/minichlink-2982dfd/1.0.0/minichlink
.
Documents
Pinout Diagram
Refer to variant_CH32V003F4.h and variant_CH32V003F4.cpp for the definition of port names in Arduino IDE.
Knowledge
Factory DefaultDraft
The custom bootloader (source code / binary file) based on cnlohr/rv003usb is written. This is for timeout adjustment, Seamless-Switch support, and product identification. Also, a user program is written that lights up the orange diode in the center of the board like a candle.
Seamless SwitchDraft
It switches between the write standby mode and the program execution mode without replugging into a USB port (Seamless-Switch).
Via the Reset Button
When 3 lines code are inserted into setup()
of sketch, the function of the reset button alternates from "RESET" to "Seamless-Switch".
// the setup function runs once when you press reset or power the board
void setup() {
if (FLASH->STATR & (1<<14)) NVIC_SystemReset();
SystemReset_StartMode(Start_Mode_BOOT);
pinMode(PD4, OUTPUT);
...
Anti Dazzling
The LEDs may be dazzling in a bedroom at night, etc. The LEDs inside the board can be turned off by cutting the jump pads.
Function | Color | Schematic | Jump Pad | Description |
---|---|---|---|---|
Power on | Blue | LED1 | CUT1 | |
USB signal | Orange | LED2 | CUT2 | NOT be unwritable if cut. |
Builtin LED | Orange | LED3 | CUT3 | Be high impedance if cut. |
Application Example
WS2812B Lighting
DS18x20 Temp. Sensing
- https://github.com/invariablyafk/CH32V-OneWire-Temperature-Example
- https://github.com/cnlohr/rv003usb/tree/master/testing/cdc_exp
The code must be customized that allows sensing temperatures and sending messages at the same time.
Using Arduino Library
This is the Arduino library that worked and the sketch when worked.
SevSeg
Show Arduino Sketch
#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment object
void setup() {
byte numDigits = 1;
byte digitPins[] = {1};
byte segmentPins[] = {3, 4, 2, 5, 9, 7, 8, 10};
bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_ANODE; // See README.md for options
bool updateWithDelays = false; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros, disableDecPoint);
}
void loop() {
sevseg.blank();
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(0, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(1, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(2, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(3, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(4, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(5, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(6, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(7, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(8, 0);
sevseg.refreshDisplay();
delay(1000);
sevseg.setNumber(9, 0);
sevseg.refreshDisplay();
delay(1000);
}
Reference
CH32V003
- 32-bit general-purpose RISC-V MCU-CH32V003 - NanjingQinhengMicroelectronics
- GitHub - openwch/ch32v003: CH32V003 is an ultra-cheap RISC-V MCU with 2KB SRAM, 16KB flash, and up to 18 GPIOs that sells for under $0.10
Tips
- 20円マイコン RISC-V CH32V003とは #RISC-V - Qiita
- WCH社のRISC-V搭載CH32シリーズまとめ | Lang-ship
- CH32V003 - fab-wiki
- CH32V003 – inajobのいろいろレビュー
- #29- How to RESET CH32V003 if PD1 is Occupied? - YouTube
- CH32V003J4M6 PD1 SWIO ピン共用問題 Flash eraseでの解決方法 - 宅配おもちゃ病院
- CH32V003 warning - Don't leave SWIO/PD1 floating!
- Help: Reset to bootloader by software or hardware button · Issue #52 · cnlohr/rv003usb
DIY
- Arduino IDE で安価なRISC-VマイコンCH32V003のデジタル出力を試してみた | P.T.A.55
- CH32V003で、UARTで書き込みできるブートローダを書き込んで利用する - @74thの制作ログ
- 40円マイコンCH32V003で、Auto-wakeup(AWU)を使って省電力な動かし方をしてみる #組込み - Qiita
- GitHub - shippoiincho/ch32v003examples: CH32V003 test programs
Development Stack
With USB
With Arduino IDE
- GitHub - openwch/arduino_core_ch32: Core library for CH32duino
- 40円RISC-Vマイコン(CH32V003)をArduino IDEでLチカをしてみました | きょうのかんぱぱ
- 激安RISC-VチップCH32V003を動かす | ELSPINA VEINZ TECH BLOG
- Arduino環境でnanoCH32V003開発ボードを使う | たまねぎブログ
- Arduino環境でBTE32-15(CH32V003)開発ボードを使う | たまねぎブログ
- Clock selection using Arduino IDE menu · Issue #27 · openwch/arduino_core_ch32
- Arduinoでコードからリセットをする方法
With Rust
Pro Micro
- Pro Microとそのバリエーション
- Arduino互換ボード「Pro Micro」の情報まとめ #Arduino - Qiita
- Pro Micro - 5V/16MHz - DEV-12640 - SparkFun Electronics
- SparkFun Qwiic Pro Micro - USB-C (ATmega32U4) - DEV-15795 - SparkFun Electronics
- Qwiic Connect System - SparkFun Electronics
USB
- Document Library | USB-IF
- USB Cheat Sheet
- はじめてのUSB [USB発展の歴史と基礎知識] | テクニカルスクエア | 丸文株式会社
- パケットのフォーマットからプロトコルの詳細まで
- USBの通信プロトコル
- USB Type-C コネクタに必要な終端抵抗 – Community Translated (JA... - Infineon Developer Community
- Replacing Standard USB 3.0/2.0 Connector with Type... - Infineon Developer Community
- pcb - How to connect USB Connector shield? - Electrical Engineering Stack Exchange
- 01signal: Resetting a USB device on Linux (and maybe control its power supply)
Previous Version
Thank You for
Review
- Yutaro Hiyoshi
- Masashi Yokota
- Yuta Suzuki
Suggestion
- Masashi Sasaki
- Kojo Kimura
- Tomoyuki Dansako