Home > Electronics > Connecting an RS-232 device into Raspberry Pi

Connecting an RS-232 device into Raspberry Pi

November 20th, 2013 Leave a comment Go to comments

I own a VHF scanner Uniden UBC3500XLT and I wanted to control it remotely via its serial interface and Raspberry Pi. That task was not as easy as I expected it to be. :)

Here is the pinout of Uniden cable. It is not documented nicely (quite confusing actually!) so I will describe it.

The “D” on the left is the male part of the Uniden connector on the cable which you plug into the Uniden. You are looking at that cable so that you see those pins.
The individual wires in my cable were colored (from top to the bottom): black, green, white, red.
Now – what I marked is the purpose of those wires from the RECEIVER point of view, so the top pin is GND, the bottom pin is what Uniden uses for transmission, the second from top is what Uniden uses for reception.

IMG_0433

Some people connect it directly to the RS-232 serial port according to a similar Uniden connector http://pinouts.ru/PosDevices/uniden_bc296d_pinout.shtml so I expected that I could connect it to UART GPIO ports on my Raspberry Pi. But that was not the case – UART is not RS-232 (I mean RS-232 is not about the type of connector only). If you look at the specification, RS-232 normally communicates at a higher voltage and it uses negative voltage for 1 and positive for 0. I have just found a perfect article about it (although quite late as I figured it out myself after a few hours of testing without an oscilloscope)  https://www.sparkfun.com/quiz/58 .

The article mentions that in order to connect UART (TTL) with RS-232 device, you need a so called transceiver which inverts the signal and increase it for transmission and inverts and decrease it for reception. In the article they mention MAX-232 but when I disassembled my Uniden cable, I found ZT232LEEN in it. I don’t know what LEEN means but it is basically similar (if not identical) to ZT232F http://www.zywyn.com/pdf/ZT232F_ds.pdf.

In addition to ZT232 there was (obviously) an USB to UART bridge CP2102 https://www.sparkfun.com/datasheets/IC/cp2102.pdf.

So I decided to look at those datasheets and try to disconnect the CP2102 and connect Raspberry Pi to the ZT232 to create an RS-232 interface which should be able to talk with my Uniden UBC3500XLT. And I was right. You can even use pin P1-02 or P1-04 on Rapsberry Pi to power the ZT232.

Here is how a ZT232 can be used to create RS-232 on Raspberry. This is from the Raspbery PI point of view. The circled pins are connected to the external device – Uniden in my case. So data from Uniden flows through circled RXD by R2IN pin 8, is processed by ZT232 and outputs at the pin 9 R2OUT into Raspberry PI UART RXD. CTS and RTS is used for flow control and doesn’t need to be used (can be disconnected). In that case, you need to configure serial port on Raspberry this way:

stty -F /dev/ttyAMA0 115200 cs8 -ixon istrip

(-ixon disables flow control)

IMG_0431

 

Here is how my test setup looks like. I directly soldered some lines into the ZT232 pins which is not ideal. I will probably create a new board for it at some point.

IMG_0435

Here is how it looks with USB audio and wifi interface connected to home-made wifi “antenna”. Works good. :)

scanpi

 

Categories: Electronics Tags:
Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Andrew

Nice project, but useless without the code to make it work! – Would you be willing to share the code and what it does?

2
0
Would love your thoughts, please comment.x
()
x
deadly laser