How to connect Arduino and Pixhawk together?

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!

1 Like

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ā€¦

1 Like

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.

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

1 Like

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.

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: Copter Object Avoidance ā€” Dev documentation

I suggest that you ā€˜ā€˜read the bookā€™ā€™ of Ardupilot before trying to ā€˜ā€˜reinvent the wheelā€™ā€™. :wink:

1 Like

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.

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

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!

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.

1 Like

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)

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.

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!

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!

1 Like

Dear ppoirier
Iā€™m facing a similar problem: I must connect a Pixhawk flight controller of a hexa, to an ARDUINO NANO collecting signals from several sensors. The measurements mast be available inside the MP. The hexa is controlled through python scripting inside the MP. Can you please explain in more details, how are you ā€œspoofingā€ existing drivers to communicate with the Pixhawk either using Telem2, either using I2C? Are there commands for MAVLINK to communicate with serial or I2C? The sentences to be read from ARDUINO are in the form: "1001,41.139234,24.912345,67.25,12,14, ā€¦;ā€?
Thanking you in advance.

Hello, I suggest you start a new discussion explaining in detail what you are planning to do, this way we will be able to better help. You can post in other hardware

Dear ppoirier, I have already done it here:

https://discuss.ardupilot.org/t/data-transfer-from-arduino-to-pixhawk-through-serial-or-i2c/29973

Thank you very much for your interest!
Ioannis

I have been doing something similar with a boat. My approach was was to connect the Pixhawk to the Arduino Mega using Serial.
The Arduino reads the Mavlink messages sent from the Pixhawk and extracts the latitude,longitude,Date, Time and mode.
The sonar has a CAN connection and is connected to the Arduino Mega through a sparkfun CAN Shield.
In the software on the Mega all this data is combined and saved to an SD Card on Sparkfun Shield.

I would have liked to see the depth in mission planner but havnā€™t figured that out yet.

1 Like

related to this, Weā€™ve recently added a DPTH message into the dataflash log so that we record the lat, lon and depth of a downward facing echosounder. This change is included in Rover-3.4.1-rc1.

The key requirements for this to be recorded are:

  • echosounder needs to be connected to the pixhawk (wiki)
  • RNGFND_ORIENT should be set to 25 (pointing down)
  • the vehicle must be a boat (FRAME_CLASS = 2)

Viewing the depth in real-time on the ground station (i.e. mission planner or equivalent) is possible with Rover-3.4 (and earlier even). If using the MPā€™s ā€œQuickā€ or ā€œStatusā€ tab (found on bottom left of the Flight Data screen) select ā€œsonarrangeā€. I tested this last week with the ECT400 echosounder and it seemed to work OK.

Randy thanks again looks like I will need to do a CAN to serial conversion and feed it back through the serial port as nmea sentence.