Adding Serial to USB - iot-root/garden-of-eden GitHub Wiki

Here are step-by-step instructions for adding soldering wires and connecting them to a serial-to-USB adapter on a Raspberry Pi Zero, followed by enabling serial communication on the Pi.

Materials Needed:

  1. Raspberry Pi Zero / Pi Zero 2
  2. Soldering iron and solder
  3. 3x jumper wires (female-to-male)
  4. Serial-to-USB adapter (with TX, RX, and GND pins)
  5. Heat shrink or electrical tape (optional, for wire insulation)
  6. Terminal access to Raspberry Pi (either direct or via SSH)

Step 1: Solder Wires to the Raspberry Pi Zero 2

  1. Prepare the GPIO Header:

    • If your Raspberry Pi Zero 2 doesn't have headers pre-soldered, you'll need to solder the headers onto the GPIO pins. The pins you'll need for serial communication are:
      • Pin 6 (GND): Ground
      • Pin 8 (TXD): Transmit data
      • Pin 10 (RXD): Receive data
  2. Solder the Wires:

    • Solder one end of a wire to Pin 6 (GND), another wire to Pin 8 (TXD), and the last wire to Pin 10 (RXD). These are part of the GPIO header on the Raspberry Pi.
    • Ensure that the solder joints are solid and that no excess solder causes a short circuit between adjacent pins.
  3. Insulate the Connections (optional):

    • If you wish, you can cover the soldered joints with heat shrink tubing or electrical tape for better insulation and to avoid short circuits.

Step 2: Connect the Serial-to-USB Adapter

  1. Match the Connections:

    • On your serial-to-USB adapter, you should find pins marked GND, TX, and RX.
    • Connect the wires as follows:
      • GND (Pin 6 on Pi) to GND on the serial-to-USB adapter.
      • TXD (Pin 8 on Pi) to RX on the serial-to-USB adapter.
      • RXD (Pin 10 on Pi) to TX on the serial-to-USB adapter.

    Important: The TX on the Pi connects to the RX on the adapter, and the RX on the Pi connects to the TX on the adapter, since data transmission and reception work in reverse.

  2. Plug the Serial-to-USB Adapter into a computer. The serial adapter will act as a bridge between the Raspberry Pi and your computer for serial communication.

Step 3: Enable Serial on the Raspberry Pi Zero 2

  1. Access the Raspberry Pi:

    • Boot the Raspberry Pi either with a monitor and keyboard or SSH into it if you can access the Pi over the network.
  2. Run the Configuration Tool:

    • Run the following command to open the Raspberry Pi configuration tool:
      sudo raspi-config
      
    • Navigate to Interfacing Options.
    • Select Serial.
    • It will ask two questions:
      • Disable the shell over the serial port? No.
      • Enable the serial hardware? Yes.
    • Save and exit the configuration tool.
  3. Edit the /boot/config.txt File (optional, if the configuration didn't apply):

    • Open the /boot/config.txt file:
      sudo nano /boot/config.txt
      
    • Ensure the following lines are present to enable UART (serial communication):
      enable_uart=1
      
    • Save the file and exit (Ctrl + X, then Y to save).
  4. Disable Serial Console:

    • In some cases, you may need to ensure that the serial console isn't using the serial pins. Edit the /boot/cmdline.txt file:
      sudo nano /boot/cmdline.txt
      
    • Remove any references to console=serial0,115200 or console=ttyAMA0,115200.
    • Save and exit.
  5. Reboot the Raspberry Pi:

    • After making these changes, reboot the Raspberry Pi:
      sudo reboot
      

Step 4: Test the Serial Connection

  1. Install Minicom (if necessary):

    • If you're connecting to the Raspberry Pi via serial on a Linux/macOS system, you can use a terminal program like minicom or screen. Install Minicom using the following command:
      sudo apt install minicom
      
  2. Use a Serial Communication Program:

    • On your host computer, use a terminal program (like minicom, screen, or Putty) to connect to the Raspberry Pi over the serial interface.
    • Set the baud rate to 115200 and use the correct serial port (on Linux, it could be something like /dev/ttyUSB0).

    Example command to start minicom:

    minicom -b 115200 -o -D /dev/ttyUSB0
    

    Replace /dev/ttyUSB0 with the correct serial device for your system.

You should now have a working serial connection between your computer and the Raspberry Pi Zero 2.

USB Serial adaptor image

Solder wires to Pi Serial Pins image

Route Wires through wire channel image

Route Wires out Humidity Sensor Channel image