FTDI-gate wasn’t great for anybody, and now with hardware hobbyists and technological tinkerers moving away from the most popular USB to serial adapter, some other chip has to fill the void. The cheapest USB to serial chip on the market appears to be the CH340G, available for 20-40 cents apiece from the usual retailers. There is, however, almost no English documentation, and the datasheet for the CH340 family doesn’t include this chip. [Ian]’s here to help you out. He got his mitts on a few of these chips and managed to figure out the pinout and a few reference schematics. He even made an Eagle part for you. Isn’t that nice?
The CH340 series of chips do exactly what you would expect them to do: a full-speed USB device that emulates a standard serial interface, with speeds from 50bps to 2Mpbs. The chip supports 5V and 3.3V, and all the weird modem lines are supported. This chip even has an IrDA mode, because wireless communication in the 90s was exactly as rad as you remember.
With [Ian]’s help, we now have a cheap source of USB to serial chips. If you need the datasheet, here you go. The driver is a bit more difficult to find, but what you’re looking for is the CH341 family of chips. That can be found with a little bit of Google fu.
“FINDING A CHEAPER USB TO SERIAL CHIPS” – Really, HAD ? It’s “Chip”
I thought the Prolific series of chips nicely filled the bottom and somewhat ropey end of the market? Saying that though, most PL chips are cloanes and their drivers block off ones of them. Getting my Baofeng lead to work is like russian roulette so maybe this is a good idea, providing they pull a good driver out of the hat.
everyone wanted FTDI when prolific started to block the clones, I guess FTDI didn’t pay attention
Why use a dedicated USB to serial chip when you can use an AVR to do the same task in software?
http://www.recursion.jp/avrcdc/cdc-232.html
Because it is cheaper?
Because CDC (supposedly) is outside the USB spec on low speed devices. And because using an AVR requires you to keep track of another software stack. But if you need something fast and have a AVRs in you bin, go for it :-)
This is software emulated USB. Means: slow and prone to EMI.
If you want to use a micro, use at least an AVR with hardware USB.
And LUFA: http://www.fourwalledcubicle.com/LUFA.php
CDC on a lowspeed breaks USB specs (bulk endpoints are not allowed for low-speed), thus doesn’t work with some USB hosts properly. Besides, using interrupt-in ep for incoming data severely limits speed to something between 57600 and 115200.
Last time I needed that – I ended up writing a custom protocol that used control transfers to transfer data over a vusb link, and a userspace libusb-based terminal app.
It wont work reliably. it wont work correctly.
Software (bit banged) USB is nice as a demonstration of what can be done in code, but to think that it can actually replace a real (hardware) USB device is delusional.
For some reason, my Fakeduino uses ATMEGA16U2 as USB to Serial chip!
The CH341 chip looks even more interesting: if I’m not mistaken, it’s also capable of EPP, I2C and SPI communication!
Unfortunately, the current driver in Linux only supports the USB-to-serial capability.
That would be fantastic to have a driver that supports all the features of the CH341, say to add more I/O to an embedded device running OpenWrt.
Having user level I2C and SPI support is not just for tiny computers running OpenWrt, it’s also nice for servers with unusual sensors that don’t have kernel drivers, things like flow sensors and fluid level indicators for water cooling, external fan controllers, etc.
Oh, now I know why that chip’s name sounded familiar… I have one of those… it’s an epoxy blob in a USB->LPT cable I got somewhere… can’t use it of course since I’m on Linux >.< Anyone want to expand that driver to parallel capability? ;) I'd do it myself if I wasn't still hooked on QuickBASIC… I am NOT a good programmer lol.
It's IEEE-1284 (LPT), RS-232 (COM), and I2C compatible. I hadn't heard about any SPI capability tho…
SPI *is* mentioned in the spec sheet available at http://www.oomipood.ee/drivers/ch341a_programmer/CH341_chip.pdf
But I’m not sure which specific chip (a/h/t) in the CH341 family supports which protocol.
Apparently, the CH341a has more pins and so should provide the best support.
Unfortunately there’s no CH341 driver for OSX. There is a sort-of terminal program here:
http://www.staarcom.com/software/WCH341-Terminal/index.html
But it’s a time-limited trial thing, and pretty unstable anyway. I had to use a virtual XP to make use of my eBay cable on OSX.
They have a official OSX driver support both CH340 and CH341 you may want to try:
http://www.wch.cn/downloads/downfile.php?id=178
Unfortunately, this is broken in recent OSX (Yosemite).
(Yes, there is a workaround, by disabling kernel security.
Nobody in their right mind will want to do that.)
I’ve found a signed CH340 driver for Yosemite here: http://www.mac-usb-serial.com
Really? Nobody in their right mind?
If you develop hardware and software on Mac OS, it’s pretty much de rigeur.
Unless you know of another way to get my software talking to my hardware?
I have a driver for i2c working on linux: https://github.com/mkschreder/hack-ssd1306-openwrt. If time allows, I will add an SPI driver as well.
I am running Win 7 and i cant get the ch340g driver to install. I cant see a com port listed. when i plug in the LoLin NodeMcu V3. I just cant get to square 2. Square 1 was when i plugged the USB cable in and the blue lights flashed. But no driver load. What the heck is wrong. troy
These chips have horrible support. I had to take windows code examples from manufacturer and write my own linux driver based on that. It works alright. I have no idea about windows support though.
A big disadvantage for this chip is not having the drivers in windows update. Having to install drivers for something simple sucks.
“Having” to install drivers for something is great. The Windows Update drivers for many things suck donkey kugels.
Having a third party maintain the drivers for your hardware sucks anyhow because all they really do is introduce more unnecessary bureaucracy in the middle and then you get outdated buggy drivers and bad support. It’s the same whether it’s Windows Update or Linux repositories – it’s just unnecessary middlemen.
Tell that to your customers…
“Hey customer, click on this link to download and install the latest version of the driver”
Gosh that was SO traumatic
yeah… try that and let me know your success rate.
heh yeah right ! :) all joking aside you must have customers that are somewhat tech aware.
— How do I download?
— Click on this link
— How do I click?
— Click with your mouse
— Computer mouse or animal mouse?
— Computer mouse!
— It does not click. What do I do?
— Click ON the link
— What’s next?
— Install that thing
— What is install?
— Double-click on the file
— It asks me something… Hold on, let me get the glasses on… Ehm… behm… Run… Save…
— Just click “Run”
— What’s next?
— Now you should see the device working
— What device?
— Hm. I think I got a wrong number.
Good ol’ HAD. I can always count on it to give me a good laugh based on hacks…
@Sashka You are too awesome and brilliant on that one. +1
Yeah mooltipass lol. How did that go?
being driverless helped.
It might be worth mentioning that Windows 10 Technical Preview (build 9860) loads Microsoft’s CDC serial driver (USBSER.SYS) automatically. Assuming they don’t revert or regress before release, Windows 10 will finally solve USB serial driver install for all class-compliant USB serial devices.
http://www.dorkbotpdx.org/blog/paul/windows_10_preview_build_9860_finally_fixes_usb_serial
As Windows users migrate to version 10, we’ll finally have a situation where USB serial devices work as well on Windows as they have for many years on Linux and Macintosh.
Microsoft also fixed the long-standing surprise removal bug in the driver.
https://www.youtube.com/watch?v=DRmvUsa2xuU
So then what’s the cheapest compliant chip? Does anybody here know? Actually, that would make a great HaD post. How about a table, columns could be pre-soldered, dip and surface mount. The rows could be cheapest overall and cheapest compliant.
It’s not just the price of the chip, they need other parts like resistors, capacitors, crystal oscillators, etc. You need to incorporate the prices of these parts in your comparison. And then you need to factor in availability, a cheap chip is irrelevant if you can’t get them (or the supporting parts!) in the quantities and timeline you need for your project. You also need to factor in board space, in three dimensions. Big capacitors can be really cheap but they are problematic if you have size constraints.
Does it use a generic built in driver or do you have to find and download the driver?
It does not have a linux driver, but I’m working on one: https://github.com/mkschreder/hack-ssd1306-openwrt
Does anyone know if recent linux kernels come with a driver?
Yes. In /usr/src/linux/drivers/usb/serial you can find ch341.c
Oh, and if you want to check beforehand:
static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x4348, 0x5523) },
{ USB_DEVICE(0x1a86, 0x7523) },
{ USB_DEVICE(0x1a86, 0x5523) },
{ },
};
Yeah, plug it in, and it simply works (at least on my Ubuntu (Ubuntu Gnome 14.04)).
Not only recent ones.
The driver has also been backported to old kernels.
“Does anyone know if recent linux kernels come with a driver?”
Yes, it comes with many drivers for all sorts of hardware!
“Yes, it comes with many drivers for all sorts of hardware!”
Like many other OSes do for all sorts of other hardware.
It’s been supported in linux for close to a decade. ancient stuff.
CH340G is a pretty OK chip.The cheapest Arduino clones I sell use it. While it does the job, drivers are indeed a bit tricky to install due to not being signed and the fact you have to actually download them. I gotta see the datasheet if I could write better drivers myself…
The CH341 chip looks even more interesting: if I’m not mistaken, it’s also capable of EPP, I2C and SPI communication!
Unfortunately, the current driver in Linux only supports the USB-to-serial capability.
That would be fantastic to have a Linux driver that supports all the features of the CH341, say to add more I/O to an embedded device running OpenWrt.
What about the CP2102? I have 2 Boards here with these chip, working flawless. But I can’t remeber anymore if I had to search for the driver, or if they where installed automatically.
Drivers are automatic for the CP2102, and you can buy full blown adapters using them for $3 or under.
well in windows 8.1 they install automatically never had troubles with them
I use Prolific (not in win 8), Ftdi, ch340, silabs cp2102 no problems, no ftdi gate since i use originals chips ….
I like the Silicon Labs chips more. (CP210x). They are only slightly more expensive, you get a real datasheet, a signed driver, example code and support.
Especially the CP2104 is nice, as it has four additional GPIOs.
There’s a commercial product (relay board) that uses the CP2104, and the software for this board will run with every CP2104:
http://www.conrad.de/ce/de/product/393905/Conrad-USB-4fach-Relaiskarte-Baustein-5-VDC-Ausgangsleistung-8-A24-VDC
The SiLabs chips are really nice. I’ve used the CP2108 (4 UARTs and some GPIO), and the driver setup and chip config was really simple. The reference design is also pretty trivial, it doesn’t need an external oscillator like many FTDI chips and only needs a couple of caps to run.
Really nice might be stretching it for me. The driver under Linux can be a bit quirky on older kernels, so you need to be a bit careful to make sure to be running a relatively recent kernel, especially for GPIO access, which I think you still need to get the driver from SiLabs.
Definitely cheap and easy to use, though.
I second this. I started using CP2102 boards for all TTL-level UART applications. I get them on eBay for around $2 each. They have great driver support, and the boards are teeny-tiny. For $2 they are cheap enough to just leave in a project.
yup serial for the rest of us, CP2102 and PL2303 adapter boards from china for less than $1.50ea are a quick easy way to go. Complete and working, just plug in your project. I only use linux now, I started giving up on m$ back in 98 and have no need of it anymore. I been throwing these boards into my projects for a while with no issues.
Isolation was easy too!
http://hackaday.io/project/296-bench-power-supply
Just to pile on: for thous that don’t know there super easy to mod for ardueno use, just add a .1uf cap and cut a trace.
http://hackaday.io/page/416
The datasheet referenced is only for the CH340T and CH340R, both 20-pin parts and NOT used on Arduino clones. The only datasheet I’ve seen that has the 16-pin CH340G is mostly in Chinese. However it is enough to be able to use the CH340G is a new design (your own Arduino clone maybe?). I am using it in a project where I put the equivalent of a clone Arduino Nano on my board.
Here’s a ASCII version of the pin-out since I haven’t figured out how to post a picture yet:
————————
1 | GND VCC | 16
2 | TXD RS232 | 15
3 | RXD RTS# | 14
4 | V3 DTR# | 13
5 | UD+ DCD# | 12
6 | UD- RI# | 11
7 | XI DSR# | 10
8 | XO CTS# | 9
———————–
The rest of the Chinese datasheet is the same as the English version. You can match up pins in the example schematics well enough to use it in a design. I created an Eagle library for this part (and only this part), but I’m not sure how to share on HAD yet.
Thank you for the pinout!
I ordered some Arduino Nano for $3.27 shipped. It is using the CH340G chip.
http://www.banggood.com/ATmega328P-Nano-V3-Controller-Board-Compatible-Arduino-p-940937.html?currency=USD
but I wasn’t able to find the schematic.
The Driver directly from the chip manufacturer works fine on WIndows7 64 bit (seems to be the CH341 drivers, but work):
http://www.winchiphead.com/download/CH341/CH341SER.ZIP
Board is recognized as well on my PogoPlug running Debian with 3.12 kernel.
For the price of a USB-Serial board you get an Arduino Nano clone with more GPIO etc.
That looks like a sweet deal on the nano!
I’ve thrown my weight behind the Cypress Semi CY7C65213-28PVXI. It’s pin-for-pin compatible with the FT232RL, it’s supported by CDC drivers, so there isn’t a proprietary one for them to horse around with, and it’s about half the price.
In fact, I designed a little USB-to-RS232 board to test it out. It works really nicely. I’d sell them, but I’d have to price them at around $10, and that’s just ridiculous.
I third this recommendation. I’ve used CY7C65213 in a few designs and it works great.
The Cypress UART chip also supports SPI and I2C. And the USB Battery Charging spec. You can change a couple of the GPIO pins to report what amount of current is available. (100mA for unenumerated, 500mA for enumerated or SDP, <800mA for CDP, DCP, or unenumerated on a USB 3.0 port). It's a pretty cool feature if you wanted to implement a battery charger. Plus you can configure the GPIOs as capacitive button sensors. It's kind of a kitchen-sink chip, but I don't think it's any more expensive than the SiLabs or FTDI chips that do all 3 serial protocols.
CY7C65213-28PVXI is $2.00 in quantity 100
CH340 is about $0.30 in quantity 100
Do you glue on a Cadillac logo when you use overpriced chips?
Here is the signed driver for ch340 chip which I used it to install my usb2serial converter on Win 8.1 x64:
http://www.winchiphead.com/download/CH341/CH341SER.ZIP
Thanks for the link, I put it on my CH340 blog post (the one that this HaD is about).
it is not signed driver unfortunatelly …
The downloaded driver which I have has a digital signature. I put a picture here:
http://img294.imagevenue.com/img.php?image=338767667_ch341signed_122_185lo.jpg
If you are looking for ‘just the chip’, check out aliexpress.com and search on CH340G. They are mostly in lots of 50 and 100, but there are several with as few as 5. The larger lots have the parts for around $.50 USD and free shipping. They also list a lot of USB to serial boards (way cheap) and Arduino clones, Nano, Uno, and Mega that have the CH340G.
great, replacing the worlds most popular one with slower, worse chips with various driver issues, if you’re doing low speed non bulk/non streaming they’re usually ok. but hit them with hi speed continuous traffic and watch them fall apart.
perhaps you can enlighten the rest of us with your experimental data so we can avoid the problems you’ve had
Well thats really the results, they’ll work until you stream lots of data over long periods of time, I do automotive ecu’s (aftermarket and oem), data loggers and performance/tuning software and the customer support nightmare i went through, as well as just trying to get them to stream a consistent flow of data continuously overly long periods of time, they were just never stable at all. The drivers blue screen, they don’t bulk transfer well, stop responding, problems with multiple reconnect errors where you have to switch to a different usb port or reboot, the list goes on.
one of the reasons i’ve stuck with FTDI
this is related to the ch341/and silabs cp210x mainly. And any that use usbser as a basis for the windows side driver.
These are the same sorts of problems I see with FTDI chips on OSX
But I have great results with PL23203 and CP2102 chips
So it’s not the hardware at all, but rather the quality of the driver
To some extent, but mostly i’d disagree, there are definitely hardware side issues as well that cause some of these problems. Perhaps you could tell us what sort of work load you’re using it in OSX., I get considerably less issues with the FTDI on linux/osx/windows and other embedded OS’s than with the other chips, certainly not the PL2302 and definitely not the CP2102, that chip was a nightmare for me, but YMMV. It’s difficult to compare anecdotal notes and get much of use out of it thats for sure.
I’ve got a lot of arudino clones of pretty good quality that have been using these chips for a while now. They work great on Windows and gave me a little trouble on OSX but overall they work just fine and even with the IDE.
If I wanted to make a device that used USB for power ( And therefore, enumerate to get 1A ), I’m going to assume that I could care less about all this UART stuff and would want the cheapest IC possible. Would the CHG340G be a good choice?
usb is typically 100mA , with enumeration it’s 500mA, for 1.A+ typically thats charging ports, low ohm over D-/D+ for those. there are some dedicated charging chips that will enumerate automatically for the right setup, but i’m only aware of ones that are suitable for charging batteries.
http://www.maximintegrated.com/en/app-notes/index.mvp/id/4803
*couldn’t* care less
I’d recommend bitbanging usb for something like this application, as you could just do it on the same MCU that the rest of your code ran on. Take a look at something like http://www.obdev.at/products/vusb/index.html for AVR microcontrollers.
“…all the weird modem lines are supported.”
Not knowing them is good! (For me.) Made a mint back in the day from people that just called them weird and mysterious. Paid for my hobby! $50 per cable back in the 80’s! Lot of useful things can be done with them weird lines, but yet again you don’t have to use them at all! None is more difficult to understand than what one should do when they hear a knock at the door. Heck even the ex was enthused enough to have me teach her how to make custom cables and handle a logic probe… she liked the $50 a pop that much that she bothered to learn it! Tons more profitable than her knitting and macrame! Paid for her hobby too! It wasn’t much of a leap for her at all… and she don’t know electronics even as far as a battery, light bulb, and two wires…. but she made nice looking cables!
That folks still don’t know these weird modem lines means vendors will make much $$ with this chip.
Thanks for the memory HAD!
Hi,
for CH341 I do have a working I2C driver available for Linux – I’ll post it this week.
Thanks,
Peter
https://github.com/mkschreder/hack-ssd1306-openwrt/tree/master/i2c-ch341
Does anybody have a footprint for the CH340G chip. I do not use Eagle so the Eagle library file doesn’t help me.
I found a page with footprint, reference design schematics, etc.
http://www.sunrom.com/m/4511
I’m glad someone commented on this to bring it into the recent comments list and back onto the front page.
This weekend I was helping some students with a project. I was using a CRIUS USB->TTL module to configure an HC05 bluetooth module. The CRIUS module works great on my Linux laptop. Not so great on the Windows PC at school.
FTDI is *still doing it* (June 2015). Bastards! My CRIUS module was bricked, so it was useless. I had to take it home and unbrick it. An afternoon wasted.
Anyway, DealExtreme is listing CH340 devices, so I’ll buy them in future.
Getting nuts ….. I have bought several CH340G boards – can’t get them to run. Well, on arduino it works, but not else. (Driver is installed and works correct – no fault).takes RXD-data when connected to arduino on TXD pin.
Have a current cost energi-monitor with is suppose to run at 9600 N81 – it works fine on a PL2303HX in windows 8.1 but when I put the 2 lead on the CH340G – I get no output. (No doesn’t help to change RXD / TXD – and beside the receive LED i blinking on the CH340 ….. so there must be data inn!). Anybody has a clue???
Try to use below USB Driver http://www.winchiphead.com/download/CH341/CH341SER.ZIP
The URL has changed http://wiki.seeedstudio.com/images/7/7c/CH340DS1_EN.PDF
I use FTDI chips and USB is a non-issue…they just work…THAT is part of what you pay for.