Go Down

Topic: Is it possible to use I2C with SPI? (Read 950 times) previous topic - next topic


I've got a magnetometer (micromag 3) on SPI and an accelerometer (lis3lv02dq) on I2C, each working independently, through different pins.  I've had some trouble combining the code into one.

I know it's a generic question, but I want to know:  

Is it possible with the arduino?  Is there any factors to consider when integrating them that you don't have to think about when coding the individual interfaces?

(I know it would be far more elegant to have them both on the same SPI bus, since the lis can do SPI, but this is proof of concept and needs to be done quickly)

Many thanks



Are you trying to poll them for data concurrently or one and then the other? Are the pins used for each bus separate?

Are you using the hardware i2c pins and support or are you bit banging i2c?

Your problem is more in what you're doing than a question of possibilities.


I'm *trying* to do it one then the other - I'm wrapping the individual parts in function calls, and calling the ones for I2C THEN the ones for SPI.

I'm using different pins for each bus.

I'm using hardware i2c pins  (analog 4 + 5 on the duemilanove - as used by the wire.h lib).

It's great that it's possible!  It means I'm not barking up the wrong tree. ;)

I'm just having an overhaul/debug of my code, and then I'll post it/the relevant bits.  It's not pretty, but I'm afraid this is my first bit arduino project.


I know it's a generic question, but I want to know:  
Is it possible with the arduino?

Yes it is possible, they use totally different pins and different hardware inside the processor.


Grumpy_mike, there's never been a problem I've had when you haven't been part of the cavalry!  I admire the commitment to giving the newbies a hand-up. :D

I just did my debug/rebuild run, and I sorted out the problem - it's working absolutely fine right now :D!  Thankyou too Kyle, for weighing in.

Ah, the sweet feeling of success!

Go Up