Page 1 of 1

Serial communication voltages

Posted: Fri Jul 24, 2020 11:33 am
by blippy
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.

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 12:12 pm
by B.Goode
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

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 12:32 pm
by hippy
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

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 1:42 pm
by blippy
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.

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 4:14 pm
by hippy
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.

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 4:19 pm
by FTrevorGowen
@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.

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 9:47 pm
by blippy
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.

Re: Serial communication voltages

Posted: Fri Jul 24, 2020 9:50 pm
by blippy
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.

Re: Serial communication voltages

Posted: Sat Jul 25, 2020 9:12 am
by hippy
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.

Re: Serial communication voltages

Posted: Sat Jul 25, 2020 4:41 pm
by nliviu
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.