Need help for serial comunication

Hello, i have to try something.

I have an Raspberry Pi witch sends variables over serial ( ttyUSB0) over the usb cable.

I want to read this serial bytes with the Ardupilot over usb or other serial input, may some one help me to save those bytes in variables on the Ardupilot?

I dont realy understand if this is working, because i dont realy understand if i have to use mavlink, or if i can read those bytes directly.



You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Dear sir,

    Can you please explain what will this code do?I need to establish communication between APM and odroid-U3 and send mavlink messages using UDP protocol to GCS so that telemetry link can be established and seen at Qground Control.

  • Dear Tommy Larsen,

    What will the above code do? I want to get telemetry data from APM to RPi using mavlink protocol and send it to ground control using UDP or TCP.How can I do that?

  • From where does mavlink.h file comes

    • Hi

      you can download it from here

      MAVLink Micro Air Vehicle Protocol
      The standard communication protocol for drones. MAVLink Micro Air Vehicle Protocol has 27 repositories available. Follow their code on GitHub.
      • Dear sir ,

        I am trying to have communication between autopilot and odroid-U3 over mavlink protocol to get the telmetry link and send it using UDP/TCP protocol to the Qground control.How should I use the above code to do the same? 

        • They are libraries. You should write your own code for your communication these libraries are for encode and decode the mavlink package. First it is hard to understand but you can find explanation for packages in code as comments they are very helpful.

  • I am using Atom board with APM 2.5 onboard on a Hexacopter. I am using USB port to communicate between them. I have also used the 3DR radio for their communication but the baud-rate is slow (57600) as compare to wire USB connection (115200). The python code which is used for communication is available at (I am logging all the APM data in ROS-framework).

    Hope this helps!

    • Hey Usman,

      Through you code I can communicate between APM and some computer say ordoid-U3. Now I need to send the mavlink message to GCS using TCP/UDP protocol.Can you help me in that?

  • Hey i use Linux (debian) in the Pi. I only want to send Commands from the pi to the copter. The pi is plugged in via USB to the apm. I can't fin a good documentation, how I can send an receive commands. I found a nice API where all commands are in, but I can't find anything to send them to the apm.
    What I want is that the pi can set the apm to arm, disarm. Position hold and loiter.
    Thx for helping
    Btw I use c code
  • You can do both, it is possible to read the bytes you want straight from the port, but this might be a bit complicated since there is some mavlink stuff going on usually so you would need to know what kind of messages you want to pick from the stream, and essentially you will be doing same sort of things that the mavlink does allready.

    Easier is to just use the mavlink package, which is available on c++ and python. It is fairly straightforward to even implement your own messages if needed.

This reply was deleted.


DIY Robocars via Twitter
RT @chr1sa: Just a week to go before our next @DIYRobocars race at @circuitlaunch, complete with famous Brazilian BBQ. It's free, fun for k…
DIY Robocars via Twitter
How to use the new @donkey_car graphical UI to edit driving data for better training
Nov 28
DIY Robocars via Twitter
RT @SmallpixelCar: Wrote a program to find the light positions at @circuitlaunch. Here is the hypothesis of the light locations updating ba…
Nov 26
DIY Robocars via Twitter
RT @SmallpixelCar: Broke my @HokuyoUsa Lidar today. Luckily the non-cone localization, based on @a1k0n LightSLAM idea, works. It will help…
Nov 25
DIY Robocars via Twitter
@gclue_akira CC @NVIDIAEmbedded
Nov 23
DIY Robocars via Twitter
RT @luxonis: OAK-D PoE Autonomous Vehicle (Courtesy of zonyl in our Discord:
Nov 23
DIY Robocars via Twitter
RT @f1tenth: It is getting dark and rainy on the F1TENTH racetrack in the @LGSVLSimulator. Testing out the new flood lights for the racetra…
Nov 23
DIY Robocars via Twitter
RT @JoeSpeeds: Live Now! Alex of @IndyAChallenge winning @TU_Muenchen team talking about their racing strategy and open source @OpenRobotic…
Nov 20
DIY Robocars via Twitter
RT @DAVGtech: Live NOW! Alexander Wischnewski of Indy Autonomous Challenge winning TUM team talking racing @diyrobocars @Heavy02011 @Ottawa…
Nov 20
DIY Robocars via Twitter
Incredible training performance with Donkeycar
Nov 9
DIY Robocars via Twitter
RT @JoeSpeeds: Sat Nov 6 Virtual DonkeyCar (and other cars, too) Race. So bring any car? @diyrobocars @IndyAChallenge…
Oct 31
DIY Robocars via Twitter
RT @JoeSpeeds: @chr1sa awesomely scary to see in person as our $1M robot almost clipped the walls as it spun at 140mph. But it was also awe…
Oct 29
DIY Robocars via Twitter
RT @chr1sa: Hey, @a1k0n's amazing "localize by the ceiling lights" @diyrobocars made @hackaday! It's consistently been the fastest in our…
Oct 25
DIY Robocars via Twitter
RT @IMS: It’s only fitting that @BostonDynamics Spot is waving the green flag for today’s @IndyAChallenge! Watch LIVE 👉…
Oct 23
DIY Robocars via Twitter
RT @IndyAChallenge: Congratulations to @TU_Muenchen the winners of the historic @IndyAChallenge and $1M. The first autonomous racecar comp…
Oct 23
DIY Robocars via Twitter
RT @JoeSpeeds: 🏎@TU_Muenchen #ROS 2 @EclipseCyclone #DDS #Zenoh 137mph. Saturday 10am EDT @IndyAChallenge @Twitch
Oct 23