Raspberry PI and GPIO pins: Control other devices from the serial port

In the previous post in this series, We saw How to control Raspberry PI from the serial port on your PC; Thanks to the port UART and an adapter from TTL to RS232.

Today we see how to reverse the roles, and We will control two devices from the serial port of the PI, a Router and a Switch; for what must make some changes in the configuration default serial port.

For the second example, where connect Raspberry PI to a HP Procurve switch 2610-24; We will need the converter plate of TTL to RS232, already used in previous deliveries; with WRTNode the connection will be direct between ports UART.

TTL converter Rs232
In the first case we will connect to WRTNode, It must simply connect Raspberry PI with WRTNode through its ports UART investing signals; with the table below, and the following scheme will be able to understand it better.
Raspberry PI models to, B, A +, B + WRTNode
GPIO 14 (UART TXD)
GPIO 62 (RXD2)
GPIO 15 (RXD UART) GPIO 75 (TXD2)

Raspberry PI wiring diagram – WRTNode.

The connections between the converter plate of TTL to RS232 and Raspberry they will be the same as in past deliveries, but I attached the explanation concerning the connection; to facilitate monitoring of the practice that we will perform.

Raspberry PI models to, B, A +, B + Plate TTL to RS232 converter
VCC
+ 5V
TX
GPIO 14 (UART TXD)
RX
GPIO 15 (RXD UART)
GND GND
PB150047Conexiones

Raspberry PI wiring diagram – Adapter RS232.

Some converters modules of TTL to RS232 not they should feed externally under any circumstances since they receive the power from port series, and we could burn our Raspberry PI by supercharging; in our case we will use a converter based on chip SP3232EEN, that if we feed from Raspberry through pin VCC Converter plate.

Pinout and extracted from the datasheet of SP3232E wiring diagram, identical to SP3232EEN.

Pinout and wiring diagram extracted from the datasheet of SP3232E, identical to SP3232EEN.

Now we only need connect the HP Procurve switch 2610-24 to the serial port, with a cable RJ45 – RS232 rescued from an old router Cisco; and as both connectors DB9 they are female, We will need a cable RS232 male to male, or bypass the two devices, also crossing TX and RX.

Once everything is connected correctly, We will open the file /etc/inittab in Raspberry and we will discuss the last line; to disable the login via the UART port.

#/etc/inittab original #Spawn to getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty - L ttyAMA0 115200 VT100

Then we can see the last line of the file already commented, This is how it should be.

#/etc/inittab modified #Spawn to getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty - L ttyAMA0 115200 VT100

We must also edit the file /boot/cmdline.txt, by eliminating the reference to /dev/ttyAMA0; so to not display the boot via the port information UART.

#/boot/original cmdline.txt dwc_otg. lpm_enable = 0 Console = ttyAMA0, 115200 kgdboc = ttyAMA0, 115200 Console = tty1 root = / dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait

So the file should be After deleting the text string that refers to the port to which the boot information should be sent.

#/boot/cmdline.txt modified
dwc_otg. lpm_enable = 0 console = tty1 root = / dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait

Then, If you did not already in the previous tutorial; install ckermit, a software to control the serial port; and finally we reboot to apply the previous configuration changes.

pi@raspberry:~$ sudo apt-get install ckermit
pi@raspberry:~$ sudo reboot

The first thing we must do is to tell the device that will work; Raspberry IP by default, ES /dev/ttyAMA0 and with the option -l We are going to indicate to connect.

pi@raspberry:~$ sudo kermit -l /dev/ttyAMA0

Once opened ckermit, It only remains to establish the parameters for each connection; First we will do the test with WRTNode.

(/home/pi) C-Kermit> set speed 115200
(/home/pi) C-Kermit> set parity none
(/home/pi) C-Kermit> set flow-control none
(/home/pi) C-Kermit> set carrier-watch off
(/home/pi) C-Kermit> connect
 
Connecting to /dev/ttyAMA0, speed 115200
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------

Now press the enter key, and we are already in a management terminal of OpenWRT; the firmware of WRTNode.

BusyBox v1.22.1 (2014-08-13 19:31:12 UTC) built-in shell (Ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S F R E E D O M
 -----------------------------------------------------
 BARRIER BREAKER (Bleeding Edge, r41508)
 -----------------------------------------------------
  * 1/2 Oz Galliano Pour all ingredients into
  * 4 Oz cold Coffee an irish coffee mug filled
  * 1 1/2 Oz Dark Rum with crushed ice. Stir.
  * 2 TSP. Crème de Cacao
 -----------------------------------------------------
root@OpenWrt:/#

We do the same with the HP ProCurve switch, more similar to the typical Cisco; e identical in its configuration.

pi@raspberry:~$ sudo kermit -l /dev/ttyAMA0

Now as before, We set the parameters for the connection that will be the same for both cases; Finally click Enter, and we can already login.

(/home/pi) C-Kermit> set speed 115200
(/home/pi) C-Kermit> set parity none
(/home/pi) C-Kermit> set flow-control none
(/home/pi) C-Kermit> set carrier-watch off
(/home/pi) C-Kermit> connect
 
Connecting to /dev/ttyAMA0, speed 115200
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
Connected at 115200 baud
ProCurve J9085A Switch 2610-24
Software revision R.11.07

Copyright (C) 1991-2008 Hewlett-Packard Co. All Rights Reserved.
 RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and Computer Software clause at 52.227-7013.

 HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303

We'd like to keep you up to date about:
 * Software feature updates
 * New product announcements
 * Special events

Please register your products now at: www.ProCurve.com
Press any key to continue
Username: admin
Password: *****

If you like you can follow me on Twitter, Facebook, Google +, LinkedIn, or share it with the buttons under this publication, If you have any questions or suggestions please do not hesitate to comment.

Help us to reach more readers Share on LinkedInShare on FacebookTweet about this on TwitterShare on Google+Email this to someone

Leave a Reply