UART audio transmission

Q: Can Rpi receive serial/UART data through GPIO pin?

kunal Can I receive data which is transmitted through UART port from a transmitter side raspberry pi on a receiver side Raspberry pi’s GPIO pin??


Hi @kunal, Welcome and nice to meet you. Ah, let me see. (1) It is a bit confusing of what do you mean by “receiving side” or “transmitting/sending” side. Let us say, one Win10 PC is connected to a Rpi, using serial/UART cables, both set at 9,600baud, 8N1. Now either side can send data through its Tx pin/wire, OR receive data through its Rx pin/wire. In this case the Rx/Tx pins are crossing over, ie, one side’s TX is connect to the other side’s Rx, and vice versa.
If you agree what I am saying, then let me know what do you want to do, say, not using Rpi’s on board hardware Tx, Rx pin, but instead, use two GPIO pins to pretend/fake Tx/Rx pins and thus do “software” serial communication?
In the above case, you can use terminal emulators such as puTTY, miniCom, or say, python programs doing serial communcation on bothsides. Now if you want Rpi to use GPIO, and not its TxD, RxD pins, then you need to write, say a python program to let one GPIO pin as a software/fake pin to send data, and another GPIO pin as software/fake RxD pin to receive data. And if you don’t want Rpi to send, but just receive data, then you need just one GPIO pin. To conclude, the answer to your question is a big “YES”.
And before I go, if you want to try writing the python program, ask another question and I am happy to see how you are doing. This is a reference for newbies to get started: Rpi3 to Arduino Serial UART Communication Tutorial raspberrypi.stackexchange.com/questions/96184/…. Happy python programming. Cheers.
On more thing. I am curious to know why you would like to read UART data using a GPIO pin. If the reason is that you need more than one UART channel, actually you can use USB UART cables, and you can have as many USB UARTs as you like. And if you are using Rpi4B, then you can use more UART, at least two stable, and up to 5 UARTs (See appendices of my tutorial above). There is also a demo program of testing/looping back of multiple UARTs. Writing your own software UART receiving GPIO is very tedious. Lazy me would just use Rpi4B’s other UART channels, or USB ot UART adaptors/cables.

Hello sir@tlfong01.Thanks sir for such a brief explanation.Sir actually what I am trying to do is that, I want to transmit real time audio data(recorded by USB mic) through UART of one raspberry pi3b(transmitter side) and want to receive it(through) and play it at the same time at receiver side (Raspberry pi). Here I am able to transmit real time audio data but at receiver side it not receiving data.Total code is written in another question,link is [raspberrypi.stackexchange.com/questions/107249/… u could please check that question.

@kunal Ah, I see. So you wish to send audio signal through serial cable to Rpi’s RxD pin. But there one fundamental design problem here. (1) RS232/UART/serial are designed to send a string of characters, usually ASCII coded, or 8 bit control bytes, not necessary text/alphabets. So the sending format is byte by byte, each byte take about 11 bits (very roughly, 1 start bit, 7 or 8 data bits, 1 or no stop bit, 1 or no parity bit).
So if you wish to send real time audio, then UART is NOT an appropriate protocol/format to use. So my first thought is that you have gone the wrong path at the very beginning. The first thing that comes to my mind is to use (1) Blue Tooth, (2) Wifi, but both don’t going far. You might like to tell me how far you wish to send by serial cable, 100 metres, or even further?
Of course you can also use wired Ethernet, which is very fast and can go far, or USB3, fast but not that far. I am not knowledgeable and not experienced enough to guide you along the way, but only point out that it seems not appropriate to use UART, which I am OK to advise you on other applications except audio. Sorry to have disappointed you. But just keep trying, we learn by making mistakes! Cheers.

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.