Trying to detect SMBus device with I2C detect

Hi everyone!

I am trying to use the basic I2C detect script to detect a smart battery SMBus address. If I run the scanner with nothing connected, it returns that no devices were found. However, when I connect the SMBus clock and data lines to SDA and SCL on my Uno, it hangs in the serial monitor. I am pretty sure the board already has pull up resistors (Uno SMD)? I was wondering if I could get some guidance here, as I am no expert. I2C detection code is posted below.

// I2C address scanner program
#include <Wire.h>

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  Serial.println("I2C Scanner");
}

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

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

  nDevices = 0;
  for(address = 1; address < 127; 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("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address < 16)
        Serial.print("0");

      Serial.println(address,HEX);
    }
  }

  if (nDevices == 0)
    Serial.println("No I2C devices found");
  else
    Serial.println("done");

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

I will take a SWAG and say looking at your nonexistent schematic you have the wires crossed.

I don't really have a schematic for a two wire set up, but I'll try to draw a mental picture.

SMBus clock pin to SCL on Uno
SMBus data pin to SDA on Uno
shared ground

Do I need more than this? (Also I've checked it both ways, same hanging output no matter which wire is on which pin). I'm not sure if I need external pull-ups or maybe it's something else?

Actual picture is most helpful.
The Uno has the ability to set pull ups, but they are weak. Depending on your exact setup (photo, diagram) you may still run into trouble.




E6 = SMBus clock -> red wire -> Uno SCL

E7 = SMBus data -> orange wire -> Uno SDA

Third wire is on E1 which is just ground and is connected to the GND on Uno digital side.

Nothing else is currently connected atm. I don't want to power anything external with the battery until I can talk to the SMBus first.

Thanks for posting the pics. Everything looks good.

Some questions:

  • What is the voltage that the SMB bus has been set to? Is it for 3.3 or 5V?
  • Battery charged?
  • Do you have a data sheet for the smart battery?
  • Uno I2C tested with other I2C devices?

I found the following info. May be helpful for you to review it. But not sure if it applies to your set up:

The best information I can find on this battery is that it complies with all of the SMBus v1.1 standards. According to the SMBus v1.1 manual, the bus is "designed to operate over a range of voltages between 3 and 5 Volts +/- 10%." That makes me think the Uno's I2C Bus should be ok, no?

The battery is fully charged (according to the little LCD display on top of it).

I have not tested the Uno with any other I2C devices, unfortunately. I may be able to drum something up just to test it. I'll get back to you on that.

1 Like

Ok, I hooked everything up to a dinosaur oscilloscope to determine what the clock and data lines were seeing. Turns out the Uno only pulls down the clock signal to around 1.5-2V. The SMBus requires a CLK Low of at least 0.8V or lower. This makes the Uno technically see the device, but never obtain a returning data signal (this is why it hangs...the SCL signal out just stays low because it never gets anything). So, now I'm hunting an IC I can integrate to handle the signals and send them to the SMBus at the appropriate levels.

What are the voltage levels on E6 / E7 them disconnected from your UNO? It may be they are at 12V which the UNO can not pull down to ground.

The Uno should be able to pull the SCL much lower.
I would certainly check the levels on E6/7.

You could also check the Uno SCL and SDA lines by themselves, if you happen to have a couple of 4.7k, 2.2k or 10k resistors handy:
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.