Jan_Mechelen
Posts: 6
Joined: Fri May 27, 2016 8:23 am

USB to Serial cable

Tue May 31, 2016 5:06 pm

Hello,

I bought a verry cheap USB to Serial cable (blue connectors and a transparant wire with silver shielding).

The cable works fine on Windows 10 (tested with loopback dongle and Putty). When I insert the cable with loopback dongle in my RPi3 (Rasbian - Jessie) everything looks ok. When I start a Putty terminal session on RPi3 the terminal windows opens but nothing is displayed when I type in characters. I assume it's a Linux driver problem.

Did somebody make this cable work under Raspbian - Jessie?

lsusb
Bus 001 Device 008: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

dmesg
[ 4565.114200] usb 1-1.4: new full-speed USB device number 8 using dwc_otg
[ 4565.217331] usb 1-1.4: New USB device found, idVendor=1a86, idProduct=7523
[ 4565.217354] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4565.217367] usb 1-1.4: Product: USB2.0-Ser!
[ 4565.222276] usb 1-1.4: ch341-uart converter now attached to ttyUSB0

All help is appreciated!

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: USB to Serial cable

Wed Jun 01, 2016 11:19 am

Unsure what you are trying to do...

Are you trying to connect from a Windows computer to your Pi or the other way around?
The info you give (lsusb, dmesg) suggests you are trying to connect *from* your Pi, but the use of Putty suggests otherwise.

Jan_Mechelen
Posts: 6
Joined: Fri May 27, 2016 8:23 am

Re: USB to Serial cable

Wed Jun 01, 2016 12:31 pm

I want to connect the Pi to my home domotics system that only has a RS232 interface, therefore I need a working cable/driver.

I installed Putty on my Windows10 PC -> cable works
I installed Putty on RPi -> cable does't work

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5618
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: USB to Serial cable

Wed Jun 01, 2016 2:31 pm

Jan_Mechelen wrote:I want to connect the Pi to my home domotics system that only has a RS232 interface, therefore I need a working cable/driver.
I installed Putty on my Windows10 PC -> cable works
I installed Putty on RPi -> cable does't work
FWIW, I normally only use PuTTY to connect via SSH methods and prefer to use GtkTerm for serial connections & basic loopback tests (via Linux):
https://www.cpmspectrepi.uk/raspberry_p ... pters.html
https://www.cpmspectrepi.uk/raspberry_p ... apter.html
https://www.cpmspectrepi.uk/raspberry_p ... rtRep.html
Just OOC is it a TTL level (3.3V or 5V) or full RS232 "system"? Any hardware handshaking to be "fudged"?
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: USB to Serial cable

Wed Jun 01, 2016 2:53 pm

The OP is having a CH341 Serial to USB adapter and has a loopback installed if I read his post correctly.

In Windows 10 it works, so the device is functional.

I have read reports (e.g. http://paulbyford.blogspot.nl/2016/03/u ... vices.html) and seen myself that the CH341 in current Jessie works, as tested with Minicom.
The OP seems to have a working driver also:
[ 4565.222276] usb 1-1.4: ch341-uart converter now attached to ttyUSB0

Make sure hardware handshaking in your terminal emulator is off, it may be on by default.

The 3.3V/5V issue is not yet relevant for the Raspberry Pi side, since this is just a loopback test.
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

Jan_Mechelen
Posts: 6
Joined: Fri May 27, 2016 8:23 am

Re: USB to Serial cable

Wed Jun 01, 2016 3:23 pm

I used exactly the same settings in Putty for Windows as in Putty for Raspbian. 8 data bits, 1 stop bit, no parity, no flow control, 9600.

I assume the cable (with CH340 chip?) is not compatible with that driver.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB to Serial cable

Wed Jun 01, 2016 4:16 pm

Jan,

The message

Code: Select all

ch341-uart converter now attached to ttyUSB0
indicates that the kernel found a driver, and has the device ready for you at /dev/ttyUSB0

Is your pi user a member of the dialout group? You need that for serial access. Do this, then log out and back in again:

Code: Select all

sudo usermod -a -G dialout pi
The loopback dongle - what is it? A simple RX/TX cross in the DB9?

Personally, I find minicom or screen more straightforward than using PuTTY's pterm. Typically, 9600 8N1 connection with screen would work with:

Code: Select all

screen /dev/ttyUSB0 9600
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Jan_Mechelen
Posts: 6
Joined: Fri May 27, 2016 8:23 am

Re: USB to Serial cable

Fri Jun 03, 2016 7:31 am

Hi Scruss,

Thanks for the help but no success

1. The loopback dongle has indeed tx/tx connected ( following pins are connected1-4-6 and 2-3 and 7-8-9)
2. Dialout belongs to the pi user group (if I type "id" it shows a list of groups with "20(dialout)" )
3. I installed screen and typed your command. Unfortunately the same results as with Putty.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB to Serial cable

Fri Jun 03, 2016 1:48 pm

Can you borrow/use another USB-Serial adaptor to see if the fault is elsewhere?
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Jan_Mechelen
Posts: 6
Joined: Fri May 27, 2016 8:23 am

Re: USB to Serial cable

Sat Jun 25, 2016 8:45 am

Problem solved!

I downloaded the driver code from the manufacturers website (http://www.wch.cn/download/CH341SER_LINUX_ZIP.html) and rebuilt the driver. After that it worked immediately.

It seems there is a probem with the built in driver ch341.ko in raspbian version 4.4.12-v7+

Abbiati
Posts: 1
Joined: Tue Jul 05, 2016 2:37 pm

Re: USB to Serial cable

Tue Jul 05, 2016 2:40 pm

Hi, I've downloaded the file but i don't understand how i can rebuilt the driver.
Can you explain me?

User avatar
liudr
Posts: 687
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
Contact: Website

Re: USB to Serial cable

Wed Jul 06, 2016 1:24 am

I have Jessie from 2016-05-27 and mine works fine with ch340/1 with exact same VID/PID as yours. Mine is on an arduino nano and I've been able to communicate with it both ways. I'm not an expert but I wonder if someone can tell me how to tell the version of driver etc. so I can compare with OP's compiled driver.
Arduino data loggers, user interface, printed circuit board designer since 2009, RPI 3B 2B 2B Zero Jessie, assembly/C/C++/java/python programmer since the 80's

Return to “Beginners”