I2C port causes system to behave unpredictably

We use Navio+ device for our project. We have 3DR GPS+Compass combo (https://store.3dr.com/products/3dr-gps-ublox-with-compass) and whenever we connect it to I2C port, the whole system acts strange: the props start spinning up without any arming right after power up (very dangerous), intermittently impossible to arm from RC remote, sometimes system just hangs. We actually only use the magnetometer part of the 3DR GPS+Compass, not using the GPS.

We also have an external status LED that connects to I2C port. When that LED is connected directly to I2C port it works, but when connected via an I2C splitter, it doesn’t work, even though with Pixhawk the same setup works.

It is important for us to use external magnetometer to avoid magnetic interference (we cannot relocate Navio+ much inside the case) and as of now we simply cannot make it work with Navio+.

I’ve looked at the output of i2cdetect while external magnetometer is connected and it is very strange: it shows some devices disappear intermittently and shows some other devices that are not even there.

Here’s the output of i2cdetect executed multiple times in the row with external magnetometer connected to I2C port:

pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: 03 -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77 pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77 pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- 28 29 2a 2b 2c 2d 2e 2f 30: 30 31 32 33 34 35 36 37 38 39 3a UU 3c 3d 3e 3f 40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77 pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@navio-rpi ~ $

So do we have a faulty Navio+ or is it incompatible with 3DR compass? Why does the system behave this way?

Thank you for your help!

We had a case on the forum of a faulty I2C splitter, it may be the reason for LED not working with it. Also, maybe the wires get too long with the splitter.

Can you try running i2cdetect without external devices connected a few times? Is the output the same every time?

Without connected devices the I2C port functions correctly and output of i2cdetect is the same every time:

pi@navio-rpi ~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77

I have tried changing the frequency of I2C in /etc/modprobe.d/i2c.conf to 100KHz and 400KHz and when connecting 3DR magnetometer directly/no splitter, the i2cdetect produced different/bogus results just like in the original post. Here’s what was in i2c.conf:

options i2c_bcm2708 baudrate=400000 and options i2c_bcm2708 baudrate=100000

I rebooted the system after changing the /etc/modprobe.d/i2c.conf. Is this a correct way to change the frequency?

Also, as for LED, I have tried using multiple/different I2C splitters, same result, LED doesn’t work. However, the wires are pretty long on it, 30cm total, and it could be not working be due to that like you said. But then again, same LED+splitter does work with Pixhawk for some reason.

One more question: We will possibly need to have 3-4 devices connected to I2C. We have ordered a few Navio 2 from you, guys, as well and waiting for delivery. Is Navio 2’s I2C also pretty busy or is it more ‘freed up’ and will allow for more devices connected to it?

I2C is really not suited for long wires. Pixhawk has a slower I2C by default so it should work with longer wires.
I2C on Navio2 is less busy, it only has a barometer there.

Do you have a UART cable connected? 3DR GPS+Compass is powered only through the 6-pin UART port, not I2C 4-pin. If you only have an I2C cable connected then compass chip won’t power properly and may cause problems on the bus.

Alright, the 3DR magnetometer started being recognized by i2cdetect when I connected the power to 6-pin UART. However, I cannot make external 3DR be the primary compass for some reason. I tried messing with parameters in APM (COMPASS_EXTERNAL(2|), COMPASS_ORIENT(2)), but only rotating the Navio makes heading change in Mission Panner. Rotating external compass doesn’t change the heading in mission planner. Connecting that 3DR compass only skews the yaw vs internal compass, even though both external 3DR compass and Navio are aligned the same. What are the proper parameters to set the external compass as primary?

Also I still could not make the i2c LED work with a splitter. We’ve received Navio2 today (thanks!) and it doesn’t work with splitter neither with Navio+ nor with Navio2. I’ve changed the baudrate in /etc/modprobe.d/i2c.conf all the way to 9600 and no result. I’m still not sure if modifying i2c.conf is enough to change i2c port speed. Also in Navio2 there’s no i2c.conf in /etc/modprobe.d, so I just made one like in navio+, but it still doesn’t work even at very low speeds. Any idea?

The original 3dr gps +compass needed an orientation setting of “roll 180°”, if I remember correctly. The compass module is soldered to the underside of the pcb.

Your external compass becomes Compass #1 when you plug it in to APM. Disable Compass #2 when you plug in your external compass.

I still cannot get external compass to do anything. I’ve tried setting:
COMPASS_USE = 1
COMPASS_USE2 = 0
COMPASS_USE3 = 0
COMPASS_EXTERNAL = 1

Also tried COMPASS_EXTERNAL = 0, no matter what rotating the external compass doesn’t do anything; rotating the navio still changes the heading though. This give an impression that for some reason external compass doesn’t become compass #1, so I tried:

COMPASS_USE = 0
COMPASS_USE2 = 1
COMPASS_USE3 = 0
COMPASS_EXTERNAL = 0
COMPASS_EXTERN2 = 1
and also
COMPASS_USE = 0 and 1 (compass1 and compass2)

Still, the only way the heading changes is when I rotate the Navio2 (or Navio+) itself, external compass doesn’t change anything.

I was rebooting the system after every parameter change as well to make sure it’s applied. Also I’ve tried a few different 3Dr compasses and those were verified to work with pixhawk.

@Yaroslav_Mudryy rotating the compass will not result in immediate change of the heading, compass affects it slower than accel\gyro. Change of the heading is affected both by Navio2 (accel\gyro) and external compass.

Regarding the LED - you probably need shorter wires. I2C is very sensitive to bus timings and capacity, and there are lots of factors that affect its work: wire lengths, number or sensors, their capacities. Buses aren’t identical on Pixhawk and Navio2 due to these factors.

Hello everyone! I use NAVIO for my project and I have the problem with external RTC ds1307. I connected ds1307 and EEPROM CHIP AT24C32. When i enter command i2cdetect -y 1 i don’t see the ds1307 address (may be 0x68), but i see the address of eeprom chip.

@Osman_Mazinov

Judging by the information from the DS1307 datasheet it only supports 100Khz speed:

The DS1307 operates in the standard mode (100kHz) only.

I2C speed on Navio is set to 1MHz by default. I’d recommend to find an RTC that supports higher speeds.

@mikhail.avkhimenia

Is there a way to change the I2C speed on the Navio2 image? I have an ultrasonic range finder that supports up to 400Khz.

@larssoltmann

Sure, there is. Edit /boot/config.txt. and change i2c_baudrate to 400000.