My A4 and A5 pins are already hooked up to a LCD and I want to connect a MPU6050 as well. In a separate thread, someone told me to use SoftI2CMaster library to use other pins as SDA ans SCL. But I don't quite know how to do that. I want to use A2 and A3 for I2C, and a code snippet would be very helpful.

  • Are there no examples in the SoftI2CMaster library? – Majenko May 28 at 17:47
  • I tried following them, but got a lot of errors, a lot of them – SQLinjector May 28 at 17:55
  • 3
    in previous question it was ultrasonic sensor on A4 and A5. now it is LCD. has the LCD I2C interface? I2C is a bus. you can wire more I2C devices to the I2C pins – Juraj May 28 at 18:00
  • Yeah the LCD's got I2C. Tried wiring them like that, didn't work. – SQLinjector May 28 at 18:06
  • Oh and yeah, my bad. Wrote ultrasonic sensor by mistake : / – SQLinjector May 28 at 18:07

Use both devices on I2C, with different addresses. Hook it up like this

enter image description here

And call each transmission with a different address

void setup() {   
  Wire.begin();                           //begin the wire comunication  

Image and snippet from electronoob's very complete tutorial

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.