How to Enable Serial on Raspberry Pi: Step-by-Step Guide
To enable serial on Raspberry Pi, open the terminal and run
sudo raspi-config. Then navigate to Interfacing Options > Serial, disable the login shell over serial, and enable the serial hardware interface before rebooting.Syntax
Use the raspi-config tool to enable serial communication on Raspberry Pi. The key commands and options are:
sudo raspi-config: Opens the Raspberry Pi configuration tool.- Navigate to Interfacing Options > Serial: To configure serial settings.
- Choose No when asked to enable login shell over serial.
- Choose Yes to enable the serial hardware interface.
- Reboot the Raspberry Pi to apply changes.
bash
sudo raspi-config
Example
This example shows how to enable serial on Raspberry Pi using the terminal commands and configuration tool.
bash
sudo raspi-config # In the menu: # 1. Select 'Interfacing Options' # 2. Select 'Serial' # 3. When asked 'Would you like a login shell to be accessible over serial?', select 'No' # 4. When asked 'Would you like the serial port hardware to be enabled?', select 'Yes' # 5. Exit and reboot with: sudo reboot
Output
Raspberry Pi Software Configuration Tool (raspi-config)
Interfacing Options > Serial
Would you like a login shell to be accessible over serial? No
Would you like the serial port hardware to be enabled? Yes
Reboot required to apply changes.
Common Pitfalls
Common mistakes when enabling serial on Raspberry Pi include:
- Not disabling the login shell over serial, which blocks serial communication for other uses.
- Forgetting to enable the serial hardware interface.
- Not rebooting after changes, so settings do not take effect.
- Using the wrong serial port device (use
/dev/serial0or/dev/ttyAMA0depending on Pi model).
bash
sudo raspi-config # Wrong: Enabling login shell over serial (selecting 'Yes') # This will prevent using serial for custom communication. # Correct: # Select 'No' for login shell over serial # Select 'Yes' to enable serial hardware sudo reboot
Quick Reference
Summary of steps to enable serial on Raspberry Pi:
| Step | Action |
|---|---|
| 1 | Run sudo raspi-config |
| 2 | Go to Interfacing Options > Serial |
| 3 | Disable login shell over serial (select 'No') |
| 4 | Enable serial hardware (select 'Yes') |
| 5 | Exit and reboot with sudo reboot |
Key Takeaways
Use
sudo raspi-config to enable serial interface on Raspberry Pi.Disable the login shell over serial to free the port for communication.
Enable the serial hardware interface to activate the serial port.
Always reboot the Raspberry Pi after changing serial settings.
Use the correct serial device like
/dev/serial0 for your Pi model.