Can't read I2C output


As Im building in indoor “compass” Im trying to read the output of the i2c (compass is forced externa so I should get datal) on a TX2.

As the pixhawk is a I2C-Master I’m using a FDTI UM201X as a USB to i2c slave.

I connected the FTDI slave to the Tx2-Master & could test my communication code, it seems to be working.

I don’t have tools to check if the i2c is working, so I plugged an hmc58XX and was able to make the external compass work in less than a minute (so its not “broken”).

Is there any sequence I need to send to the pixhawk to have it send me something?
(I read the i2c-probe part of the code, and I should get an output, but I get nothing).
And just to confirm there isn’t a mavlink message to set compass values?

thank you for your time.


Im going to give more details.

Final goal is to create a separated driver, but as long as Im unable to receive data from the i2c port starting to make a driver is pointless.

My usb-Slave as been set to the SlaveId = 0x1E (default i2c address for HMC5883).

Here is my sender output:

sudo ./i2c_test
USB Paramter set at [16, 0]. //for USB <->I2c only
Device reset done. //for USB <->I2c only
Flow Control set. //for USB <->I2c only
Read & Write timeout set at 5 ms. //for USB <->I2c only
Latency set at 5. //for USB <->I2c only
EEPROM_READ Succesful:
-VendorID: 0x0403
-ProductID: 0x6015
-DeviceID: 0x00
-Slave_addr: 0x1e //expected address of an HMC device
-Manufacturer: FTDI
-ManufacturerId: FT
-Description: UMFT201XB
-SerialNumber: FT0GBM83
status OK, trying to read something

No Data

No Data //Nothing on Received

while trying to read I rebooted the pixhawk to try to get something out of it.

I checked connections, tested my cables, added pull-up resistor between SDA/VCC & SCL/VCC.

Nothing, I can’t get a single byte from the pixhawk… Im missing something to make the pixhawk start sending me datas.

I keep digging but there is not so much left to dig anymore, and I can’t find my problem.

Added more print to get the status of the hmc5883 probe.
bus is detected.
whoIam is always failing.

So I dug into whoIam() and I can’t really add new output to transfert to identify the probe, but most call except one (the pix4flow) are failing, so Im wondering why I cant even get the “not an HMC device.” from the second if test of whoIam as the first test is already failing…

So I thought that something have to be wrong in my setup.

So I restarted my sender on a Rpi using ioctl I2C read/write calls to verify my receiver.
I can communicate with the FTDI without any troubles.

Back again to try to catch whoIam() register read signal…

I’ll get an osciloscope tommorow to check if the clock is pulled down/up or even exist.

If anyone as a clue that can help me understand what Im doing wrong, its making me crazy.

I can push my receive code if it helps but its really close to the FTDI code sample & function (ctrl+f to FT_EVENT)

FTDI UM201X i2c-Slave

FTDI code sample & function

Why dont you use an Arduino to do this ?
There are tons of support, drivers and sketches to read I2C on an Arduino, and none for the FDTI UM201X


Lot of reasons, most important one is that I can’t use arduino by requirements on my project.

The FTDI is used as I will later make a custom carrier for the Tx1/tx2 including the chip on the board.

The i2c communication protocol of the FTDI is “working” I tried on various OS (any combinaisons of Windows/Raspbain/OSX/Ubuntu14.xx ~ 16.xx) flawlessly.

Im sure Im just not seing something simple, or a pixhawk requirement.

The bus is “probably”* open (I shouldn’t be able to get the “not an HMC device” if it wasn’t), so I can’t be that far from actually having the connection working.

*I will check if I get a clock on SCL as soon as I can get access to an osciloscope.

One of the main reason of my “fake” compass is that my GPS is setting an arbitrary north (also indoor compass error are far too high) and the GPVTG/GPRMC tracks are not matching the compass values.

Another viable solution would be to make an serial driver for the compass, but I tried and its far out of my reach.

Well, in that case you are in uncharted territory :wink:
For probing, unless you have a digital scope with I2C functions, its easier to work with a I2C probe & analyzer like Saleae or BusPirate

Side questions:

  • how hard (and how) could I clone the hmc5883_i2c.h to make it an hmc5883_uart.h?
    (its still my backup plan).

-It just hit me, you said “There are tons of support, drivers and sketches to read I2C on an Arduino” does that mean that the i2c can’t detect or communicate with the FTDI ? (if Im not wrong i2c protocols don’t need drivers to communicate -for understanding each other & interpreting bytes they do but receving & sending operation are “driver-less” or am I wrong?).

-Last but not least in the hypothesis that I could finally include an arduino on the project, any recommendations?

I just made it work, literally 1minute ago…

loop start status 0
out of while 5 <- Rxbytes
after for bytes received 5 RxBytes5 status0
string received: 2, 1, 3, 2, 1,
loop end status 0

Now its a straight line (switch case on possible received values).

(change pullup from 4k7ohm to 10k Ohm).

I dont think that going I2C to Serial would make thing easier. I suspect that this ‘‘alternative route’’ would make sensor fusion inefficient.

As for the Arduino, nearly all the devices do have a library compatible for Arduino, this is how I test most of my I2C components.