I'm trying to read communication from a Curtis motor controller to my Pi 2. Serial communication is normally Idle=High and the start bit is low. The motor controller however has a Idle low, and a high start bit. So using pyserial to read just gives random characters. The output of the motor controller is being stepped down to 3.3V, the encoding is ascii.

-0 4P!3@"7 %^=!      

-^!\8( 4P!7 @!3 %.   

- K@"

How would I be able to read in the data successfully?

  • Do you only need to read the data from the motor controller?
    – joan
    Mar 17, 2016 at 22:10
  • 3
    Are you using the correct baud rate? Mar 18, 2016 at 0:04
  • Yeah I only need to read data from the motor controller.
    – Yogesh
    Mar 23, 2016 at 0:37

2 Answers 2


The following untested code may work. Untested as I don't have a device which inverts the logic.

Change the baud rate to suit.

#!/usr/bin/env python

# serial_invert.py
# 2016-03-18
# Public Domain

import time
import pigpio # http://abyz.me.uk/rpi/pigpio/python.html


pi = pigpio.pi()

if not pi.connected:

pigpio.exceptions = False # Ignore error if already set as bit bang read.

pi.bb_serial_read_open(RXD, 9600) # Set baud rate here.

pigpio.exceptions = True

pi.bb_serial_invert(RXD, 1) # Invert line logic.

stop = time.time() + 60.0

while time.time() < stop:

   (count, data) = pi.bb_serial_read(RXD)
   if count:





I added an inverter between the TXD and RXD GPIO so I could test the code.

The following shows RXD is the inverse of TXD.

Inverted RXD from TXD

The received data is interpreted as gibberish until the line logic is inverted (slri command)

$ pigs slro 15 9600 8 # Open RXD for bit bang serial read.
$ echo "Hello" >/dev/ttyAMA0
$ pigs slr 15 100
14 171 211 210 82 42 235 0 171 211 210 82 42 235 0 # Gibberish
$ echo "Hello" >/dev/ttyAMA0
$ echo "Hello" >/dev/ttyAMA0
$ pigs -a slr 15 100
21 \xab\xd3\xd2R*\xeb\x00\xab\xd3\xd2R*\xeb\x00\xab\xd3 # Gibberish
$ pigs slri 15 1 # Now invert line logic.
$ echo "Hello" >/dev/ttyAMA0
$ pigs -a slr 15 100
7 Hello\x0d\x0a
$ echo "The lazy brown fox jumps over the sleeping dog" >/dev/ttyAMA0
$ pigs -a slr 15 100
48 The lazy brown fox jumps over the sleeping dog\x0d\x0a

Possible problems:

Ground Connection

As well as TX and RX, you will need a common ground between the two devices.


The Pi's standard baudrate is 115200, while most modules are 9600, and some are different, make sure you are using the correct baudrate.

  • We had the baud rate to 9600 in our code to match with the motor controller output rate, and we do have a common ground. So those unfortunately aren't the issues.
    – Yogesh
    Mar 23, 2016 at 0:35
  • Please, could you take a look at my question?
    – joninx
    Jan 15, 2018 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.