Connecting Serial Devices

Introduction

The RPi has a serial interface called ttyAMA0 and this can be used as a general purpose serial port. The following describes how to use this port and what connections to use. Most BV devices have a serial interface and can be connected this way.
Important: One thing to be aware of is that the serial interface uses 3.3V logic and some 5V devices will output on their TX line 0 to 5V. As far as I know none of the Broadcoms lines are 5V tolerant. A simple 3.3V zenner diode will suffice to limit the voltage.

Preparation

This is specific to the RPi. The serial interface by default is used by the system and so it must first be freed up from that. Also when using Python the serial interface needs installing so there are three things to do:

  1. Disable the kernel log output: There is a text file called cmdline.txt in the /boot directory open this file (sudo nano /boot/cmdline.txt) and remove "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200".
    My cmdline.text file now looks like: "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait" All one line.
  2. Comment out the second line at the bottom of /etc/inittab: (sudo nano /etc/inittab)
 #Spawn a getty on Raspberry Pi serial line
 #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

This will ensure that the operating system does not use the COM port. If it does then anything connected to the port will be effected. This is particularly important if a device that is connected uses a CR to detect the Baud rate. 3. Now install Python serial:

 sudo apt-get install python-serial

The port is called /dev/ttyAMA0 and it is this that we will be using.

Connecting BV212 to RPI

Bv212 pi conect.jpg
NOTE Ther serial device pins may vary - check first
Just 4 wires are normally needed to connect to the RPi. In this instance a BV212 is shown that has an on board 3.3V regulator but needs 5V to operate. The power supply will go to either the 5V or the 3v3 line, consult the individual data sheet for this information.