leonvdheiden
Posts: 3
Joined: Tue Feb 13, 2018 10:22 am

Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 10:25 am

My Pi 3 is connected to a solar panel system with an USB to RS232 cable. Unfortunately I am unable to receive any data with the Pi so far. I got it working under Windows. What I've checked on my Pi so far:

1) My pi recognizes the device.

Code: Select all

root@zonnepaneel:~# lsusb
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
2) The device is listed as ttyUSB1 and the rights should be sufficient.

Code: Select all

root@zonnepaneel:~# dmesg | grep tty
[0.000820] console [tty1] enabled
[7221.626142] usb 1-1.2: pl2303 converter now attached to ttyUSB1

Code: Select all

root@zonnepaneel:~# ls -l /dev/ttyUSB*
crw-rw-rw- 1 root tty 188, 1 feb 13 10:11 /dev/ttyUSB1
3) It can be connected with cu (baud rate 9600 is correct).

Code: Select all

root@zonnepaneel:~# cu -l /dev/ttyUSB1 -s 9600 --parity=none
Connected.
However, no data is displayed. What can I try to make this work?

User avatar
topguy
Posts: 4406
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 12:04 pm

I've worked with serialports and Linux for 14 years, never heard about "cu" until today and had to google it.

Can I suggest using "screen" or "minicom" or "gtkterm".
What is the solarpanel supposed to send ? And will it send things without asking ?

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 12:35 pm

There is a good chance that your hardware handshake is the problem!

Check the manual if the device needs hardware handshake!

Maybe DTR needs to be high.


On the PI side check the communication using by loop back the RX and TX!

Disconnect the cable from the solar panel and connect pin 2& 3 together (9 pins connector) and see if you are able to have an echo of what you send.

I'm agree with topguy!
use another terminal application. I prefer 'minicom' because for me 'screen' is problematic with my multi-language keyboard. Don't forget to check the hardware handshake!
Last edited by danjperron on Tue Feb 13, 2018 3:56 pm, edited 1 time in total.

B.Goode
Posts: 5803
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 12:36 pm

However, no data is displayed. What can I try to make this work?
First, check that the usb serial port adaptor is working with your RPi by doing a simple loopback of the data at the rs232 connection, probably pins 2 and 3, and verify that data typed into your chosen serial test program on the RPi is echoed back to you.

Once that is ok, check the wiring between the adaptor and the data source. There needs to be a crossover somewhere in the system so that data transmitted by the panel appears on the Receive line of the RPi, and vice versa.

Provided you have compatible data formats - baud rate, stop bits and parity - all should then function as expected.

(Some possible duplicated advice here as another reply was posted as I typed this... )

leonvdheiden
Posts: 3
Joined: Tue Feb 13, 2018 10:22 am

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 1:33 pm

Thank you all for the fast response and help. Really appreciated.

First of all, I am using Minicom now.

As mentioned, I did use the data on a windows pc within a program. That worked 'out of the box' so I am not aware of many technical aspects there. But what I learnt from that setup is that the specific setup should be: baud rate 9600, 8 bits, 1 stop, parity=none.
Unfortunately I don't really know what the data should looks like and I also am not aware if there is some kind of handshake needed.

Further I experimented with the settings for hardware flow control and software flow control in Minicom on my Pi. This gave me no other results. Connecting the hardware pins differently to check the capabilty of echoing is no option since my cable is molded and I cannot change it myself. Can I check this via software as well?

User avatar
topguy
Posts: 4406
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 3:07 pm

As mentioned, I did use the data on a windows pc within a program.
So you used exactly the same cabling on windows ?
But what program was it ? Your own ?

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Reading data from a PL2303 serial USB converter

Tue Feb 13, 2018 4:01 pm

As mentioned, I did use the data on a windows pc within a program. That worked 'out of the box' so I am not aware of many technical aspects there. But what I learnt from that setup is that the specific setup should be: baud rate 9600, 8 bits, 1 stop, parity=none.
Then if you not able to find the documentation it is time to do a spying device. Connect your pc on the panel and use your usb to rs232 on the pi and just connect the rx pin on it. You should see what kind of signal you send . After that chrck the tx part by changing your rx pib to the tx pin between the panrl snd the pc. Also check the handshake signal. DTR,CTS,RTS and DSR. Just in case they are needed.

leonvdheiden
Posts: 3
Joined: Tue Feb 13, 2018 10:22 am

Re: Reading data from a PL2303 serial USB converter

Mon Feb 19, 2018 2:00 pm

Hello Everybody!

Thank you for the support. I did manage to get it working.
It turned out that my device needed some kind of handshaking.
That was the main reason why I didn't receive any data with the tail command.

For those who are interested: I used this script to get it working.
https://github.com/trollkarlen/inverter ... README.txt

natopal46
Posts: 8
Joined: Mon Apr 09, 2018 11:25 am

Re: Reading data from a PL2303 serial USB converter

Wed May 02, 2018 8:36 am

Looks like I am facing the similar problem (but I am dealing with I2C interface) as I am using 2 Wire I2C baesd 4-20mA current loop receiver connected to sensor at long distance around (30 meters) What is the best way to make I2C interface converted to USB and interface it with raspberry pi to read the data ? And is it possible to power the current loop receiver using I2C to USB interface ?

Your intel on this will be very helpful

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19546
Joined: Sat Jul 30, 2011 7:41 pm

Re: Reading data from a PL2303 serial USB converter

Wed May 02, 2018 10:48 am

natopal46 wrote:
Wed May 02, 2018 8:36 am
Looks like I am facing the similar problem (but I am dealing with I2C interface) as I am using 2 Wire I2C baesd 4-20mA current loop receiver connected to sensor at long distance around (30 meters) What is the best way to make I2C interface converted to USB and interface it with raspberry pi to read the data ? And is it possible to power the current loop receiver using I2C to USB interface ?

Your intel on this will be very helpful
Please start a new topic - this is unrelated to the original posting.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 8 guests