blippy
Posts: 72
Joined: Fri Nov 03, 2017 3:07 pm

Serial communication voltages

Fri Jul 24, 2020 11:33 am

I recently got an USB to TTL232 module. I suddenly realised that I have no clue about voltages. I'd like to connect the device's RX and TX pins to the appropriate GPIO pins on the Pi. I have no idea if that will fry the GPIO pins, though. What's the answer?

The chip is a CH340C. I'm assuming that VCC output is 5V, which doesn't matter, because I am powering my Pi separately anyway. The big question is what's coming out of the TX pin.

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

Re: Serial communication voltages

Fri Jul 24, 2020 12:12 pm

blippy wrote:
Fri Jul 24, 2020 11:33 am
I recently got an USB to TTL232 module. I suddenly realised that I have no clue about voltages. I'd like to connect the device's RX and TX pins to the appropriate GPIO pins on the Pi. I have no idea if that will fry the GPIO pins, though. What's the answer?

The chip is a CH340C. I'm assuming that VCC output is 5V, which doesn't matter, because I am powering my Pi separately anyway. The big question is what's coming out of the TX pin.


So you want to plug the usb end into some unspecified external device, and connect the 'other' side of the convertor to the RPi 40-way header?


"The big question is what's coming out of the TX pin."

Absolutely! And for that you need the datasheet for the convertor module and/or its chipset.

But note that as a general principle rs232 signalling is bi-polar, or 'non return to zero'. So the two signal states ( mark/space ) are represented by positive and negative going versions of the same absolute signal level. Not only will a signal level of 5v be potentially fatal to a 3.3v gpio pin, but ANY negative-going signal is also likely to cause damage.


And just in case I don't know what I am talking about:
All UARTs on the Raspberry Pi are 3.3V only - damage will occur if they are connected to 5V systems.
Ref: https://www.raspberrypi.org/documentati ... on/uart.md

hippy
Posts: 8560
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Serial communication voltages

Fri Jul 24, 2020 12:32 pm

blippy wrote:
Fri Jul 24, 2020 11:33 am
The big question is what's coming out of the TX pin.
Indeed. You could just measure it with a multimeter as it should be idle high to connect to a Pi's UART. Or assume it's 0V/5V and choose resistors for an appropriate divider which will likely still work if 3V3.

Code: Select all

.----------.   .------------------< Pi TXD
|       RX |<--'    ___
| UART  TX |-------|___|---.------> Pi RXD
|       0V |---.    12K   .|.
`----------'   |          | | 22K
               |          |_|
               |           |
               `-----------^------- Pi 0V (GND)
UART TX = 5V0, Pi RXD = 3V2

UART TX = 3V3, Pi RXD = 2V1

blippy
Posts: 72
Joined: Fri Nov 03, 2017 3:07 pm

Re: Serial communication voltages

Fri Jul 24, 2020 1:42 pm

hippy wrote:
Fri Jul 24, 2020 12:32 pm
You could just measure it with a multimeter as it should be idle high
Aha, that's useful. That voltage came out at 4.05V, which I assume is still too high. Sigh, well that was a waste of a couple of quid from China!

Fortunately, I've got a Plan B. I have an ESP32, which operates on 3V3. So with a little bit of code I can use it as a "proxy" to the Pi.

Thanks for your help, guys.

hippy
Posts: 8560
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Serial communication voltages

Fri Jul 24, 2020 4:14 pm

blippy wrote:
Fri Jul 24, 2020 1:42 pm
That voltage came out at 4.05V, which I assume is still too high. Sigh, well that was a waste of a couple of quid from China!
Just adjust the resistor values to drop it to 3V3 or slightly less. Plenty of on-line calculators available. 10K over 30K would probably do the job.

That's got to be a lot easier than using an ESP as some sort of proxy.

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

Re: Serial communication voltages

Fri Jul 24, 2020 4:19 pm

@blippy, for future reference you may find these notes/tests about/of a number of USB-to-Serial TTL devices of interest:
https://www.cpmspectrepi.uk/raspberry_p ... pters.html
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

blippy
Posts: 72
Joined: Fri Nov 03, 2017 3:07 pm

Re: Serial communication voltages

Fri Jul 24, 2020 9:47 pm

hippy wrote:
Fri Jul 24, 2020 4:14 pm
Just adjust the resistor values to drop it to 3V3 or slightly less. Plenty of on-line calculators available. 10K over 30K would probably do the job.

That's got to be a lot easier than using an ESP as some sort of proxy.
My electronics knowledge is naff, but I can figure out voltage dividers. If I set up a voltage divider I have to set up components with a breadboard. If I use an ESP32, it's basically just three Dupont wires into the Pi.

blippy
Posts: 72
Joined: Fri Nov 03, 2017 3:07 pm

Re: Serial communication voltages

Fri Jul 24, 2020 9:50 pm

FTrevorGowen wrote:
Fri Jul 24, 2020 4:19 pm
@blippy, for future reference you may find these notes/tests about/of a number of USB-to-Serial TTL devices of interest:
https://www.cpmspectrepi.uk/raspberry_p ... pters.html
Trev.
Many thanks.

hippy
Posts: 8560
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Serial communication voltages

Sat Jul 25, 2020 9:12 am

blippy wrote:
Fri Jul 24, 2020 9:47 pm
My electronics knowledge is naff, but I can figure out voltage dividers. If I set up a voltage divider I have to set up components with a breadboard. If I use an ESP32, it's basically just three Dupont wires into the Pi.
You can take your dupont wires, and solder the resistors in-line, wrap it all with insulating tape, no PCB required. Or pass it though a plastic pen body cut-off to make a nicer end-result.

But whatever you choose to do is fine.

nliviu
Posts: 51
Joined: Tue Jun 23, 2020 1:24 pm
Location: Romania

Re: Serial communication voltages

Sat Jul 25, 2020 4:41 pm

You can use something like this which has a jumper to select betweeen 5V/3.3V interface.
It works very well to program ESP8266 with the jumper set to 3.3V.

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