RS485
This section introduces how to use the RS485 interface functions on the Raspberry Pi, laying the foundation for subsequent project development.
Enabling Interface Configuration
- Enable the RS485 interface (disabled by default)
- Edit the config.txt file
sudo nano /boot/firmware/config.txt
- To use RS485, add the following lines (these correspond to the 2 communication interfaces):
# Corresponding to CH1dtoverlay=uart4-pi5# Corresponding to CH2dtoverlay=uart2-pi5
- Enable all 4 RS485 channels simultaneously
# Enable CH1 ~ CH2 RS485 channels at the same timedtoverlay=uart2-pi5dtoverlay=uart4-pi5
- After modification, reboot the Raspberry Pi, then the program can drive RS485 normally
sudo reboot