I'm wiring together my Arduino uno to a keypad through PCF8574. At the same time, I want to control the RTC (DS1307). Depends on the way I connect them, I'm having trouble getting Arduino to talk to both devices.
If I connect them both to the same SDA/SCL lines from the Arduino (see pic), the I2C scanner can only find the PCF8574, but not the DS1307. If I unplug the PCF8574 SDA/SCL lines, then the I2C scanner will find the DS1307.
Which Arduino board do you use ?
Did you add pullup resistors ? Which value ?
Can you give links to the modules ? (links to where you bought them).
How did you connect it ? Did you connect the GNDs ? Did you power everything with 5V ?
How long are the wires ? Do you use a cable ? What kind of cable ?
I think that the PCF8574 module has connected both the SDA pins and both the SCL pins. In theory there is no difference between the two pictures. If you can make it work that way, that means that you are on the very edge of working and not-working. That's why I ask all those questions
I'm using an Arduino UNO R3, and I'm using the pins labeled SDA / SCL.
I did not add any pull up resistors; my understanding is that the UNO already has them on those pins and that the PCF8574 has weak internal pull ups as well (I'm not using the interrupt pin, that'd require a pull up I think).
Grounds on both the DS1307 and PCF8574 are connected to the same Arduino GND.
Power is 5V for all.
This is all on a breadboard right now, so cables are pretty short; they're just prototype jumper wires and dupont jumper wires.
Well, that is all done correctly. Nothing wrong with that.
The PCF8574 module has 10k pullup resistors for SDA and SCL.
The kit has a DS3231 module, and I see 4k7 pullup resistors there. The DS3231 can work in DS1307-compatible mode.
Combined pullup: 10k // 4k7 // 30k internal = 2889 Ω
Sink current : 5V / 2889 = 2 mA
That means the I2C bus is also okay.
There are a few things that you can measure to get more information.
Breadboards have often bad contacts. When the GND has a bad contact, then anything can happen. Can you put everything in other pins on the breadboard ?
Can you measure the 5V pin ? Is it above 4.5V ? Could you try another USB cable ?
Can you measure the sink current for SDA and SCL ? Perhaps the wrong pullup resistors are on those modules (it happens). Make a sketch with Wire.begin() in setup() and a empty loop(). Let it run with both modules connected and measure the shortcut current from SDA to GND and the shortcut current from SCL to GND. It should be near the 2 mA that I have calculated. A value of 0.5 mA to 3 mA is okay.
Someone on this forum had a project that didn't work well and it turned out that one of the jumper wires was broken internally :o Can you check that, or use other wires ? I don't use those wires, I use single core wires.
Did you put a battery in that DS3231 RTC module ? Can you remove it ? That module will overcharge a rechargeable battery when the module is used at 5V. Remove the charging circuit (remove the diode) to use a normal battery or use a 5V supercap instead of a battery.
The PCF8574 module is preventing the DS1307 (DS3231) to work. You could remove the two smd pullup resistors on the PCF8574 module, maybe there is something wrong with them. Or buy an other PCF8574 module.
The final solution is to make something similar with other parts: an other computer, other USB cables, an other Arduino board and other modules from a different brand and a different seller. Let's hope you don't have to go there