Use UART for your own communication

Your may want to use uart for your own communication. To achieve that, you need first disable serial console. Free uart port from serial console ******************************

Free UART port of Pi

$ sudo vi /etc/inittab

Then comment out the following line by add ‘#’ sign at the start of the line

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

The boot code also by default uses the serial port as output. We need edit /boot/cmdline.txt to disable it.

Firtst, backup the original file by

$ sudo cp /boot/cmdline.txt  /boot/cmdline.txt.bak

Then edit the file

$ sudo vi /boot/cmdline.txt

Delete console=ttyAMA0, 115200 from the line

dwc_otg.lpm_enable=0 console=ttyAMA0, 115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=dealine rootwait

Save the file, and then reboot the Pi,

$ sudo reboot

Pi and PC uart communication

Pi and PC uart communication

For a simple test,

On Pi

$ sudo minicom -b 9600 -D /dev/ttyAMA0

On your PC, for linux

$ sudo minicom -b 9600 -D /dev/ttyUSB0

If you can type on Pi or PC, you should receive text on the other side.

For serious usage, you can use pyserial and write some simple python code to do the comunication.

Table Of Contents

Previous topic

Serial console