How do I use UART serial port on the Pi-2 bus?
#1
How do I reference the UART pins on the PI 2 header (pins 8 and 10) to start a serial session from the command line?  I'd like to use GNU Screen, if possible.  I'm guessing something like :
>$ screen /dev/ttySomethingOrAnother 115200

I'm a newb to the P64, and this is my first time trying to communicate with a peripheral.

Do I need to configure the pins to use their UART function?  If so, how?  

(If there are better Rx/Tx pins to connect to my device, I'm open to that.  I just picked those pins from an example on connecting UART to the RPi)

Feel free to point me to any docs on the subject.  (I'm still learning where to search for Pine64 info.)
  Reply
#2
(12-08-2016, 09:19 PM)SvdSinner Wrote: How do I reference the UART pins on the PI 2 header (pins 8 and 10) to start a serial session from the command line?  I'd like to use GNU Screen, if possible.  I'm guessing something like :
>$ screen /dev/ttySomethingOrAnother 115200

I'm a newb to the P64, and this is my first time trying to communicate with a peripheral.

Do I need to configure the pins to use their UART function?  If so, how?  

(If there are better Rx/Tx pins to connect to my device, I'm open to that.  I just picked those pins from an example on connecting UART to the RPi)

Feel free to point me to any docs on the subject.  (I'm still learning where to search for Pine64 info.)

You're on the right track. You also need to connect Ground - you can use pin 4 for that. That makes it easy to remember pins 4, 6 and 8 are UART2, so the command would be:

>$ screen /dev/ttyS2 115200

If you're using a USB UART adapter make sure it's set up to run on 3.3 volts.
  Reply
#3
(12-08-2016, 10:08 PM)psychedup Wrote: >$ screen /dev/ttyS2 115200

If you're using a USB UART adapter make sure it's set up to run on 3.3 volts.

I will add :
  uart2:  /dev/ttyS2
  uart3:  /dev/ttyS3
  uart4:  /dev/ttyS4

You will probably want to do one of the following:

   sudo chmod 0777 /dev/ttyS2

or

   sudo usermod -aG dialout  username

The pl2303 cable from ada fruit is pre-set to 3v3.  Other cables like the cp2102 based TTL usb serial bridge are switch or jumper selectable 3v3 or 5v;  make sure yours is set to 3v3.  This is VERY important.

screen works well,  as well minicom,  and  cu  is another option;  although  cu  does not work well with all TTL serial bridge cables ( my CH340G does not work with cu ). 

uart3 and uart4  are on the euler bus.  uart1 is on the wifi bus , and uart2 is on the pi bus.

Note:  a neat trick is to do a loop-back  , or sometimes referred to a wrap-plug;  that is on uart2 you jumper across Rx--Tx.

First start screen:

sudo screen /dev/ttyS2 115200     (connect nothing to uart2  leave Rx and Tx open)

... then type in the screen... it will appear as though nothing is happening... characters are going out Tx and into oblivion.

... now, jumper across Rx -- Tx.   Again, type on the keyboard in screen...  this time the characters that you type will appear in your window;  the characters are going out Tx and then right back into Rx;  wrap, or loopback.

You can use this trick to test your uartx ports, test your comm package, and make sure things are working before you try to connect the uart2 in a project where other factors will complicate debugging.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#4
(12-08-2016, 11:12 PM)MarkHaysHarris777 Wrote:
(12-08-2016, 10:08 PM)psychedup Wrote: >$ screen /dev/ttyS2 115200

If you're using a USB UART adapter make sure it's set up to run on 3.3 volts.

I will add :
  uart2:  /dev/ttyS2
  uart3:  /dev/ttyS3
  uart4:  /dev/ttyS4

You will probably want to do one of the following:

   sudo chmod 0777 /dev/ttyS2

or

   sudo usermod -aG dialout  username

Fantastic!  Are there any more general guides on how to interface with the various IO ports that don't really exist in the PC linux world?

I've dealt with microcontrollers, and I've dealt with PCs, but this is my first venture into Linux where I will deal with GPIO, UART, I2C, etc.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pine64 / V 13x Serial Port wrong permissions /ttyUSB0 maxtox 1 3,004 10-14-2016, 11:33 PM
Last Post: MarkHaysHarris777

Forum Jump:


Users browsing this thread: 1 Guest(s)