Nanjing QinHeng Electronics CH340

ch340usb.jpg

ch340-min.jpg

These are cheap USB UARTs available is various configurations.

These devices are becoming popular, so much so that fake ch340 chips exist. The fakes have the ch340 USB identity and can be found in RS485 adatpers (see below).

As well as being found on general purpose serial interfaces they are often found on Arduino clones and ESP8266 bridges.

Pinout

    CH340G              CH340T              CH340R
    +------+            +------+            +------+
GND 1     16 VCC   CKO  1     20 NOS#  NC   1     20 NOS#
TXD 2     15 R232  ACT# 2     19 VCC   ACT# 2     19 VCC
RXD 3     14 RTS#  TXD  3     18 R232  TXD  3     18 R232
V3  4     13 DTR#  RXD  4     17 NC    RXD  4     17 IR#
VD+ 5     12 DCD#  V3   5     16 RTS#  V3   5     16 RTS#
VD- 6     11 RI#   VD+  6     15 DTR#  VD+  6     15 DTR#
XI  7     10 DSR#  VD-  7     14 DCD#  VD-  7     14 DCD#
XO  8      9 CTS#  GND  8     13 RI#   GND  8     13 RI#
    +------+       XI   9     12 DSR#  XI   9     12 DSR#
                   XO   10    11 CTS#  XO   10    11 CTS#
                        +------+            +------+

Linux

ESP8266 bridge

Identity
ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
udev /dev/ttyCH340
KERNEL=="ttyUSB*",\
    ATTRS{idVendor}=="1a86",\
    ATTRS{idProduct}=="7523",\
    GROUP="dialout",\
    MODE="0660",\
    RUN+="/bin/ln -sf %k /dev/ttyCH340"
udev by-id
/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0

udev by-id is not supported by Pickle Microchip PIC ICSP.

Pickle Microchip PIC ICSP

ch340g.jpg

Pickle ICSP supports RS232 for programming boards such as the Velleman K8048 kit.

Velleman K8048 Configuration

The K8048 kit has an RS232 interface which is used in a bit-bang mode of operation. USB UARTS are not ideal for this purpose but can operate, albeit slowly.

The .pickle configuration for the CH340 is this.

DEVICE=/dev/ttyUSB0
SLEEP=600
BITRULES=0x001F

The SLEEP value affects both the speed of programming and the reliability of operation.

RS485

ch340-485.jpg

Top: ch340g Bottom: fake

Cheap RS485 adapters exist using both this chip and a fake version of this chip.

The real chip is a CH340G with 16 pins and the fake chip has 24 pins in an unmarked package. The top 20 pins of the fake match those of a genuine CH340R or CH340T device which is only available in 20-pin packages.

The RS485 I/O stage varies slightly between the real and fake adapters and is constructed like this for the CH340G device.

Resources

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information