Pixhawk 2.1 with maxbotic I2CXL-maxsonar-EZ issues

Hey guys,

I’ve been playing around with the Maxbotic I2CXL sonar for a day now and can’t seem to get it to talk to the pixhawk 2. Started out by connecting it to the I2C 2 port on the PH2 and configuring parameters as seen here: http://ardupilot.org/copter/docs/common-rangefinder-maxbotixi2c.html?highlight=i2c
I confirmed that I was getting 5.2V to the sonar and I can see the voltage on the SDL, pin 4, varying when powered up on the bench. I then tried to set the RNGFND_ADD to 112 as specified in the sonar’s datasheet to no luck. Finally I tried the initial setup however using the RNDFND 2 parameters (I was thinking maybe with the RNDFND 2 paramters set it would look for data from the I2C 2 port) which hasnt worked. So all in all the sonar is getting power and I am reasonably sure that its taking readings however the PH2 is not talking to or can’t see the sonar sensor. How do I get these devices to talk to each other? Any advice or suggestions is appreciated and thank you in advance.

Will F

1 Like

Hi Will,

Unfortunately for now ArduPilot is only looking at only one of the I2C buses in PH2.1 - the one connected to the GPS1 port. Here is the issue tracking this problem: https://github.com/ArduPilot/ardupilot/issues/5831


Ah I see. Thanks for the heads up I’ll be sure to check out the issues page to keep myself in the loop. But just to be clear I’m running ArduCopter 3.4.5, so this I2C issue affects all of ArduPilot, copter, plane, rover… correct?

Will F

It’s the same for 3.4.5 - with 99.9% certainty, that version won’t be fixed as it still used the old PX4Firmware drivers which are harder to work with. Probably 3.5.0 won’t have it either (as we want to release it as soon as possible), but a patch should be easy enough that it will most likely be fixed in a 3.5.X release.

Just to explain a little better: the Pixhawk only has one external I2C bus and that’s what the team is used to; now with PH2.1 the I2C bus that was internal in the Pixhawk was made external too and we are still adjusting to that - at the same time we changed to using our own drivers (which are now shared with Linux boards) so we can take our time to have everything working as expected by all users. And yes, this affects all of ArduPilot vehicles.

I believe I am having a similar issue as was explained in this post, but I wanted to make sure I am understanding this perfectly. I have a pixhawk mini that is running 3.5.0-rc3 (quad X config) that I am trying to be able to use for precision landing with IR-Lock. Currently I have connected to the I2C port the GPS, a pixy camera and a sonar detector. Does this mean that the device is only able to communicate with the GPS and is not communicating at all with the sonar and camera?

I unfortunately didnt find this information from Oxinarf. Now that I’ve found it, I understand and I’ve fixed my issues (I2C related on Pixhawk 2.1 only).

If you want this I2C device to work, you need to hack into the I2C located on the GPS1 port - until they implement support for the other I2C busses.

I have a HERE gps. In my case I spliced the following wires, spliced a 4pin I2C cable in (do it nice - use solder and shrink tube and make sure your connections are done well, or find someone who can) Here connector is with the pins up - purple on right - I2C cable is pins up - red on right:

HERE GPS - Pin 1 Purple 5V = I2C cable Pin 1 (Red)
HERE GPS - Pin 4 Yellow I2C SCL = I2C cable Pin 3
HERE GPS - Pin 5 Orange I2C SDA = I2C cable Pin 2
HERE GPS - PIN 8 Black Gnd = I2C Cable Pin 4

Plug this 4 pin cable into your old I2C splitter, or if you used a new JST cable (like what comes with PH2.1) and want to use your new I2C splitter, it’s the same pinout - pins up - VCC on right.

Don’t feel real great about hacking into the new GPS cable, but I have several I2C devices and would like to both use them and test new firmware with my new Pixhawk 2.1. And now I can.

Hope it helps.

1 Like

Thank for this, i have this issue on my pixhawk2 and i can’t use lidar on the second I2C port.

Is the I2C port of the second GPS is the same as the first GPS ?
So perhaps we can use it without cut the first GPS cable ?

i need to test…

tested, that doesn’t work…

Were you able to get more than one Sonar working? It seems like if you accessing the I2C through the GPS port that ardupilot actually see’s, then your only able to hook up one sonar, until support for the second I2C port comes in?

I’m pretty sure on the Cube the gps2 port is on the internal i2c bus. And unless they implemented support for the internal or second bus in 3.5 RC6…it isn’t being read by AP.

I know for sure nothing but the oled display will read off of that bus in AP.

I’m running at least 4…maybe 5 accessories wired as I described without issue. I do have the higher current devices powered externally however.

There were some issues with sonar not being read in this RC.

So is anyone able to get SONAR or LIDAR or any object avoidance system to work on the latest version of ardupilot with the pixhawk 2.1?

I use a lidar lite or a terra ranger one (pix 2.1 and copter 3.4.6).
but with a custom cable for taking i2c on the first gps port.

Awesome, could you share your pinout on the custom wiring? Any idea if this will work with the maxbotics sonar sensors as well?


the pinout of the first gps port, you juste need a y cable for the i2c pin.
be careful with the 5V, perhaps you need an external power supply.
and there is no reason that the maxbotix sonar wouldn’t work.

1 Like

Awesome thank you much for that! So all I do is splice (not cut and replace as the GPS still needs it?) in the appropriate wires into the GPS1 port with the I2C plug and then I should be able to have AP read the sonar connected?

Can by any chance I connect an additional sonar, or does the additional need to be seen separately on another port?

Why do you say be careful with the 5V from the pixhawk? Just make sure im not over driving it? So to be safe run a 5v PS?


I just realized the sonar im using is the analog XL sonars not the i2c. Here is how its supposed to be connected to the pixhawk:


Im not sure how to hook it up to the 2.1, its ADC port has 3 wires, and I cant find a pinout like you provided above. Could you let me know where to findthe 2.1 pinouts? I dont see them in the literature here from the downloads folder:


This is the Sonar I am using:


Can someone explain how the compass is the GPS can work if the range finder is also wired to the SCL and SDA pins? I’m can’t see how both the compass and rangefinder can be wired to the same pins?

I2C is a serial bus : all devices have an indivifdual adress and the FC is the master that initiate conmunication by sending the sensor adress first and then send an instruction or read a value

Ah right great, that makes sense. Didn’t realise it worked like that with my analog brain. Might actually consider hacking my Here GPS cable now. I have the 1240 sensor which I’ve had some success using the analog output (cos i ddidn’t want to hack the GPS cable without knowing it would work). When I say some success I mean I’m getting a voltage that roughly changes when I move the copter around on the bench.
When I arm and fly however it’s not current working. In the field it just got stuck at 6.5m and didn’t do anything else. Read the troubleshooting guide and I think it’s most likely noise on the power supply for which I’m going to wire in a filter as advised here:

It could also be radiated noise, acoustic noise or vibration but I’m trying the power filter first, then Ill try moving the sensor further away from the motors etc onto the copter landing gear. Soft mounting is also something i’ll try.
If all that doesn’t work I’ll try I2C but one quick question - reading the manual it looks like I can output either I2C or analog becasue it has pins for both, however elsewhere on the internet it says you need to order a different sensor depending on whether you want analog or I2C.
Can anyone clarify that.

The I2C is the MB1242 look here

Sonar are not very effective as rangefinder, lidar are much better.