I2C questions

I have a LCD display that uses I2C, and it was easy to get working once I knew what the address was. It was too bad that I did not find any document that explained the addressing from no jumpers, to how the jumper you add, add up to the address.

The problem I had was when I was using the TintyRTC. It had no way to address it, so I was not sure what to do except to disconnect my LCD before testing the TinyRTC.

Then I noticed that the TinyRTC has two sets of connections, so am I to assume that I can put the I2c LCD on the second set of connections on the TinyRTC?

If I put the TinyRTC on the same set of wires, how do I address the TinyRTC?

Is there a higher level of understanding I can get from someone here, or is there one web site that will tell me everything I ever wanted to know about working with I2C devices on the same wire? Even devices that are not equipped with an address?

I understood that many I2c devices can go on the same two wires, but the fact that some things are not addressable, like the TinyRTC, makes me think that more than one device like that would present a problem.

Thanks to anyone who takes the time to help educate me.

Joe

Then I noticed that the TinyRTC has two sets of connections, so am I to assume that I can put the I2c LCD on the second set of connections on the TinyRTC?

We have no idea what hardware you are talking about. I2C is a bus. Any number of things can be connected to the bus, as long as each has a unique address. So, connecting the LCD to the RTC does not make sense.

If I put the TinyRTC on the same set of wires, how do I address the TinyRTC?

Same set of wires as what? A 440 VAC, 3 phase motor? If you do that, you won't need to worry about it's address. 8)

Even devices that are not equipped with an address?

All I2C devices have addresses.

I've always struggled finding out if I have a connected i2c device until i found this handy i2c scanner.

Hook up each device on the i2c buss by itself and run this test. if both devices have separate addresses hook them up together if both respond it is possible to hve a program access both while connected on the same bus

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
bool blinkState = false;
#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
  pinMode(3, OUTPUT);
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
        blinkState = !blinkState;
        digitalWrite(3, blinkState);
      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

You put up to 127 devices on an i2c bus - just connect the clock and the data of a number of devices to the clock and data line, and it in principle they should all work. If your device has two sets of connections, it's probably for daisy-chaining. That is: the two sets of pins are probably directly connected to one another.

The TinyRTC likely just has extra pins to connect more things in parallel, that's how I2C works.
You might compare to connecting your monitor to your PC, the monitor could have extra USB ports that you plug your mouse & keyboard into vs plugging them into the PC directly.

I guess that I might have expected a sketch that is so simple, and does not need speed, would have defaulted to 9600 baud. When I looked at the program, I could see that it should have been much faster. That corrected the gibberish i was getting.

I'm getting two addresses, 50, and 68. I imagine that the real time clock does not need any other addressing because you would only have one in your sketch. Thanks for the scanner I2C scanner sketch.

Joe

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
bool blinkState = false;
#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
  pinMode(3, OUTPUT);
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
        blinkState = !blinkState;
        digitalWrite(3, blinkState);
      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

[/quote]