[python-uk] Pyserial on Raspberry Pi returning just "\x00" ie NULL characters

John Pinner funthyme at gmail.com
Mon Jul 2 15:06:43 CEST 2012

Hello Michael,

On 2 July 2012 13:45, Michael <sparks.m at gmail.com> wrote:
> Hi,
> Probably a little off topic, but posting here in the hope that someone
> else has tried connecting a Rasp Pi to an arduino using the arduino's
> built in usbserial device. (ie like you would with a "normal" linux
> box).
> Ignoring all the app details, if I have a piece of code that's like this:
> import serial
> ser = serial.Serial("/dev/ttyUSB0", 9600)
> while True:
>    print repr(ser.read())
> Then on a normal linux box, I'm getting back values I'd expect. On the
> raspberrypi, I'm simply getting back "\x00" characters.
> In my actual code, I'm both sending and receiving data. The curious
> oddity here is that I appear to be receiving the correct *number* of
> characters, and appear to also be sending the right number (based on
> the flashing of the RX light on the arduino).
> However, whilst they're the right number of characters, the actual
> characters, being NULLs, are clearly wrong.
> I'm guessing that this is actually nothing to do with python and more
> a driver issue on the Pi, but on the off chance it is a python issue
> or something someone else here has seen before I thought it worth
> posting and asking.

> If anyone's interested, the context of this is using and RFID tag
> reader (plugged into the Pi - which I have working to cause motors to
> spin on another device. The reason for the arduino here rather than
> faffing with the Pi's pins is a) it'd be faff with the Pi's pins b) I
> have an arduino with built in servo control circuits - essentially an
> Arduino duemilanove clone with a motor shield combined c) I had all
> the bits and really didn't expect serial connection to/from the Pi to
> be where I'd get issues!
> Any suggestions (good or bad :), comments or sympathy welcome :-)

There are known problems with the Pi USB :

* Some possible driver issues (to do with mixed high- and low-speed
devices on the same hub.
* Power capacity.

For example, I have a rather nice IBM USB keyboard, if I use that at
the same time as a USB wifi dongle, the wifi stops working. A cheapo
Kensington keyboard works fine.


* Checking for a healthy 4.75 - 5.25 volts between TP1 and TP2 on the Pi.
* Installing an updated Pi kernel. Dom has just done a beta Wheezy
image, which he thinks may have fixed the USB driver problem, but he
wants feedback:


* Using a decent quality *powered* USB hub (>=2.0 amps)

> baffled-of-the-north,

I know how you feel.

Best wishes,


More information about the python-uk mailing list