Page 1 of 1

Connecting Rasp Pi 2 to Dell D630 via serial port

Posted: Wed Aug 19, 2015 8:21 pm
by tastyminerals
I want to connect old Dell Latitude D630 laptop with my Raspberry pi 2 via serial port. I have been following tutorial on this page http://elinux.org/RPi_Serial_Connection and another here http://www.instructables.com/id/Read-an ... pberry-Pi/.
Unfortunately I can't transmit any data from raspberry to dell laptop. I have created a small python script which uses serial module to listen to port every second and output the result. This script is started on Dell laptop. On my raspberry I am running another script that simply writes the keyboard input to serial port. I can see that something is transmitted because every time I type in a message and hit enter small orange light indicator blinks on my level shifter, and when running screen /dev/ttyAMA0 115200 it blinks with every keystroke I make, so something is going on. However the script on my dell laptop that runs in a loop reading its serial port /dev/ttyS0 reports nothing.
Here is the script used on Dell laptop:

Code: Select all

#!/usr/bin/env python
import time
import serial
ser = serial.Serial(
   port='/dev/ttyS0',
   baudrate = 115200,
   parity=serial.PARITY_NONE,
   stopbits=serial.STOPBITS_ONE,
   bytesize=serial.EIGHTBITS,
   timeout=1
)
	
while 1:
   print 'SERIAL PORT:', ser.readline()
   time.spleep(1)
Raspberry pi script

Code: Select all

#!/usr/bin/env python
import time
import serial
ser = serial.Serial(
   port='/dev/ttyAMA0',
   baudrate = 115200,
   parity=serial.PARITY_NONE,
   stopbits=serial.STOPBITS_ONE,
   bytesize=serial.EIGHTBITS,
   timeout=1
)
	
while 1:
   message = input('>> ')
   ser.write(message)
   time.spleep(1)
As I mentioned above with all connected and set up the first script outputs nothing when I am writing to port on raspberry pi.
Needless to say that I tried various things, like screen, minicom and even java pi4j implementation -- the message is not transmitted from raspberry to dell although the light indicator is blinking.
Both user of Dell and Rasppi is in "dialout" group, rasp pi has its ttyAMA0 port open and working.
I am attaching photos of how the rasp pi is connected to the laptop, take a look please. So, my question is -- what am I doing wrong? Maybe I should just write and read to the same port on the same machine? How do I transmit data then?
Image
Image
Image
Image

Re: Connecting Rasp Pi 2 to Dell D630 via serial port

Posted: Thu Aug 20, 2015 6:43 am
by rpdom
If the LED on the module is flashing when you press keys on the Pi I'd say the Pi is wired correctly and working and you need to look at the laptop end of things.

Is the cable to the laptop the correct one? You probably need cross-over instead of straight-through.
The simplest wiring of a cross-over cable is pin 2 to pin 3, pin 3 to pin 2 and pin 5 to pin 5.

Is the laptop serial port configured for soft flow-control only? (No DTS/RCS etc).

Do any indicators on the module blink when you press keys on the laptop?

Re: Connecting Rasp Pi 2 to Dell D630 via serial port

Posted: Thu Aug 20, 2015 6:52 am
by KLL
i see in a other example that a
ser.write(input + '\r\n') included a add sending CRLF, because on the other side you wait for
a complete line by ser.readline()
your keyboard ENTER could be eaten by the input! and not be part of the string

Re: Connecting Rasp Pi 2 to Dell D630 via serial port

Posted: Thu Aug 20, 2015 6:01 pm
by tastyminerals
rpdom wrote:If the LED on the module is flashing when you press keys on the Pi I'd say the Pi is wired correctly and working and you need to look at the laptop end of things.

Is the cable to the laptop the correct one? You probably need cross-over instead of straight-through.
The simplest wiring of a cross-over cable is pin 2 to pin 3, pin 3 to pin 2 and pin 5 to pin 5.

Is the laptop serial port configured for soft flow-control only? (No DTS/RCS etc).

Do any indicators on the module blink when you press keys on the laptop?
Well, to be honest this is my first time with raspberry pi and serial ports. I managed to send messages from rasppi to laptop only after I reconnected the pins. So in order to send from rasppi to laptop I connected transmit pin to transmit pin on the level shifter and ground pin to ground. That's it, only two. Only then I was able to listen to /dev/ttyS0 on my laptop and receive some data that was sent from pi. In order to send the data from laptop to rasp pi surprisingly I need to change the wire on raspi to receive pin and leave the rest as it is. Then I am able to send data from laptop to rasppi. This is strange because in various tutorials connection should be the way it is on the photos. Moreover when I am printing out the received data on my laptop I see garbled strings, like punctuation instead of "1" or "2" that I send from pi, but I think that's just my laptop.

Re: Connecting Rasp Pi 2 to Dell D630 via serial port

Posted: Thu Aug 20, 2015 6:02 pm
by tastyminerals
KLL wrote:i see in a other example that a
ser.write(input + '\r\n') included a add sending CRLF, because on the other side you wait for
a complete line by ser.readline()
your keyboard ENTER could be eaten by the input! and not be part of the string
I see, yes it makes sense. Thank you.