1

I have 2 I2C devices that uses the same address. One of them is the DS3231 RTC. I use this library for the DS3231. I dont want to mess with the other one cause it is way more complicated then this one.:

#include <DS3231.h>

http://www.rinkydinkelectronics.com/library.php?id=73

Then, there is an object declaration for the real time clock:

DS3231 rtc(SDA, SCL);

I wounder if I can change that to:

DS3231 rtc(A0, A1);

I've seen the library but I haven't understand it yet (duh... I'm so stupid!). But is it possible to use an other pair of pins for I2C communication.

Note that I've already tried to use the soft I2C library but I really want to avoid it because it is just too much. If it is the final solution then so be it.

asked Oct 12, 2016 at 12:26
6
  • I suspect it wouldn't work because of interrupts and stuff. Its really a question against the Wire library, because I suspect that's what it uses underneath. Commented Oct 12, 2016 at 12:42
  • If you can't get it to work you might want to look at a I2C Multiplexer (ti.com/product/PCA9544A) or in a board (hobbytronics.co.uk/…). From a quick glance it looks like these might do the job and they are relatively cheep (~£5). Commented Oct 12, 2016 at 12:47
  • 1
    Have you read the big yellow block on the web page you link to? It kind of answers your question quite succinctly. Commented Oct 12, 2016 at 12:50
  • 1
    What is the other I2C device? Commented Oct 12, 2016 at 13:02
  • The library above is actually software I2C (from what I can see in the source code). Commented Oct 12, 2016 at 13:08

2 Answers 2

2

You can change the address of the GY-521 by pulling the AD0 pin to Vcc. After that the address will be 0x69 instead of 0x68.

answered Oct 12, 2016 at 15:02
2
  • Thanks, I also have to add this line in my code. But it should work fine: MPU6050 mpu(0x69); Commented Oct 12, 2016 at 15:28
  • Great. Good point about changing the code to select the correct address. Would be very helpful for others with the same problem. Commented Oct 12, 2016 at 17:46
1

Ok, so I've realise that the anwser was somewhat on the page of the library (that I completly ignored). I can change the pins like I did because the library uses a "TWI-/I2C-like protocol".

The library has not been tested in combination with the Wire library and I have no idea if they can share pins. Do not send me any questions about this. If you experience problems with pin-sharing you can move the DS3231/DS3232 SDA and SCL pins to any available pins on your development board. This library will in this case fall back to a software-based, TWI-/I2C-like protocol which will require exclusive access to the pins used.

answered Oct 12, 2016 at 13:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.