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: You can see this in person in two weeks for our next live event with real cars. It's great fun for adults and kids alike, and…
DIY Robocars via Twitter
RT @chr1sa: The final race (1:24) at yesterday's @DIYRobcars virtual event was our best. It's only two minutes long but it has everything,…
DIY Robocars via Twitter
RT @chr1sa: The monthly @diyrobocars virtual race is starting now!
Mike Whitney liked Mike Whitney's profile
Jul 19
DIY Robocars via Twitter
Jul 2
DIY Robocars via Twitter
Jun 26
Abdulatif Tlaib liked Ryan's profile
Jun 24
DIY Robocars via Twitter
RT @SmallpixelCar: First time at @wsraceways. After tuning @HokuyoUsa lidar signal and camera sensor on @NVIDIAEmbedded, my car was able to…
Jun 20
DIY Robocars via Twitter
RT @breadcentric: The handy bit about racing with self-driving cars is that one can type while the car is racing. Report from #AWSDeepRacer…
Jun 18
DIY Robocars via Twitter
RT @chr1sa: Our Bay Area @DIYRobocars meetup is now at 2,700 members. Next in-person events (in Oakland) are training day on July 17 and…
Jun 18
DIY Robocars via Twitter
Videos from the ICRA autonomous racing workshop are now available:
Jun 10
DIY Robocars via Twitter
RT @SmallpixelCar: Prepared race track for Warm Spring Raceways @wsraceways and looking forward to test my new car at RAMS RC @ramsaicar fa…
Jun 6
DIY Robocars via Twitter
RT @f1tenth: Trying out some nasty blocking maneuvers 🏎️🤖 #f1tenth #autonomousracing
Jun 5
DIY Robocars via Twitter
May 27
DIY Robocars via Twitter
RT @araffin2: I will talk this Saturday from 18:00 to 19:00 Paris time for the @diyrobocars community about learning to race in hours using…
May 27
DIY Robocars via Twitter
RT @a1k0n: Luckily the infeasible hairpin problem was easily reproducible in simulation and I could test the fix before bringing the car ba…
May 26