Raspberry PI dronekit connection error

Hi everybody, I want to explain my problem with my bad english.
I connect from windows computer with UDP and telemetry. No problem. But Raspberry PI also gives an error connect(’/dev/ttyAMA0’,wait_ready = True,baud=57600)

Hi Kadir,

Welcome to the community forum!

Could you please share the command that outputs these messages?

hİ liudmila,
-> Raspberry PI 4 8GB
-> Navio2
-> Python
connection method
connect(’/dev/ttyAMA0’,wait_ready = True,baud=57600)

All Code…

from dronekit import connect,VehicleMode

import time

from enum import Enum

#region araç bağlantı işlemleri

class c_dynamic_vehicle:

def __init__(self):        

    self.copter = object

    self.connected = False

    self.customMessage =''



class enum_connectType(Enum):

ethernet = 0,

telemetry = 1,

RPI = 3


‘’’ Connection type : Bağlıntı şeklini seç ‘’’

connectType = enum_connectType.RPI

vehicleObject = c_dynamic_vehicle()


if (connectType == enum_connectType.telemetry):

    vehicleObject.copter = connect('COM4',wait_ready = True,baud = 57600)        

elif (connectType == enum_connectType.ethernet):

    vehicleObject.copter = connect('',wait_ready = True)        

elif (connectType == enum_connectType.RPI):

    vehicleObject.copter = connect('/dev/ttyAMA0',wait_ready = True,baud=57600)        

vehicleObject.connected = True

vehicleObject.customMessage = 'Connection successful'

except Exception as e:

vehicleObject.connected = False

vehicleObject.customMessage = 'Not Connected, Error Message = ' + str(e)



#region yardımcı metotlar. copter yönetimi haricinde kullanılacak olanlar

class c_global_methods:

def outputMessage(self,message):

    print message



globalMethods = c_global_methods()

#region copter için metotlar

class c_smart_copter_run:

def takeOff(self,aTargetAltitude):

    print "Basic pre-arm checks"        


    while not vehicleObject.copter.is_armable:            

        print " Waiting for vehicle to initialise..."            




    print "Arming motors"

    vehicleObject.copter.mode    = VehicleMode("GUIDED")

    vehicleObject.copter.armed   = True

    while not vehicleObject.copter.armed:            

        print " Waiting for arming..."




    print "Taking off!"        


    while True:            

        print " Altitude: ", vehicleObject.copter.location.global_relative_frame.alt

        if vehicleObject.copter.location.global_relative_frame.alt>=aTargetAltitude*0.95:                

            print "Reached target altitude"






smartCopter = c_smart_copter_run()

if name == “main”:


    print 'Connection : Successfull!'        



    print 'Connection : Error! -> ' + str(vehicleObject.customMessage)

Raspberry PI connect error,
ERROR:dronekit.mavlink:Exception in MAVLink input loop Traceback (most recent call last):
Help me please…
connect(’/dev/ttyAMA0’,wait_ready = True,baud=57600)

Hi Kadir,

As far as I know, this issue might appear because the telemetry is set up at a baud rate of 57600. It takes approximately 2 minutes to download the parameters, and Dronekit times out after 30 seconds.

You may modify _ _ init _ _.py file from Dronekit by changing the timeout parameter to 180 seconds or more.

Hi liudmila,

I did what you said. But this time I got an error like the following. After about 150 seconds

Important! When I connect with UDP connection or telemetry connection in windows and run the same codes, there is no problem. Only on raspberry pi something like this happens

Please help. I have to solve this problem

Hi Kadir,

It’s essential to make sure that you’ve declared the correct port for telemetry modems in the script. If you’re using UART port, it’s /dev/ttyAMA0. With USB, it’s usually /dev/ttyUSB0 but it might change in regards to what exact USB port you’re using.

We’re always glad to be of help with Navio2. However, the Dronekit configuration isn’t the easiest one and requires some programming skills. That’s why we recommend using pre-installed tools like ArduPilot autopilot to control a drone.

Please note that Dronekit is an open-source project mostly made up with the help of contributors. It’s possible some changes in the scripts interfere with the standard configurations. I suggest checking out this workaround that helps to bypass the timeout limitation.