Multiple I2C devices - Need guidance on irresponsive RTC

Hello All,

I am learning about I2C communication on my Arduino Mega 2560. I am trying to use two I2C devices, Sparkfun's HIH6130 temp/humidity breakout board, as well as Sparkfun's DS1307 RTC breakout board. I've gotten each device to work fine individually, but I believe I'm having an issue with either working when wired in parallel.

Running the below code for the RTC and with the HIH6130 completely disconnected, I get a normal response. As soon as I plug the HIH6130 in parallel to the RTC, however, the RTC hangs and the code fails to display any outputs.

I see that the HIH6130 already has 2.2k pull-up resistors to VCC over the SCL and SDA lines. Does this imply that I shouldn't need a pull-up resistor for the RTC if I hook it in parallel? Any guidance on wiring these two breakout boards would be hugely appreciated. I'm a mechanical guy, and circuits can be overwhelming at times.

HIH6130 homepage: SparkFun Humidity and Temperature Sensor Breakout - Si7021 - SEN-13763 - SparkFun Electronics
HIH6130 schematic: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/HIH6130_Breakout_v10.pdf
DS1307 homepage: SparkFun Real Time Clock Module - BOB-12708 - SparkFun Electronics
DS1307 schematic: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/RTC-Module-v13.pdf

#include <Wire.h>

#define DS1307_I2C_ADDRESS 0x68 //the i2C address for the RTC

//variables necessary for the RTC
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte zero;

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

//code for getting time from the RTC
String getTimeDs1307()
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7, true);

  // A few of these need masks because certain bits are control bits
  second     = bcdToDec(Wire.read() & 0x7f);
  minute     = bcdToDec(Wire.read());
  hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.read());
  dayOfMonth = bcdToDec(Wire.read());
  month      = bcdToDec(Wire.read());
  year       = bcdToDec(Wire.read());

  String timeString="";
  timeString += hour, DEC;
  timeString += ":";
  timeString += minute, DEC;
  timeString += ":";
  if (second < 10)
    timeString += "0";
  timeString += second, DEC;
  //Serial.println(timeString);
  return timeString;
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Code is started");
  zero=0x00;
}

void loop() {
  Serial.println(getTimeDs1307());
  delay(3000);
}

I see that the HIH6130 already has 2.2k pull-up resistors to VCC over the SCL and SDA lines. Does this imply that I shouldn't need a pull-up resistor for the RTC if I hook it in parallel?

Yes, pull-up resistors are for the whole bus. Just connect next device to SCL, SDA lines without next pull-up.

The Mega contains pull up resistors as well so you have two lots in parallel. That could be your problem.

Figured it out!

The VCC pin on the HIH6130 was hooked to a de-energized pin on the Arduino, and the 2.2k pull-up resistors were not being utilized in the LOW state. When I attempted to hook the RTC in parallel and run the clock, I could never get it to actually send/receive data. I experimented by switching the VCC pin to HIGH, and the RTC behaved! I used my multimeter to test for conductance over the SDA and VCC pin while the program was running, and would get a small bleep every time the VCC pin was switched to high.

I'm still not sure it makes sense as to why it works... but the moral of the story is to make sure your VCC pin on your pull-up resistors is indeed HIGH.

That sounds an odd way of wiring it up. Pull up resistors should always be connected to the power supply not another pin. Why did you wire them to a pin?

The VCC pin on the HIH6130 was hooked to a de-energized pin on the Arduino, and the 2.2k pull-up resistors were not being utilized in the LOW state.

Then, its pull-up resistors cannot be used for other devices on the bus.