In this post, we will describe how to set the serial port of Raspberry B+ to be a communication serial port that can be used to control other peripherals instead of the default debug port.
1. Configure the system serial port:
1) Type the following in a terminal:
$sudo nano /boot/cmdline.txt
Change following lines:
wc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
to:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevaator=deadline rootwait
Press Ctrl+X, and select Y to save and quit.
2) Execute the following:
$sudo nano /etc/inittab
Change the following content:
#Spawn a getty on Raspberry Pi serial line T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
to:
#Spawn a getty on Raspberry Pi serial line #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Press Ctrl+X, and select Y to save and quit.
3) Execute the following:
$sudo reboot
After executing this command and Raspberry Pi B+ rebooted, we will no longer to able to log in to the terminal through the serial debug port. We have to use SSH or use monitor to enter into LXterminal. If we have to, we have to undo the above steps.
2. Install libraries
1) Copy software/wiringPi.tar.gz to Raspberry Pi B+. The files can be downloaded here. Run the following commands.
$sudo tar xvf wiringPi.tar.gz $cd wiringPi/ $chmod 777 build $./build
2) After the installation, run the following command to check if the installation is successful or not.
$gpio -v
3. Print out message through the serial port:
1) Configure the serial port jumpers on the Arduino converter HAT:
- CP_RX -> P_TX
- CP_TX ->P_RX
2) Launch PuTTY, and configure as following:
- Serial line: please configure according to real situation
- Speed: 9600
- Connection type: Serial
3) Copy program/Xbee/send to Raspberry Pi and type the following:
$sudo make $sudo ./serialTest
Now the serial console will display the following message:
Leave a Reply
You must be logged in to post a comment.