Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How do i check whether an I2C device works?

Status
Not open for further replies.

Cecemel

Member level 5
Joined
Apr 16, 2014
Messages
89
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Belgium
Activity points
2,043
Hi,

I ordered a gps and magnetometer module from eBay for my quadcopter. The gps works fine, but i can’t get the I2C mag to work. (I’m using a Matek F405-CTR running iNav.)
Before i ask for a replacement and have to wait for shipping from China, i would like to make sure this one really is broken.

With the mag connected to the flight controller, i probed the SDA and SCL lines with my scope. After disabling the internal I2C barometer, both lines are constantly high, i only get a second of activity when i set the mag to ‘auto’ in the fc’s settings. I suppose the is the fc ‘scanning’ for devices?

When probing both lines of the mag without them being connected to the fc (with a 2.2K pull-up resistor to 5v), i don’t get any activity at all.


Do i need to get a replacement or is there something else i should test?

Thanks
 

Hi,

I assume the GPS device is a I2C slave...
both lines are constantly high
But who is the master?
Both lines high means the bus is idle = the master is doing nothing.
You have to check if the master is working, not the device.

First the master needs to assert I2C_start, then the slave address, then R/W....then the slave has to acknowledge...

Should be easy to verify with a scope..

****
For further discussion please
* post your circuit
* show your code
* tell us what you expect
* and what you see instead..

Klaus
 

The master is working, I know that because the onboard barometer (I2C slave) works.
I’ve been doing some more research and came across an Arduino I2C Scanner sketch. It says it found a device at address 0x0E, so I guess now I just need to find out how I can change the magnetometer address in my fc’s settings.

Thanks for your help.
 

Hi,

The master is working, I know that because the onboard barometer (I2C slave) works.
This just does mean that the MASTER does access the barometer.

But as long as both I2C lines continously stay HIGH the master doesn´t even try to access another device at the bus.

It´s the job of the MASTER to start communication.

Klaus
 

Every I2C slave device has a fixed address to be accessed by the master. So I don't think your flight controller has been sending wrong address to access the magnetometer. First of all, both the lines i.e. SDA and SCL needs to be pulled high (buses in idle case i.e. buses aren't busy and ready to communicate with master whatsoever) with pull up registers (as both lines work on wired AND logic) or no binary data can ever be transmitted over the buses.
And to be precise, the answer to your question particularly to check if an I2C device is working or not, you need to send the start condition ->device address->R/Wbit and then wait for the slave device to acknowledge this master's request by pulling SDA line low. As u have your flight controller sending the above request, you just need to see if the magnetometer is sending the acknowledgement bit (SDA = 0 bit) or not....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top