RS232 Adapter for Raspberry Pi

RS232 Adapter board for the Raspberry pi

IMG_0136

Adding an RS232 Adapter board using the ADM3202E

 This project adds an RS232 adapter to the raspberry pi using the ADM3202E level translator connected to Uart available on the GPIO Expansion port. The part is available as a 16 pin DIP so it makes it easier to solder…

RS232 Schematic

The two pins of interest are the TXD and RXD pins located on pins 22 and 23 of the GPIO header, this is linked to the expansion board using a 26 way socket. The TXD and RXD pins are then routed to the logic interface of the ADM3202E. The level translator is powered from the 3.3V supply available on pin 1 of the GPIO header this means no level translation is needed for TXD and RXD.

C1 to C5 are 100nF capacitors that for the charge pump to give the higher voltage supplies the level translator needs. The logic level converted signals are then fed to a DB9 RS232 connector as shown in the picture below.

RS232 Adapter

The board is a single layer through hole board as shown below

Rs232-1

This board is compatible with the original Model A & B Raspberry Pi’s with the 26 way connector

Compatibility with Raspberry Pi Models

 

The bill of materials for this project is

QTY              PART-REFS           VALUE

—————–

Capacitors

———-

5                    C1-C5                   100nF

Integrated Circuits

——————-

1                     U1                         ADM3202

Miscellaneous

————-

1                      CN1                     CONN-DIL26

1                      J1                        CONN-D9F

Connect the RS232 port up to another computer and run hyper terminal with settings of 115200 baud 8 bit 1 stop bit with no flow control. Make sure to change the settings in device manager as well if using a USB to RS232 converter, I also enabled the Received FIFO in the advanced settings.

Now reboot your raspberry pi and you should see in hyper terminal a reboot script something like below, type in your password and your good to go….

Broadcast message from root@raspberrypi (Mon Dec 17 18:14:40 2012):

The system is going down for reboot NOW!

[  288.168835] Restarting system.

[    0.000000] Initializing cgroup subsys cpu

[    0.000000] Linux version 3.1.9+ (dc4@dc4-arm-01) (gcc version 4.5.1 (Broadco

m-2708) ) #168 PREEMPT Sat Jul 14 18:56:31 BST 2012

[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr

=00c5387d

[    0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction ca

che

[    0.000000] Machine: BCM2708

[    0.000000] Memory policy: ECC disabled, Data cache writeback

[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pag

es: 48768

[    0.000000] Kernel command line: dma.dmachans=0x3c bcm2708_fb.fbwidth=960 bcm

2708_fb.fbheight=704 bcm2708.boardrev=0x2 bcm2708.serial=0x8590e77b smsc95xx.mac

addr=B8:27:EB:90:E7:7B dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA

0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline root

wait

[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)

[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)

[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)

[    0.000000] Memory: 192MB = 192MB total

[    0.000000] Memory: 187880k/187880k available, 8728k reserved, 0K highmem

[    0.000000] Virtual kernel memory layout:

[    0.000000]     vector  : 0xffff0000 – 0xffff1000   (   4 kB)

[    0.000000]     fixmap  : 0xfff00000 – 0xfffe0000   ( 896 kB)

[    0.000000]     DMA     : 0xffc00000 – 0xffe00000   (   2 MB)

[    0.000000]     vmalloc : 0xcc800000 – 0xd8000000   ( 184 MB)

[    0.000000]     lowmem  : 0xc0000000 – 0xcc000000   ( 192 MB)

[    0.000000]     modules : 0xbf000000 – 0xc0000000   (  16 MB)

[    0.000000]       .text : 0xc0008000 – 0xc05943d0   (5681 kB)

[    0.000000]       .init : 0xc0595000 – 0xc05c7000   ( 200 kB)

[    0.000000]       .data : 0xc05c8000 – 0xc05f93b8   ( 197 kB)

[    0.000000]        .bss : 0xc05f93dc – 0xc06c7504   ( 825 kB)

[    0.000000] NR_IRQS:245

[    0.000000] timer_set_mode: unhandled mode:1

[    0.000000] timer_set_mode: unhandled mode:3

[    0.000000] Console: colour dummy device 80×30

[    0.000000] console [tty1] enabled

[    2.759233] Calibrating delay loop… 697.95 BogoMIPS (lpj=3489792)

[    2.818185] pid_max: default: 32768 minimum: 301

[    2.818814] Mount-cache hash table entries: 512

[    2.819477] Initializing cgroup subsys cpuacct

[    2.819596] Initializing cgroup subsys devices

[    2.819648] Initializing cgroup subsys freezer

[    2.819691] Initializing cgroup subsys blkio

[    2.819809] CPU: Testing write buffer coherency: ok

[    2.819945] ftrace: allocating 14801 entries in 44 pages

[    2.893002] hw perfevents: enabled with v6 PMU driver, 3 counters available

[    2.895007] devtmpfs: initialized

[    2.902790] NET: Registered protocol family 16

[    2.904719] vc-mem: mm_vc_mem_phys_addr = 0x00000000

[    2.904786] vc-mem: mm_vc_mem_size      = 0x10000000 (256 MiB)

[    2.905308] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.

[    2.905381] hw-breakpoint: maximum watchpoint size is 4 bytes.

[    2.905429] mailbox: Broadcom VideoCore Mailbox driver

[    2.905545] bcm2708_vcio: mailbox at f200b880

[    2.905653] bcm_power: Broadcom power driver

[    2.905700] bcm_power_open() -> 0

[    2.905732] bcm_power_request(0, 8)

[    3.406426] bcm_mailbox_read -> 00000080, 0

[    3.406473] bcm_power_request -> 0

[    3.406506] Serial: AMBA PL011 UART driver

[    3.406698] dev:f1: ttyAMA0 at MMIO 0x20201000 (irq = 83) is a PL011 rev3

[    3.712408] console [ttyAMA0] enabled

[    3.738231] bio: create slab <bio-0> at 0

[    3.743805] SCSI subsystem initialized

[    3.747850] usbcore: registered new interface driver usbfs

[    3.753648] usbcore: registered new interface driver hub

[    3.759283] usbcore: registered new device driver usb

[    3.765438] Switching to clocksource stc

[    3.774495] Switched to NOHz mode on CPU #0

[    3.788196] FS-Cache: Loaded

[    3.791594] CacheFiles: Loaded

[    3.813148] NET: Registered protocol family 2

[    3.818107] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)

[    3.826684] TCP established hash table entries: 8192 (order: 4, 65536 bytes)

[    3.834218] TCP bind hash table entries: 8192 (order: 3, 32768 bytes)

[    3.840928] TCP: Hash tables configured (established 8192 bind 8192)

[    3.847311] TCP reno registered

[    3.850522] UDP hash table entries: 256 (order: 0, 4096 bytes)

[    3.856415] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

[    3.863279] NET: Registered protocol family 1

[    3.868652] RPC: Registered named UNIX socket transport module.

[    3.874836] RPC: Registered udp transport module.

[    3.879611] RPC: Registered tcp transport module.

[    3.884341] RPC: Registered tcp NFSv4.1 backchannel transport module.

[    3.891182] bcm2708_dma: DMA manager at cc808000

[    3.895946] bcm2708_gpio: bcm2708_gpio_probe c05d00e0

[    3.901616] vc-mem: Videocore memory driver

[    3.906716] audit: initializing netlink socket (disabled)

[    3.912281] type=2000 audit(0.780:1): initialized

[    4.024956] VFS: Disk quotas dquot_6.5.2

[    4.029167] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)

[    4.037191] FS-Cache: Netfs ‘nfs’ registered for caching

[    4.043904] msgmni has been set to 366

[    4.050453] io scheduler noop registered

[    4.054430] io scheduler deadline registered (default)

[    4.059976] io scheduler cfq registered

[    4.064124] BCM2708FB: registering framebuffer (960×704@16)

[    4.070533] bcm2708_fb_set_par info(cb8ec400) 960×704 (960×704), 0, 16

[    4.082459] BCM2708FB: start = cca00000,4d385000 width=960, height=704, bpp=1

6, pitch=1920 size=1351680 success=0

[    4.092355] Console: switching to colour frame buffer device 120×44

[    4.124973] BCM2708FB: register framebuffer (0)

[    4.130487] kgdb: Registered I/O driver kgdboc.

[    4.147260] brd: module loaded

[    4.156899] loop: module loaded

[    4.161211] vcos: [1]: vchiq_init_state: slot_zero = 0xffd80000, is_master =

0

[    4.168846] vcos: [1]: vchiq_init_state: called

[    4.174482] vcos: [1]: vchiq: initialised – version 2 (min 2), device 253.0

[    4.186697] usbcore: registered new interface driver smsc95xx

[    4.197001] cdc_ncm: 04-Aug-2011

   4.204835] usbcore: registered new interface driver cdc_ncm

[    4.215037] dwc_otg: version 2.90b 6-MAY-2010 (platform bus)

[    4.225576] Core Release: 2.80a

[    4.233216] Setting default values for core params

[    4.242447] Finished setting default values for core params

[    4.252767] cc840008 -> 1

[    4.459794] Using Buffer DMA mode

[    4.467353] Periodic Transfer Interrupt Enhancement – disabled

[    4.477643] Multiprocessor Interrupt Enhancement – disabled

[    4.487668] dwc_otg bcm2708_usb: DWC OTG Controller

[    4.497017] dwc_otg bcm2708_usb: new USB bus registered, assigned bus number

1

[    4.508758] dwc_otg bcm2708_usb: irq 75, io mem 0x00000000

[    4.518777] Init: Port Power? op_state=1

[    4.527162] Init: Power Port (0)

[    4.534934] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002

[    4.546258] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=

1

[    4.557981] usb usb1: Product: DWC OTG Controller

[    4.567186] usb usb1: Manufacturer: Linux 3.1.9+ dwc_otg_hcd

[    4.577337] usb usb1: SerialNumber: bcm2708_usb

[    4.587468] hub 1-0:1.0: USB hub found

[    4.595775] hub 1-0:1.0: 1 port detected

[    4.605235] usbcore: registered new interface driver uas

[    4.615003] Initializing USB Mass Storage driver…

[    4.624525] usbcore: registered new interface driver usb-storage

[    4.634989] USB Mass Storage support registered.

[    4.644422] usbcore: registered new interface driver libusual

[    4.655195] mousedev: PS/2 mouse device common for all mice

[    4.665329] cpuidle: using governor ladder

[    4.673886] cpuidle: using governor menu

[    4.682187] sdhci: Secure Digital Host Controller Interface driver

[    4.692577] sdhci: Copyright(c) Pierre Ossman

[    4.701506] bcm_power_open() -> 1

[    4.709896] mmc0: SDHCI controller on BCM2708_Arasan [platform] using platfor

m’s DMA

[    4.722268] mmc0: BCM2708 SDHC host at 0x20300000 DMA 2 IRQ 77

[    4.732586] sdhci-pltfm: SDHCI platform and OF driver helper

[    4.744486] usbcore: registered new interface driver usbhid

[    4.754409] usbhid: USB HID core driver

[    4.771734] TCP cubic registered

[    4.779122] Initializing XFRM netlink socket

[    4.787726] NET: Registered protocol family 17

[    4.798577] Registering the dns_resolver key type

[    4.814361] VFP support v0.3: implementor 41 architecture 1 part 20 variant b

 rev 5

[    4.851179] Waiting for root device /dev/mmcblk0p2…

[    4.867173] mmc0: problem reading SD Status register.

[    4.897037] mmc0: new high speed SDHC card at address b368

[    4.920248] mmcblk0: mmc0:b368 00000 7.51 GiB

[    4.935644]  mmcblk0: p1 p2

[    4.990413] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. O

pts: (null)

[    5.003148] VFS: Mounted root (ext4 filesystem) on device 179:2.

[    5.015056] Freeing init memory: 200K

[    5.049579] usb 1-1: new high speed USB device number 2 using dwc_otg

[    5.280117] usb 1-1: New USB device found, idVendor=0424, idProduct=9512

[    5.291691] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

[    5.306203] hub 1-1:1.0: USB hub found

[    5.314788] hub 1-1:1.0: 3 ports detected

[    5.599862] usb 1-1.1: new high speed USB device number 3 using dwc_otg

[    5.720371] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00

[    5.732605] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber

=0

[    5.749643] smsc95xx v1.0.4

[    5.815775] smsc95xx 1-1.1:1.0: eth0: register ‘smsc95xx’ at usb-bcm2708_usb-

1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:90:e7:7b

[    5.939875] usb 1-1.2: new high speed USB device number 4 using dwc_otg

[    6.051612] usb 1-1.2: New USB device found, idVendor=05e3, idProduct=0608

[    6.073416] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber

=0

[    6.099616] usb 1-1.2: Product: USB2.0 Hub

[    6.120737] hub 1-1.2:1.0: USB hub found

[    6.140104] hub 1-1.2:1.0: 4 ports detected

[    6.440049] usb 1-1.2.1: new low speed USB device number 5 using dwc_otg

[    6.576499] usb 1-1.2.1: New USB device found, idVendor=413c, idProduct=2003

[    6.599610] usb 1-1.2.1: New USB device strings: Mfr=1, Product=2, SerialNumb

er=0

[    6.626546] usb 1-1.2.1: Product: Dell USB Keyboard

[    6.648438] usb 1-1.2.1: Manufacturer: Dell

[    6.674505] input: Dell Dell USB Keyboard as /devices/platform/bcm2708_usb/us

b1/1-1/1-1.2/1-1.2.1/1-1.2.1:1.0/input/input0

[    6.719779] generic-usb 0003:413C:2003.0001: input: USB HID v1.10 Keyboard [D

ell Dell USB Keyboard] on usb-bcm2708_usb-1.2.1/input0

[    6.840048] usb 1-1.2.2: new low speed USB device number 6 using dwc_otg

[    6.974500] usb 1-1.2.2: New USB device found, idVendor=046d, idProduct=c054

[    6.993685] usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumb

er=0

[    7.006974] usb 1-1.2.2: Product: USB Optical Mouse

[    7.017633] usb 1-1.2.2: Manufacturer: Logitech

[    7.040884] input: Logitech USB Optical Mouse as /devices/platform/bcm2708_us

b/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0/input/input1

[    7.073430] generic-usb 0003:046D:C054.0002: input: USB HID v1.11 Mouse [Logi

tech USB Optical Mouse] on usb-bcm2708_usb-1.2.2/input0

[    7.994834] bcm2708_i2c bcm2708_i2c.0: BSC0 Controller at 0x20205000 (irq 79)

[    8.230395] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)

[    8.367762] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79)

[   14.924715] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)

[   15.272446] ### snd_bcm2835_alsa_probe c05d07a0 ############### PROBING FOR b

cm2835 ALSA device (0):(1) ###############

[   15.295802] Creating card…

[   15.305076] Creating device/chip ..

[   15.315779] Adding controls ..

[   15.325161] Registering card ….

[   15.339790] bcm2835 ALSA CARD CREATED!

[   15.363947] ### BCM2835 ALSA driver init OK ###

[   15.435116] i2c /dev entries driver

[   22.568566] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x41

E1

øø

Debian GNU/Linux wheezy/sid raspberrypi ttyAMA0

raspberrypi login: pi

Password:

Last login: Mon Dec 17 18:11:17 GMT 2012 on ttyAMA0

Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent

permitted by applicable law.

Type ‘startx’ to launch a graphical session

pi@raspberrypi:~$

So now that the RS232 interface is working next thing is to get it doing something useful under our control, in order to do that first we’ll need to disable the console and reboot.

In order to do this two files need to be modified

The first one is is found at /etc/inittab open this up in an editor and look for this line

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

to disable it put a Hash character in front of it

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

Now save the file

The next file to modify is /boot/cmdline.txt open this file and remove the text

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

Save the file and now we need to reboot the raspberry pi for the changes to take effect.

Testing the serial port a bit of python…

To test the serial port first connect the raspberry pi to another computer and open a terminal program, I used a USB to serial converter to attach  to a PC and a terminal program called termite.

First go to control panel and set up your USB to serial converter to 9600 baud, 8 bit, No Parity with 1 stop bit and make sure to enable the Uart buffers in advanced. Open up termite a set to the same settings as above.

On the Raspberry pi first make sure that the python serial routines are loaded by typing

sudo apt-get install python-serial

Open up your favorite python editor I use geany and type or download it here

#!/user/bi/env python

import serial

from time import time

Test=serial.Serial(“/dev/ttyAMA0”,9600)

Test.open

Test.write(“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”)

Test.close()

Run the python script and all going well you should see text show up in the terminal window on the PC.