We have two sensor one of them(MPU6050-gyro) is communicating using I2C, the other is via SPI(SD card reader). Now, we need an additional component as a sensor that the barometer which communicates via I2C.

Can we use all three modules without any problem? I wonder if two I2C modules is used in a hassle-free manner? Otherwise, what can be done?


Yes, that's the idea behind bus protocols like i2c. You only require the sensors on i2c to have different bus adresses. A sensor's address usually can be chosen by soldering a jumper (the mpu6050 provides this feature on pin AD0). If you can't avoid an address collision you could use an i2c multiplexer or a microcontroller in between the sensor and the actual mcu (but probably that's not neccessary when using only two sensors).

Using SPI and I2C at the same time is absolutely no problem on the atmega!


I2C is a bus. There can be many devices connected to that bus, each one having it's own address. Everytime you want to communicate with one of them, you have to send the address of the device. When you are using the Wire library, thats done by calling Wire.beginTransmission() or Wire.requestFrom(). Most slave devices have an adress, that is partly configurable, often by wiring special pins to Vcc or ground. Make sure, that every device on the bus has a unique address, or you will run into problems with corrupted data or a stuck bus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.