0

I'm working on a project that needs multiple TX/RX pins, but the Raspberry Pi that I have only has 1 of these pins. Can I use the GPIO pins as TX/RX pins? Or is there an adapter available somewhere?

Specifically, I need the TX/RX pins for a SIM module and a GPS module. Perhaps there are SIM and GPS modules that uses GPIO directly instead? Any links would be helpful

5
  • @Ghanima None of the Dupe's mention Software Serial and from my understanding that is what the OP is asking for.
    – MatsK
    Oct 7, 2019 at 19:01
  • @MatsK fair enough, but I still consider it related and these might very well be applicable. The OP seems to be open minded about the solution (e.g. they consider peripherals that do not use a serial interface at all).
    – Ghanima
    Oct 7, 2019 at 19:05
  • @Ghanima I agree that it is kind of related.
    – MatsK
    Oct 7, 2019 at 19:12
  • @aldo, Ah, let me see, you can consider two things: (1) Switch to Rpi4B, which has FIVE hardware uarts: TxD0 to TxD4, RxD0 to RxD4, (2) Use USB to serial adapters/cables. Say, if you have a 9 port USB hub, and 9 USB/TTL cables, you can talk to 9 SIM/GPS modules at the same time.
    – tlfong01
    Oct 8, 2019 at 1:47

2 Answers 2

3

There is a way that is called "Software serial" or "Soft UART".

The project https://github.com/adrianomarto/soft_uart is doing precisely what you are looking for, you can install the soft_uart and use any GPIO as Rx/Tx.

Software-based serial port module for Raspberry Pi.

This module creates a software-based serial port using a configurable pair of GPIO pins. The serial port will appear as /dev/ttySOFT0.

Features

  • Works exactly as a hardware-based serial port.
  • Works with any application, e.g. cat, echo, minicom.
  • Configurable baud rate.
  • TX buffer of 256 bytes.
  • RX buffer managed by the kernel.
0

You could a USB to serial converter. That would let you connect the USB end to the Pi and the serial TX/RX/Ground end to the serial device.

You can use (my) pigpio to bit bang a serial link on any spare GPIO.

As long as the baud rate is 19k2 or less it should be fine.

For Python the read is straightforward. Writing requires waves and needs more effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.