Several slaves on I2C (RTC + MPC23008)

Hello everybody,

With an Arduino Micro, I want connect two slaves on I2C bus.

The first esclave is a multiplexer MCP23008. When this component is alone, with address 0x20 or 0x27, all is done. (the LED on GP0 is blinking )
But when I want add the Tiny RTC module on the I2C bus, the blinking LED is stopped.

The modules I2C are connected on pin 2 (SDA) and 3 (SCL) on Arduino, in parallel.

Could you help me ?

Thank
Aurélien (FR)

#include <Wire.h>
#include "Adafruit_MCP23008.h"
#include "RTClib.h"

// Basic toggle test for i/o expansion. flips pin #0 of a MCP23008 i2c
// pin expander up and down. Public domain

// Connect pin #1 of the expander to Analog 5 (i2c clock)
// Connect pin #2 of the expander to Analog 4 (i2c data)
// Connect pins #3, 4 and 5 of the expander to ground (address selection)
// Connect pin #6 and 18 of the expander to 5V (power and reset disable)
// Connect pin #9 of the expander to ground (common ground)

// Output #0 is on pin 10 so connect an LED or whatever from that to ground

Adafruit_MCP23008 mcp;
RTC_Millis rtc;
  
void setup() {
  Serial.begin(9600);  
  mcp.begin(0x27);      // use default address 0
    rtc.begin(DateTime(__DATE__, __TIME__));
    Serial.println("Démarrage");

  mcp.pinMode(0, OUTPUT);
}


// flip the pin #0 up and down

void loop() {
    DateTime now = rtc.now();
    Serial.print(now.hour(), DEC);
    Serial.print(" ");
    Serial.print(now.minute(), DEC);
    Serial.print(" ");
    Serial.println(now.second(), DEC);
    
  delay(1000);

  mcp.digitalWrite(0, HIGH);  

  delay(1000);

  mcp.digitalWrite(0, LOW);
}

Hi Aurélien

Do you have pullup resistors on SDA and SCL? What value are they?

Have you tried running the I2C Scanner with just the RTC connected to check that the Arduino can see it?

http://playground.arduino.cc/Main/I2cScanner

Regards

Ray

AurelienC: The first esclave is a multiplexer MCP23008. When this component is alone, with address 0x20 or 0x27, all is done. (the LED on GP0 is blinking )

You don't appear to be defining the RTC. A typical command is

define DS1307_ADDRESS 0x68

Thank for your responses

Nick_Pyner -> This command is defined in the RTClib, I think

Hackscribble -> I haven't resistor. Now I have a 4K7 resistor. But the problem is same.

When the MCP23008 is alone, the scan is OK, but when the Tyni RTC is wired, the scan not done

Now I have a 4K7 resistor.

Do you have two resistors, one from SDA to +5V and the other from SCL to +5V?

What results do you get from scan if you disconnect the MCP23008 and only have the RTC connected?

AurelienC: Nick_Pyner -> This command is defined in the RTClib, I think

OK you might be right, I initially made the definition without using a library

Yes, I have two resistors well-connected

When I connect the Tiny RTC, I think the Arduino is stopped, I have no information via Serial...

My RTC module is down ?

Maybe the problem could be on the wiring.Post how did you wire it

Here

IMG_20140607_222746.jpg

When I connect the Tiny RTC, I think the Arduino is stopped, I have no information via Serial... My RTC module is down ?

As a basic test, try disconnecting the RTC and load the simple "blink LED" example program into the Arduino. Once it is running, connect the RTC +5V and 0V connections. Does the LED keep blinking?

The LED blink with or without the RTC module.

But, I have tested with Arduino UNO besides Arduino MICRO and the scanner I2C is same. When I connect the RTC module, the scan is stopped, the Arduino stop to send by Serial conenction.

With a program on Arduino UNO with only the RTC module, the time is OK (but if I disconnect the module, the time is even correct).

I’m lost !

Attached :
Picture 1 : without RTC
Picture 2 : with RTC