I'm using Raspberry Pi 2 to realize RS232 communication between raspberry and my laptop. It seems that my Raspberry Pi can send data, but it can get nothing from my laptop. The following information are about what I've done:

  1. I installed a GPIO UART Shield with RS232 on my Raspberry Pi.

  2. Edit the file /boot/cmdline.txt, and delete the line

console=ttyAMA0, 115200 kgdbooc=ttyAMA0, 115200

Edit the file /etc/inittab, comment the last sentence:

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
  1. Installed python-serial module

In Python 2.7 environment, I tried following commands:

import serial
ser=serial.Serial("/dev/ttyAMA0", 9600, timeout=5)

On a laptop, I ran a RS232 debug tool. In it, I could directly see the characters "hello". Then, I typed "abcde" on my laptop and pressed "send with every 2 seconds". On Raspberry I executed the following command:


The first time, the data was received, but when I executed the command again, third time, fourth time... nothing was received. The following are the commands I tried, but every time I got " '' "


> ''


> ''


> 0

But still, I can use ser.write() to send data. And after send, I can read, but only one time.

Then I gave the python environment, and used minicom, but the situation was same:

As long as I typed any characters in minicom, the data could be sent to my laptop immediately. But when I tried to send data from the laptop, at first time, minicom can display the data, then, nothing, and always nothing.

Could anyone tell me what the problem is?


I found that only after some data was sent by raspberry, it could receive data! I did following tests:

In raspberry, I executed:

>>import serial

On my laptop, I could receive "a", and I sent "abcde" from my laptop. In respberry I could receive "abcde":


Sent "abcde" from laptop again. In raspberry:

'' #Nothing received
0 #Nothing received
1 #"a" was sent successfully 
'abcde' #Data received!

If I executed ser.write(""), still, nothing could be received! It seemed that only after data could be sent successfully, raspberry could read the data! Did any one meet the same situation ?

  • 1
    I started to edit the format, but realised the post is so full of spelling errors and other carelessness that I don't really know what you mean. – Milliways Oct 19 '15 at 6:33
  • You should also pass on data format, as in, 5/6/7/8 bytes, No / even / odd parity, 1 / 2 stop bytes. Not sure what the default values are for them. – dhruvvyas90 Oct 19 '15 at 7:31
  • How can I pass on data format ? <br/>Pass these parameters in serial.Serial() function ? Could you give me an example ? Thanks – Aaron Yang Oct 19 '15 at 9:21
  • What shield? /dev/ttyAMA0 is TTL (0-3.3V) not RS232 level (-15/15V). Could you provide details of the shield and a photo of the connections? – joan Oct 19 '15 at 10:45
  • @joan : here is the photo: <br/> !photo. – Aaron Yang Oct 19 '15 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.