Servers by jDrones

MAVLink and Arduino: step by step


(Tim D) #61

Why does the mavlink library not include the 3dr radio packet?

(Juan Pedro) #62

Hi, Tim. Sorry, but I do not understand your remark. MAVLink is the protocol, 3dr is the physical radio link. They are at a different OSI level.

(Tim D) #63

The library is missing this file.

Where did you get the library from?

(Juan Pedro) #64

Ah! Now I get the point to your question. As you indicate, the zip file is not the complete library, it was the version of the library that worked for me at the very begining and it is enough for basic tasks and to gain selfconfidence.

I am planning to rewrite the full article to correct some errors, include some other topics and include the full v1 library. I expect I will have some time for this around August (this year)…

(repaer_dewov) #65

So in my project i want to send information from 2 sonar sensors (one in front and another at the back of UAV) to the autopilot. the schematic shows how i have connected my setup. im having the sonar sensors give its values into the arduino(A2 for front A3 for back) after which i want to use MAVLink commands (sent from the arduino Tx to the pixhawk Rx in telemetry 2 port) to either move the drone or stop it from moving. even just displaying the values at this stage would be enough. I wanted to know how to proceed. I seem to have issues trying to get anything to work together. the mavlink libraries cant be included since it doesnt exist even though i have it in the main arduino folder (C:\Program Files (x86)\Arduino\libraries) as well as the project directory (C:\Users\Dewov\Desktop\ArduMavlink\libraries). the arduino keeps showing that there is no file or directory with that name. i have tried using #include <mavlink.h> as well as #include <C:\Users\Dewov\Desktop\ArduMavlink\libraries/mavlink.h>.
I need to know how else do you get Mavlink Libraries into the arduino IDE. (importing ZIP and manually dint seem to work)
Also how do i send a MAVLink Message to the Pixhawk to make it stop? hold position or height hold.
Any help would be greatly appreciated. even if its just pointing me to other sources to read up on. (most of what ive been looking for seem to be old and outdated giving me the 404 page.)

(Xenopoulos) #66

Dear LeiroJuan,
thank you for PM to me your code! It was really useful for me.

(Juan Pedro) #67

Hi, @trovesmurf:

It looks that your main problem is installing the library in the IDE. Check this link, the third section and revert in case you continue having problems.

(repaer_dewov) #68

Hi @jplopezll,
Thanks for the suggestion! that was the issue and after a bit of trial and error. i got the libraries installed. i would like to follow up however with regards to what messages you can send through MAVLink in order to get the sensor inputs displayed on the screen constantly. at the moment i use Proximity from the Ctrl+F menu on mission planner to view the sensor inputs. example is shown below. i would like to know if there was a way of making it appear automatically or through as message i can send as a MAVLink message from the Arduino to refresh it every time it takes a sensor reading. Thank you once again.

(Mike S) #69

Hi @jplopezll
I want to say thank you for this. Its the best I have seen. I have been struggling with reading mavlink messages on the Arduino. Was basically making it more complicated.

I am actually going in the opposite direction. Basically going from the Teensy 3.5 as a controller with mavlink going to a GCS (APM Planner in my guess) over 3dr clones. Sending messages from the Arduino to the GCS is working like a charm but having some challenges going from the GCS to the controller is giving me headaches.

Just by way of letting you know where I am. I updated my code to your comm receive method and that helped. Thank you for that. I am able to send waypoints from the GCS to the controller but having a two problems that maybe you can help me with:

  1. I am using a joystick as a controller as opposed to RC. I was able to disable all RC inputs and the GCS is saying its transmitting a manual control message. But I am not seeing it on the controller side. Is there some other trick to get this to work?
  2. I can’t seem to set param values from the GCS to controller? How would you do that?

Any help would be appreciated it.


(Mike S) #70

Just by way of an update got manual_control messages to work by updating the mavlink library to the latest v1. Still can not figure out how to set_param from the ground planner to the teensy.

(Iqra Imtiaz) #71

do you have any experience with tiva?

(Juan Pedro) #72

Hi, @iqra_imtiaz. Sorry, no experience with that…

(Selim) #73

ı use arduplot 2.8. ı want to communicate with ardunio mega .
my schematic is here

And ı want to see this data on ardunio mega serial port.veri%20g%C3%B6r%C3%BCntleri

how can ı make this application.
please help me :slight_smile:

(Juan Pedro) #74

Hi, Selim:

As you can read in the Arduino reference, the Mega has three additional serial ports: see here. Leave Serial for the USB monitor and use any of the extra seral ports of the Mega for MAVLink communications.

Regarding what streams to request what data, please re-read the post:

Hope this helps. Kind regards.

(Selim) #75

Thank you for answer
Could you write a simple code for read only altitude . I have to hurry :frowning: .
Please help me.

(jpkh) #76

@Selim this is not a simple code that you are asking here. Code needs to include MAVLink libraries and use them.

Best and fasttest way to understand what all is needed would be to take a look old MinimOSD or jD-IOBoard mavlink-frsky bridge code. On IOBoard code you can find examples how to extract mavlink messages. After you extract wanted messages, printing them additional serial port is easy.

Old code repository is here:

Not sure if that old code compiles anymore with latest MAVLink libraries but it wont be that hard to make it work again.

(Lorenzo) #77

Hi ! Thanks for your great tutorial! is very useful!

I think is clear for me how to receive some data from the pixhawk.
but how can i send a command (in particular a mission) from the arduino to the pixhawk?
could you please help me?

(Lorenzo) #78

another question. why you connect directly the arduino considering the pixhawk serial is on 3.3V ?

(Juan Pedro) #79

I connect directly because it is 5V tolerant and works without further hardware…

(Lorenzo) #80

i tried with an arduino nano clone and pixhawk mini but it doesn’t work. is 5v tollerant as well?