Parts

CH340G USB to serial chip: pinout, the 12 MHz crystal, 5 V or 3.3 V wiring, and the CH340C

By

The CH340G is WCH's USB to serial chip in a 16-pin SOP. Pin 16 is VCC, pin 1 is ground, pin 2 is TXD and pin 3 is RXD. Pins 5 and 6 go straight to the USB D+ and D− lines, and a 12 MHz crystal sits across pins 7 and 8. Pin 4, V3, is the one people get wrong: on 5 V it takes a 0.1 µF capacitor to ground, and on 3.3 V it is tied to VCC.

This page covers the two ways to power it, its logic levels against a 3.3 V ESP32, a worked wiring with every margin checked, a divider for when the chip has to stay on 5 V, and the crystal-free CH340C, which shares the footprint. All the figures come from WCH's CH340 datasheet, version 3D; WCH is the only maker.

Datasheet: WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340 (PDF)

Advertisement

Pinout by package

CH340G SOP-16 · WCH1=GND 2=TXD 3=RXD 4=V3 5=UD+ 6=UD− 7=XI 8=XO 9=CTS# 10=DSR# 11=RI# 12=DCD# 13=DTR# 14=RTS# 15=R232 16=VCC
top view, notch upCH340G116GNDVCC215TXDR232314RXDRTS#413V3DTR#512UD+DCD#611UD−RI#710XIDSR#89XOCTS#

Top view, pin 1 at the dot. 3.9 mm body, 1.27 mm pin pitch.

Unused I/O pins may be left open (p. 4 note).

Source: WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 2 (Section 3, package table: CH340G in SOP-16, 3.9 mm, 1.27 mm pitch); WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 3 (Section 4, pin table, SOP16 column: VCC 16, GND 1, V3 4, XI 7, XO 8, UD+ 5, UD− 6, TXD 2, RXD 3, CTS# 9, DSR# 10, RI# 11); WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 4 (pin table continued: DCD# 12, DTR# 13, RTS# 14, R232 15)

CH340C SOP-16 · WCH1=GND 2=TXD 3=RXD 4=V3 5=UD+ 6=UD− 7=NC 8=OUT# 9=CTS# 10=DSR# 11=RI# 12=DCD# 13=DTR# 14=RTS# 15=R232 16=VCC
top view, notch upCH340C116GNDVCC215TXDR232314RXDRTS#413V3DTR#512UD+DCD#611UD−RI#710NCDSR#89OUT#CTS#

Top view, pin 1 at the dot. Same footprint as the CH340G; only pins 7 and 8 differ.

Lots whose number starts with 4 have 5 V tolerant I/O (p. 5).

Source: WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 2 (package table: CH340C in SOP-16; note that CH340C has a built-in clock and needs no crystal); WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 3 (pin table: CH340C pin 7 empty, must be left open; pin 8 OUT#); WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 6 (Section 5.3: on lots starting with 4 and above B40, a 4.7 kΩ pull-down turns pin 8 into a second DTR#)

Which one do you have?

The CH340 is a family. The CH340G and CH340C are the two in SOP-16 that you find on Arduino Nano and Uno clones, ESP8266 and ESP32 boards and USB to TTL adapters. WCH also makes the CH340B (SOP-16, internal clock and EEPROM), the CH340N (SOP-8), the CH340K (ESSOP-10), the CH340E and CH340X (MSOP-10) and the CH340T (SSOP-20); their pin numbers differ, so check the marking before you follow a pinout.

On a board, a CH340G always has a 12 MHz crystal, usually a silver HC-49 can, right next to it. No crystal means a CH340C or one of the other clock-free versions. All of them use the same CH341 driver on the computer side.

CH340C: the same chip without the crystal

The CH340C has a built-in clock. Its footprint and pinout match the CH340G except pins 7 and 8: pin 7 is an empty pin that must be left open, and pin 8 is OUT#, a modem output. On lots whose number starts with 4 and ends above B40, a 4.7 kΩ pull-down on pin 8 turns it into a second DTR# for boards that need both a reset and a boot line.

PinCH340GCH340COn the board7XINCG: 12 MHz crystal + 33 pF to GNDC: leave open8XOOUT#G: crystal + 33 pF to GNDC: modem output, or a second DTR#Pins 1 to 6 and 9 to 16 are the same on both
Figure 1. Only pins 7 and 8 differ. A CH340C fits a CH340G footprint once the crystal and its two capacitors are left off.

The internal clock is looser. WCH puts the CH340C's transmit baud error below 1.8 %, against 0.3 % for the crystal-driven CH340G, and rates it from −20 to 70 °C instead of −40 to 85 °C. The CH340C also draws less in USB suspend.

Absolute maximum ratings and supply range

The supply may go to 6.0 V absolute, and no pin may sit more than 0.5 V above VCC. That second limit is the one that bites: a CH340 running from 3.3 V must not see 5 V on RXD or on any modem input, except on the newer lots of the CH340C, CH340N and CH340X that WCH calls 5 V tolerant.

Absolute maximum and operating ranges, from WCH's CH340 datasheet V3D
ParameterCH340GSOP-16CH340CSOP-16
Supply voltage, absolute maximum VCC−0.5 to 6.0 V−0.5 to 6.0 V
Voltage on any I/O pin VIO−0.5 V to VCC + 0.5 V−0.5 V to VCC + 0.5 V
Operating temperature TA−40 to 85 °C−20 to 70 °C
Storage temperature TS−55 to 125 °C−55 to 125 °C
Supply, 5 V operation VCCV3 on a capacitor only4.0 to 5.3 V4.0 to 5.3 V
Supply, 3.3 V operation VCCV3 tied to VCC2.9 to 3.6 V3.1 to 3.6 V

In 5 V operation VCC runs from 4.0 to 5.3 V, which covers USB's 5 V bus. In 3.3 V operation the CH340G accepts 2.9 to 3.6 V and the CH340C 3.1 to 3.6 V. Design to the CH340C's floor if the board might be built with either.

Supply current, logic levels and the clock

At 25 °C (min/max unless marked typical)
ParameterCH340GSOP-16CH340CSOP-16
Supply current, operating ICCVCC = 5 V7 mA typ, 20 mA max7 mA typ, 20 mA max
Supply current, operating ICCVCC = 3.3 V4 mA typ, 12 mA max4 mA typ, 12 mA max
Supply current, USB suspended ISLPVCC = 5 V0.09 mA typ, 0.2 mA max0.05 mA typ, 0.15 mA max
Input high, min / input low, max VIH / VILVCC = 5 V2.3 V / 0.9 V2.3 V / 0.9 V
Input high, min / input low, max VIH / VILVCC = 3.3 V1.9 V / 0.8 V1.9 V / 0.8 V
Output high, min VOH2 mA outVCC − 0.6 VVCC − 0.6 V
Output low, max VOL6 mA in (5 V), 4 mA in (3.3 V)0.5 V0.5 V
Clock12 MHz crystal, 11.98 to 12.02 MHzinternal, ±1.2 % (−5 to 55 °C), ±1.8 % (−25 to 75 °C)
Transmit baud-rate errorbelow 0.3 %below 1.8 %
Baud rate50 bps to 2 Mbps50 bps to 2 Mbps

V3 is the chip's internal 3.3 V node. From 5 V the chip makes that node itself and V3 only needs its 100 nF capacitor; from 3.3 V the supply already is 3.3 V, so V3 is joined to VCC. Either way VCC gets its own 100 nF at the pin.

5 V supply5 VCH34016 VCC4 V31 GND100 nF100 nF onlyGND3.3 V supply3.3 VCH34016 VCC4 V31 GND100 nFV3 = VCCGND
Figure 2. V3 on its own capacitor for 5 V, tied to VCC for 3.3 V. Ground is pin 1 in both.

It is a light load: 7 mA typical and 20 mA at most from 5 V (100 mW worst case), 4 mA and 12 mA from 3.3 V (39.6 mW). The outputs guarantee VCC − 0.6 V high and 0.5 V low, and an input reads high above 2.3 V on 5 V or 1.9 V on 3.3 V.

The clock decides the baud rate. A UART receiver samples each bit near its middle, and WCH says the CH340 receiver copes with about 2 % of rate error. The crystal-driven CH340G transmits within 0.3 %, leaving 1.7 points for the other end; the CH340C's 1.8 % leaves only 0.2.

CH340G< 0.3 %CH340C< 1.8 %receiver tolerance about 2 %
Figure 3. Transmit error against the receiver's tolerance. A microcontroller on an internal RC clock adds its own error to the CH340C's.

What it is good for

  • Programming and talking to a microcontroller over USB: Arduino clones, ESP8266 and ESP32 boards, STM32 with a serial bootloader.
  • A USB to TTL serial adapter for a GPS module, a Bluetooth module or a router's debug header.
  • USB to RS232 or RS485, with a MAX232-type level shifter or an RS485 transceiver after it (WCH's sheet shows both).
  • Automatic reset and boot-mode entry: DTR# and RTS# are outputs the computer controls, so a download tool can reset a board and put it in bootloader mode with no buttons.

It is a poor choice above about 1 Mbps one way or 500 kbps both ways: WCH itself points those jobs to its CH343, which has hardware flow control. Its USB is full speed only.

Worked example: a CH340G for a 3.3 V ESP32

A home-made programming board for an ESP32 module: USB in, a CH340G, and the ESP32's UART0. The ESP32's pins are 3.3 V only (3.6 V at most on an input), so the simplest plan is to run the CH340G from the same 3.3 V rail.

1. Power. USB's 5 V feeds a 3.3 V regulator such as the AMS1117-3.3. Its output goes to VCC (pin 16) and V3 (pin 4) together, with 100 nF from pin 16 to pin 1 at the chip. The CH340G adds at most 12 mA to the regulator's load.

2. Clock. A 12 MHz crystal across pins 7 and 8, and 33 pF from each pin to ground, as WCH's reference circuit shows. Keep the traces short.

3. USB. UD+ (pin 5) to D+ and UD− (pin 6) to D−, directly. The pull-up the host looks for is inside the chip, so no series or pull-up resistors.

4. CH340G TXD to ESP32 RX. On 3.3 V the CH340G guarantees a high of 3.3 V − 0.6 V = 2.7 V. The ESP32 needs 2.47 V (0.75 × 3.3 V), so the margin is 0.23 V. Low: 0.5 V sent against 0.825 V needed, a margin of 0.32 V.

5. ESP32 TX to CH340G RXD. The ESP32 guarantees 2.64 V high and the CH340G needs 1.9 V: 0.74 V spare. Low: 0.33 V against 0.8 V, 0.47 V spare.

6. Ground and reset. Join the grounds. For automatic downloads, DTR# and RTS# drive the ESP32's EN and GPIO0 through the usual two-transistor circuit; WCH's Section 7.9 gives the idea for a microcontroller with a reset pin and a boot pin.

CH340 TXD high → ESP32 RX+0.23 VCH340 TXD low → ESP32 RX+0.32 VESP32 TX high → CH340 RXD+0.74 VESP32 TX low → CH340 RXD+0.47 V0 V1 V2 V3 Vblue: sent, red: needed
Figure 4. All four checks pass on 3.3 V. The tightest is the CH340G's high into the ESP32, 0.23 V, with nothing between the pins.

Worked example in numbers

Supply
3.3 V, V3 tied to VCC
Tightest margin
0.23 V
Crystal
12 MHz, 2 × 33 pF
Current, max
12 mA

If the CH340G has to stay on 5 V

Many boards power the CH340G straight from USB's 5 V. Then its TXD high is at least 4.4 V and can reach 5.3 V, which is 0.8 V or more over the ESP32's 3.6 V limit. The other direction is fine: the ESP32's 2.64 V high clears the CH340G's 5 V threshold of 2.3 V by 0.34 V.

A 10 kΩ / 18 kΩ divider on TXD brings the high down to 2.83 V to 3.41 V, inside the ESP32's window. With 12 pF of pin and jumper capacitance the edge rises in 170 ns, against a half bit of 250 ns at the CH340's top rate of 2 Mbps.

R1 10 kΩ R2 18 kΩ C1 12 pF CH340 TXD ESP32 RX
Figure 5. The divider as ngspice checked it: 4.4 V from TXD arrives as 2.83 V and 5.3 V as 3.41 V, and the first edge takes 170 ns. RXD needs no divider. The level-shifter guide has the same divider for other 5 V parts.

The divider works, but running the CH340G on 3.3 V does away with it and its two resistors. The voltage divider lesson explains the arithmetic.

Advertisement

Tips and checks

  • Cross the data lines: CH340 TXD goes to the microcontroller's RX, and RXD to its TX.
  • Put the 100 nF on VCC and, on 5 V, the one on V3 right at the pins.
  • If USB keeps connecting and dropping, look at the crystal first: WCH suggests halving the capacitor on XI for a crystal that is slow to start, and the crystal maker's value (often 47 pF) for a ceramic resonator.
  • When the board has its own supply, power the CH340 from it too. Two supplies let current flow through the I/O pins into whichever side is off; WCH's Section 7.7 shows the diode and MOSFET fix if you cannot avoid it.
  • Unused modem pins can be left open. R232 has a pull-down, so leave it open for TTL levels.

The logic levels lesson explains VIH, VOH and margins, and crystals and resonators covers load capacitors.

Substitutes

The CH340C is the only drop-in, and only once the crystal is gone. The other CH340 versions are different packages with different pin numbers.

Pin numbers as on the SOP-16 top view, dot at pin 1.
PartPinsVerdict
CH340Csame pins except 7 and 8Fits a CH340G footprint once the 12 MHz crystal and its two 33 pF capacitors are left off: pin 7 must stay open and pin 8 becomes the OUT# output. Its clock is looser (transmit error under 1.8 % against 0.3 %) and it is rated to 70 °C, not 85 °C.WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 2; WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 3; WCH (Nanjing Qinheng Microelectronics) CH340 Datasheet: USB to Serial Port chip CH340, p. 7

Bench check: is it working?

  1. Plug it in and check the computer sees a new serial port (a COM port on Windows, /dev/ttyUSB0 on Linux). Nothing at all usually means a missing driver, a crystal problem or V3 wired wrong.
  2. Measure VCC to GND: 4.0 to 5.3 V or 2.9 to 3.6 V. On 5 V, V3 should read about 3.3 V.
  3. With nothing sending, TXD (pin 2) should sit high: at least VCC − 0.6 V. Only the discontinued CH340R idles low, so a low TXD on a CH340G or CH340C points to a short on that line or a damaged chip.
  4. Loop back: join TXD to RXD, open a terminal at 9600 baud and type. Each character should come straight back. If it does, the chip and driver work, and any fault is in the wiring to the target.

What we'd do

For a 3.3 V microcontroller, run the CH340G from the same 3.3 V rail with V3 tied to VCC and wire TXD and RXD straight across: every level then has at least 0.23 V of margin and no divider is needed. Keep a 5 V CH340G only on 5 V boards, such as an ATmega328P. Choose the CH340C when board space or parts count matters more than baud accuracy, and stick to the CH340G with its crystal if the far end runs on an internal RC clock.

Questions people ask

What is the CH340G pinout?

Pin 1 GND, 2 TXD, 3 RXD, 4 V3, 5 UD+, 6 UD−, 7 XI and 8 XO (the crystal), 9 CTS#, 10 DSR#, 11 RI#, 12 DCD#, 13 DTR#, 14 RTS#, 15 R232 and 16 VCC.

What is the difference between the CH340G and the CH340C?

The CH340C has an internal clock, so it needs no crystal. Pin 7 becomes an empty pin and pin 8 becomes OUT#. Everything else matches. Its baud error is looser, under 1.8 % against 0.3 %, and it is rated to 70 °C rather than 85 °C.

Can the CH340G run on 3.3 V?

Yes, from 2.9 to 3.6 V, with V3 (pin 4) wired to VCC. Its outputs then swing to 3.3 V logic, and nothing connected to it should exceed 3.3 V.

What crystal does the CH340G need?

A 12 MHz quartz crystal between pins 7 and 8, with 33 pF from each pin to ground. A ceramic resonator works with the capacitors its maker specifies, usually 47 pF.

Which driver does the CH340 use?

WCH's CH341 virtual COM port driver; the CH340 is software compatible with the CH341. Linux has it built in as the ch341 module. On Windows or macOS, install WCH's driver if no new port appears.

Buying the CH340G in India

Indian sellers stock the bare CH340G and CH340C chips and, far more often, ready-made USB to TTL adapter boards built on them. On an adapter, look for a 3.3 V / 5 V jumper and check which pin it actually moves: some only switch the supply pin on the header, not the chip's VCC. Our guide to buying electronic components in India compares ten online sellers and covers how to spot fakes.

Advertisement

One email a month from the bench

New circuits, lessons, part guides and calculators, on the first Sunday of each month.

We'll send one email to confirm. Every email has a one-click unsubscribe. Privacy policy

Used in these lessons

Lessons that go deeper

Datasheets this page was checked against

Makers revise datasheets. If the copy you download has a newer revision and a number here disagrees with it, the datasheet wins, and we would like to hear about it.