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
blippy wrote: ↑Fri Jul 24, 2020 11:33 amI 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:
Ref: https://www.raspberrypi.org/documentati ... on/uart.mdAll UARTs on the Raspberry Pi are 3.3V only - damage will occur if they are connected to 5V systems.
Re: Serial communication voltages
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 = 3V3, Pi RXD = 2V1
Re: Serial communication voltages
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
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.
- FTrevorGowen
- Forum Moderator
- Posts: 5999
- Joined: Mon Mar 04, 2013 6:12 pm
- Location: Bristol, U.K.
- Contact: Website
Re: Serial communication voltages
@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.
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 & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm
Re: Serial communication voltages
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
Many thanks.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.
Re: Serial communication voltages
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
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.
It works very well to program ESP8266 with the jumper set to 3.3V.