Not detecting I2C devices

Hi -

I have read through some of the posts on I2C problems, but not sure mine is due to resistor values as I have swopped it out with just about everything you can find between 4.7k and 10k :see_no_evil:

I have build several of these devices before, so also pretty sure the PCB design is not the problem. There is one difference between the previous and latests design and that is that I simply removed the I2C Multiplexer as we now only have 3 x I2C populated on the board for this particular project, so they are now connected directly to the µC SDA/SCL pins with a PU on each.

I used the code below to scan for I2C devices, my coding skills are terrible, but found this scanner in the forum and just replaced Serial.print with Particle.publish.

// Simple Scanner ///////////////

#include "application.h"

void setup()

{
  Wire.begin(); 
  Serial.begin(115200); 
  
  while (!Serial) Particle.process();
  Particle.publish("I2C Scanner", PRIVATE);
}

void loop()

{
  byte error, address; //variable for error and I2C address
  int nDevices;

  Particle.publish("Scanning", PRIVATE);

  nDevices = 0;
  for (address = 1; address < 127; address++ )
  
   delay(10);
  
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Particle.publish("I2C device found at address 0x", PRIVATE);
      
      if (address < 16)
        Particle.publish("0", PRIVATE);
        Particle.publish("Found I2C 0x" + String(address,HEX), PRIVATE);
        nDevices++;
    }
    else if (error == 4)
    {
      Particle.publish("Unknown error at address 0x", PRIVATE);
      if (address < 16)
        Particle.publish("0", PRIVATE);
        Particle.publish("Found I2C 0x" + String(address,HEX), PRIVATE);
    }
      
  }
  
  if (nDevices == 0)
    Particle.publish("No I2C devices found", PRIVATE);
  else

    Particle.publish("done", PRIVATE);

  delay(5000); 

    
}

The devices are ABRACON 1805 RTC and MAX17055 fuel gauge. Reflow seem absolutely fine, actually one of best to date, no bridges at all :grinning_face_with_smiling_eyes:

Am I missing something obvious?

Regards, Friedl.

Do you mean you have three sets of pull-ups (6 resistors in total)?
If so, that’s not right since you’d then have the pull-ups in parallel giving you only a third of the individual values.

Other than that we don’t have enough info to advise better.

  • How exactly are your signal lines wired?
  • What level are you pulling up to?
  • Have you checked the continuity of your signal lines between sensors and µC?
  • Have you checked the voltage levels on the signal lines (either end)?
  • Can you get a oscilloscope/logic analyzer trace of your signal lines?
  • Do you get any Particle.publish() event - if so what exactly?

Also, if you haven’t got a Serial client connected, this line might pose an issue as it may keep the code flow stuck at that line :wink:

1 Like

Hey - Long time :slight_smile:

No, only one set.

To answer your questions;

  1. I can send you the board file if need, but will not be able to in Forum due to NDA. Aside from that, All SCL lines meet prior to PU and from there connect to SCL pin on µC. Same with SDA lines.
  2. 3.3V
  3. Yes I have… working fine. Sorry, should have included this in initial post.
  4. No, will do that now. I removed all other I2C components, only have he AB1805 populated now. I thought maybe one component was placed incorrectly (Ambient sensor with worst possible PIN1 indicator) but seems not to be the problem
  5. Unfortunately I do not have either one. Maybe one day when I am all grown up :slight_smile:
  6. Yes. see below.

Will remove this and see.

Thanks for helping out!
Regards,

Voltage is steady 3.3V… at least as far as my MM is concerned :slight_smile:

@ScruffR -

Could it be due to the fact that the supply voltage to the AB1805 is 3.75V and I have the pull-ups connected to the 3V3 pin on the µC ??

EDIT: I hardwired the PSU to the pull-ups on the I2C lines directly from the same PSU that feed the AB1805 - no change, still no I2C devices found :man_shrugging:t2:

Regards,
Friedl.

Hi,
@friedl_1977 maybe, AB1805 is blown/damaged ? regarding to the data sheet Absolute Maximum Ratings for Vcc and Vbat is 3.8V
AB1805_abs_max_r

1 Like

Hi @dreamER -

Hhmm… Sorry, I should learn to be more thorough in explaining, I just went according to the pin name on our initial schematic design. The actual voltage supplied by the regulator is 3.75V which means the AB1805 is getting supply voltage of 3.75 :slight_smile: Also, there are two other I2C devices, one which is 5V tolerant and neither one of them seems to be working :confused:

We have been powering these devices like this for the past year or so, the only change was now removing the Multiplexer, connecting all I2C lines directly to the µC.

Solved by removing the external pull-ups altogether. Scanner code posted is for some reason not working. Serial scanner detected I2C after external pull-ups were removed.

Thanks @no1089

1 Like

You can only publish once per second on average. You’re far exceeding that if you have more than once I2C device. If you exceed the limit, the events may be discarded.

For an I2C scanner, it’s best to scan the whole bus and publish the results as a single string if you want to publish it, but usually it’s easier to just use USB debug serial.

1 Like

HI @rickkas7 -

Thank you for the feedback. I know I am terrible at coding. Will see whether I can fix it, will maybe include
delay(1000);. in the IF statement :relaxed:

Just on that note, at the time of writing the post, I had only the AB1805 populated; I removed the other two devices, so if I understand correctly then this should not have been a problem. This was however before the external PU’s were removed.

Thanks again!!
Friedl

Are you using bare AB1805s or some sort of breakout?
If the sensor (breakout) comes with its own set of pull-ups you may run into the same issue as mentioned above (parallel resistances reduce the total).

1 Like

Hi @ScruffR -

Bare components, no breakout boards. After removing the PU’s on the I2C lines, it seems to be working just fine. I populated more components, serial scanner is now detecting all of them. I am working on my other scanner that publishes to the cloud, got it working as well, just the string needs formatting. Trying to figure that out.

Thanks for helping!!
Friedl.

Hi -

Here is my simple once-off I2C scanner code.

This scanner publishes to Particle Cloud as apposed to printing to serial monitor. It is just basic scanner to see whether all I2C components are detected before handing the hardware to the real programmers :grinning_face_with_smiling_eyes:

/*
    /////////////// Simple I2C Scanner  ///////////////
*/

#include "Wire.h"

void setup() {

     delay(1000);

    Wire.begin();
    Particle.publish("\Scanner ready!", PRIVATE);

      for (uint8_t addr = 0; addr<=127; addr++) {
        
        delay(10);

        Wire.beginTransmission(addr);
        if (!Wire.endTransmission()) {
          Particle.publish("Found I2C 0x" + String(addr,HEX), PRIVATE);

      }
    }

    Particle.publish("done", PRIVATE);
}

void loop() 
    {
    }  

See results below:

Feel free to improve, I am pretty sure this is far from perfect, but gets the job done for me :slight_smile: Hope it helps someone.

Regards
Friedl