Servers by jDrones

How to connect Arduino and Pixhawk together?


(stevenette) #1

Hello, I finally finished my boat, and now need to implement the hardware. I am running into a lot of frustrations right now however.

In addition to many non-generic connectors with every instrument I buy, I am having trouble figuring out how to connect the pixhawk to my arduino. I noticed the pixhawk has DF13 connectors, with converters to JST for the power cable. The pixhawk also came with a cable that has one end JST and the other end female pins for the ICSP connections on the arduino.

My question is: What hardware/software/cables do I need to connect the arduino to the pixhawk by either I2C or Telem2 as some forums have suggested? Any preferences, pros/cons? Do I just connect the serial RX, TX and G pins, or all 6 I2C MISO, SCK, Reset, VCC, MOSI, GND?

Goal: I want to control a boat with gps and sonar with the pixhawk. I then want to record that data to an arduino mega with sd card logger so I can plot it up on a computer when I get home. I am very stuck on the hardware part now between the pixhawk and the arduino.

Thank you in advance!


(ppoirier) #2

Hello,

Most of interface are done using serial and connecting with df13-to- female headers cable assy you can get for 1$ at aliexpress

I am using arduino or ATtiny or Teensy for interfacing sensors directly to PixHawk by “spoofing” existing drivers or by using standard MavLink messages.

In the datacollection you are describing, I think you could make internally the Flight Controler = without the use of a microcontroler…


(stevenette) #3

Thank you for the reply,

  1. Do you know what the connectors are called or have a link to them? There are 34,000 items when i search?

  2. Do you hook up sensors to pixhawk then read them over to your teensy and log them that way?

  3. What do you mean in your third paragraph about using just a flight controller without a microcontroller? Are you saying i could just program everything on the pixhawk and discard the arduino?

I am very adept at arduino, but have never used any kind of rc stuff before. So confused by the number of options to solve the same problem. No idea how to begin.


(Rjiun Raj K) #4

You may follow this link.

https://discuss.ardupilot.org/t/establishing-mavlink-connection-between-arduino-and-pixhawk/13237/6

https://www.google.co.in/search?q=arduino%2Bpixhawk&client=ubuntu&hs=5bo&channel=fs&dcr=0&source=lnms&tbm=isch&sa=X&ved=0ahUKEwir5LOS9e_XAhWHr48KHcN8AOYQ_AUICygC&biw=1280&bih=892#imgrc=vdZZBCMu7q0oUM:

http://ardupilot.org/copter/docs/common-pozyx.html


(stevenette) #5

Ahhh! Thank you so much, I never thought to image search the pin diagram. This is incredibly helpful.

Now I just need to find the female connectors at aliexpress. I want just the connector so I can make a custom length cable between the pixhawk and arduino.


(ppoirier) #6

This is basically what ArduPilot is doing. …and much more !!
As for the Sonar, I guess you want some kind of object avoidance, take a look at this: http://ardupilot.org/dev/docs/code-overview-object-avoidance.html

I suggest that you ‘‘read the book’’ of Ardupilot before trying to ‘‘reinvent the wheel’’. :wink:


(stevenette) #7

Ok, so I guess I can use the pixhawk as a datalogger? I can program arduino really well, so I thought I would make it easier on myself by doing that, but otherwise I could dive deep into programming the pixhawk.


(Rjiun Raj K) #8

you can cut the middle of a telemetry cable and join it with male jumper to connect with arduino.


(stevenette) #9

Ok, I took a break and managed to get absolutely everything working on my boat except the sonar. Apparently the 9600 baud rate of NMEA output is way too slow for pixhawk and would jam everything up. I guess I will still have to go with the pixhawk for navigation, and the arduino for data logging. Please let me know if I am wrong. Thank you!


(rmackay9) #10

Hi Steve,

By the way, which sonar are you using? It seems like a number of people want a sonar connected to their boat so perhaps I/we should write a driver and document the setup on the wiki.


(stevenette) #11

No way!!! You rock my world! I am using (As many other forum users are as well) the airmar DT800 transducer outputting NMEA0183 data. I have gotten it to work on arduino, but then that means I need an arduino board. In addition, the signals are inverted, so I need a serial inverter as well. This requires valuable space and energy on my boat. If there is any way to help, please let me know! The link is here
Airmar DT800 (plastic, not bronze)


(rmackay9) #12

Steve,

I guess this is a guide for how it can be connected to an Arduino and a similar hardware setup could work with the Pixhawk (or other flight controller).

The 9600 baud rate is very low but that won’t slow down the Pixhawk at all because we do the reads in the background. The SERIALx_BAUD would just need to be set to 9600 I think.

The issue is just that we’d need a new RangeFinder driver that understands NMEA. this NMEA decoding guide describes what messages the DST-800 is outputting:

VWVLW - distance travelled through water
YXMTW - mean temperature of water
SDDPT - depth of water
SDDBT - depth below transducer

So it is probably these last two that are most important.

Writing a driver (and more importantly debugging it) is a little tricky without one on my desk… I know someone at Garmin so I might ping him to see if he can get me one.


(rmackay9) #13

Steve,

There’s another person who coincidentally wants to connect a NMEA based sonar as well. The other chat is here and at the bottom you’ll see some instructions for a firmware I wrote today that may work with a NMEA sonar.

If you do decide to give it a go, please be careful because it’s mostly untested. It should be safe but it’s hard to be sure. I should be getting a NMEA sonar next week from echologger.com so I’ll be able to test it myself then. So no pressure!


(stevenette) #14

Hi there,

This is great! Thank you for looking in to this! I actually commented back in August on that first link you sent. The weird thing was that the inverter never worked for me. It worked fine for the GPS I was using, but then started messing everything up once I plugged in the transducer. I also had to plug everything in the exact order I described, or else it also wouldn’t work. It was super super super finicky, and only worked one out of maybe 5 times I power cycled it. Below is the comment if it helps with the pixhawk?

I have a DT800, the RS485 converter that was linked, and an arduino Uno. I hooked up everything to a GPS I have and a serial line was being printed no problem, then trying to hook up to the transducer, and nada. A combination of pulling cables here and inserting cables there, I got lines to finally display, here is what I had to do.

RS485
A <=> NMEA+
B <=> NMEA- AND my TX pin of the arduino!
VCC <=> 5V
gnd <=> ground
RO <=> RX pin of arduino
RE <=> Grnd of arduino

Now this initially didn’t work, UNTIL, I unplugged the ground from the ground terminal on the RS485 leaving the RE ground connected. Then serial lines started displaying

$SDDPT,44.3,4A
$SDDBT,147.7,f,44.3,M,24.6,F
00
$YXMTW,32.5,C*16

I have to plug them in and unplug them in the right order, or else I don’t get anything. If I just hook up the RX and TX to NMEA+ and - respectively, I only get MTW and DBT, but not DPT…No idea why. So confused. Maybe there is a capacitor on there that needs to be charged up, then the ground needs to be taken away?

I will be busy house sitting this week, but if I can find some time before you get your transducer in the mail, I will let you know! Cheers!