Here’s how to add a 9-pin serial port to your Raspberry Pi, and it’ll only take you 10 mins. Well, maybe a couple of weeks to wait for the part to arrive from Hong Kong, but once it arrives, it’s only 10 minutes! 😉
Here’s the part you’ll need. It’s an RS232 to TTL converter module containing a MAX3232 chip. The MAX3232 is important, as the older MAX232 won’t handle the 3.3v levels of the Pi, whereas the Max3232 will. It comes with a 4-way cable for connecting the module to the GPIO of your Pi. If you search on eBay for “RS232 Serial Port To TTL Converter Module MAX3232” you should find several. The one I got cost me €3 with free shipping from Hong Kong.
Here’s another view, showing the bottom of the module, indicating the +5V, GND, Tx and Rx pins.
Simply attach the cable to the module, and connect to the 5V, GND, UART Rx and UART Tx pins of the GPIO.
And a closer view of the GPIO connections.
I removed the bolts from the module so that I could plug directly into the serial port of my laptop without a long serial cable.
Once the module was attached to the laptop serial port, I downloaded PuTTY, and attached to the com port (usually COM1) at 115200 baud, 8 data bits, no parity, and no flow control.
Once I applied the settings in PuTTY, I powered on the Raspberry Pi, and saw the entire boot process displayed out the UART of the Raspberry Pi and into PuTTY on the Laptop. A login prompt was displayed, and I could then log in over the UART as normal.
Now to find a project that needs serial port access. I do have a few in mind! 🙂
Perhaps you could enlighten me as to why no one is doing this with male (DE9) connectors? I don’t want to connect to a computer – I want to connect a device to my Pi. I suppose I could just slap on a gender changer, but it seems ludicrous that no one else is doing it.
Hi David, I was just wondering something about how you wired this up. Do you have it so that the TXD gpio pin goes to RXD on the converter module with the RXD gpio pin going to TXD on the converter?
So with it this way the RXD light would come on when the Pi sends data? Is that right, or should it be the other way around?
As far as I remember the RXD on the module is for the RXD on the Pi. It’s on the 9-pin Dsub side that the RXD goes to TXD on the far end.
Regards,
Dave.
Hi David,
Where did you get it ? I need the same circuit for RS485. Please let me know.
Thanks for your info
Umit
If you search on eBay for “RS232 Serial Port To TTL Converter Module MAX3232” you should find several.
Regards,
Dave.
If the PI has a 3 Volt logic level for the serial port, then the RS232 converter chip should also be powered from 3volt ( ok 3.3Volt )
The attached images appear to show the MAX232 powered from 5V. This will probably work – but may be overloading the PI inputs.
For RS485, you will need an RS2285 interface such as a SN75176 device.
Hi,
we have one problem for about Rs232
example I want give or take 1 data Pi to PC, I can send to PC no problem but I cant take Pc to Pi any data… if I send 30 times or 40 times after I can send PC to Pi… then it be normaly… but if I push caracter from keyboard after lock serial com… after I send again 30 or 40 times data then open again… after normaly…
I tried resister then I use max3232 but no change… only I have problem for Pi to PC send wire…
example some example I have from internet “Pi serial com. to ardiuno” but this not work…
I will wait your helps …
thanks a lot…
I am having the same problem. If ur problem is solved then please help me too.
That isn’t a problem, it’s a feature. What is going on, is that the PI serial port is set for cooked IO and it’s buffering the input,
The application should set the port for raw IO or you can do it with stty. On the Pi type man stty for details. Explaining it further would only serve to confuse as the Linux support for serial IO and terminals is extensive and covers almost anything that can be done with RS232. The man pages are also very commplete as is the serial HOWTO (Google serial HOWTO)
Hello there
I would like to do almost a similar set-up and I already have the required items.
I have an item (BMV 602) with 3.3V, RX, TX and GRND pins. It is a logging item and I would like to read the logs from raspberry pi using an application. If i connect the cables as you mentioned here, will I be able to read from the port? The item sends data every second.