Check and/or reset i2c pins

Status
Not open for further replies.

gilFuser

Member
Hi everybody.

I don't know what I did wrong, but the i2c pins, that were working fine, are not anymore. None of them. I'm trying to check with the usual i2c scann sketches, using Wire and i2c_t3, with the same results. Either stuck in the "scanning..." phase or having a "No devices found".
Maybe I made a short circuit, or had the + coming from Vin. I don't know. I found some threads about similar problems, but they have so many information, pointing to many different directions, I don't know which one to follow.

So I would like to ask how can I check if I ruined the pins for good, or if I didn't and just made them unresponsive somehow, is there a way to reset them? Like a "restore defaults" or something like that?

B.t.w. Wouldn't be nice if this was in the troubleshooting session? I'm sure a a lot of beginners like me would have to face similar problems, and having an organized way to decouple the problem would be useful for everyone.

best regards,
Gil
 
i2c not working? okay..

want a special how to for the most obvious checks posted all over the forum on several threads that a search can reveal?

i see no code
i see no wiring

i can also see you didnt see the red outline at the top of this page?

we have more questions than you, thats not normal

we dont know if your using proper pullups (if any) nor do we know what teensy you got
 
Last edited:
You're right tonton81. I was sloppy.

Here goes the info
I'm using a Teensy 3.6 and I'm trying to use it with an IMU, the GY-80, but atm I'm only interested in the data from the accelerometer, a ADXL350. As I said, at some point it working. Although I was not using pullups properly. Only later I realized how should I setup the wiring. Now I have one 2.7KΩ between 3.3V and SCL and the same for SDA.

The thing is that when I was passing from the breadboard to a perboard I wired things wrong. I used Vin instead of 3.3V, connected the SCL from the IMU with the SDA from the Teensy (I don't know if that matters).

I tested in all pins possible, SCL/SDA 0 to 2, and I tried with the basic examples/Wire/Scanner, from the Arduino IDE, and the basic_scanner from the i2c_t3 lib. Here are they respectively:
Code:
Code:
 // --------------------------------------
// i2c_scanner
// http://playground.arduino.cc/Main/I2cScanner
//
// 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.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

// #include <i2c_t3.h> // I tried this with this instead of Wire.h in order to access SCL/SDA 1 and 2
#include <Wire.h>


void setup() {
  // uncomment these to use alternate pins
  //Wire.setSCL(16);
  //Wire.setSDA(17);
  Wire.begin();
  //Wire1.begin(I2C_MASTER, 0x00, I2C_PINS_37_38, I2C_PULLUP_EXT, 100000);
  Serial.begin(9600);
  while (!Serial);        // Leonardo: wait for serial monitor
  Serial.println(F("\nI2C Scanner"));
}


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

  Serial.println(F("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(F("Device found at address 0x"));
      if (address < 16) {
        Serial.print("0");
      }
      Serial.print(address,HEX);
      Serial.print("  (");
      printKnownChips(address);
      Serial.println(")");

      nDevices++;
    } else if (error==4) {
      Serial.print(F("Unknown error at address 0x"));
      if (address < 16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0) {
    Serial.println(F("No I2C devices found\n"));
  } else {
    Serial.println(F("done\n"));
  }
  delay(5000);           // wait 5 seconds for next scan
}


void printKnownChips(byte address)
{
  // Is this list missing part numbers for chips you use?
  // Please suggest additions here:
  // https://github.com/PaulStoffregen/Wire/issues/new
  switch (address) {
    case 0x00: Serial.print(F("AS3935")); break;
    case 0x01: Serial.print(F("AS3935")); break;
    case 0x02: Serial.print(F("AS3935")); break;
    case 0x03: Serial.print(F("AS3935")); break;
    case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
    case 0x0B: Serial.print(F("SMBusBattery?")); break;
    case 0x0C: Serial.print(F("AK8963")); break;
    case 0x10: Serial.print(F("CS4272")); break;
    case 0x11: Serial.print(F("Si4713")); break;
    case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
    case 0x18: Serial.print(F("LIS331DLH")); break;
    case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
    case 0x1A: Serial.print(F("WM8731")); break;
    case 0x1C: Serial.print(F("LIS3MDL")); break;
    case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
    case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
    case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
    case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
    case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
    case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
    case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
    case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
    case 0x2B: Serial.print(F("CAP1188")); break;
    case 0x2C: Serial.print(F("MCP44XX ePot")); break;
    case 0x2D: Serial.print(F("MCP44XX ePot")); break;
    case 0x2E: Serial.print(F("MCP44XX ePot")); break;
    case 0x2F: Serial.print(F("MCP44XX ePot")); break;
    case 0x38: Serial.print(F("RA8875,FT6206")); break;
    case 0x39: Serial.print(F("TSL2561")); break;
    case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
    case 0x3D: Serial.print(F("SSD1306")); break;
    case 0x40: Serial.print(F("PCA9685,Si7021")); break;
    case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
    case 0x42: Serial.print(F("PCA9685")); break;
    case 0x43: Serial.print(F("PCA9685")); break;
    case 0x44: Serial.print(F("PCA9685")); break;
    case 0x45: Serial.print(F("PCA9685")); break;
    case 0x46: Serial.print(F("PCA9685")); break;
    case 0x47: Serial.print(F("PCA9685")); break;
    case 0x48: Serial.print(F("ADS1115,PN532,TMP102,PCF8591")); break;
    case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591")); break;
    case 0x4A: Serial.print(F("ADS1115")); break;
    case 0x4B: Serial.print(F("ADS1115,TMP102")); break;
    case 0x50: Serial.print(F("EEPROM")); break;
    case 0x51: Serial.print(F("EEPROM")); break;
    case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
    case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
    case 0x54: Serial.print(F("EEPROM")); break;
    case 0x55: Serial.print(F("EEPROM")); break;
    case 0x56: Serial.print(F("EEPROM")); break;
    case 0x57: Serial.print(F("EEPROM")); break;
    case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
    case 0x5A: Serial.print(F("MPR121")); break;
    case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
    case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
    case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
    case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
    case 0x64: Serial.print(F("AtlasEzoEC")); break;
    case 0x66: Serial.print(F("AtlasEzoRTD")); break;
    case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
    case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
    case 0x6A: Serial.print(F("LSM9DS1")); break;
    case 0x6B: Serial.print(F("LSM9DS0")); break;
    case 0x70: Serial.print(F("AdafruitLED")); break;
    case 0x71: Serial.print(F("SFE7SEG,AdafruitLED")); break;
    case 0x72: Serial.print(F("AdafruitLED")); break;
    case 0x73: Serial.print(F("AdafruitLED")); break;
    case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
    case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
    default: Serial.print(F("unknown chip"));
  }
}

Code:
// -------------------------------------------------------------------------------------------
// I2C Bus Scanner
// -------------------------------------------------------------------------------------------
//
// This creates an I2C master device which will scan the address space and report all
// devices which ACK.  It does not attempt to transfer data, it only reports which devices
// ACK their address.
//
// Pull the control pin low to initiate the scan.  Result will output to Serial.
//
// This example code is in the public domain.
// -------------------------------------------------------------------------------------------

#include <i2c_t3.h>

// Function prototypes
void print_scan_status(uint8_t target, uint8_t all);

uint8_t found, target, all;

void setup()
{
    pinMode(LED_BUILTIN,OUTPUT);    // LED
    pinMode(12,INPUT_PULLUP);       // pull pin 12 low to show ACK only results
    pinMode(11,INPUT_PULLUP);       // pull pin 11 low for a more verbose result (shows both ACK and NACK)

    // Setup for Master mode, pins 18/19, external pullups, 400kHz, 10ms default timeout
    Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
    Wire.setDefaultTimeout(10000); // 10ms

    Serial.begin(115200);
}

void loop()
{
    // Scan I2C addresses
    //
    if(digitalRead(12) == LOW || digitalRead(11) == LOW)
    {
        all = (digitalRead(11) == LOW);
        found = 0;
        
        Serial.print("---------------------------------------------------\n");
        Serial.print("Starting scan...\n");
        digitalWrite(LED_BUILTIN,HIGH); // LED on
        for(target = 1; target <= 0x7F; target++) // sweep addr, skip general call
        {
            Wire.beginTransmission(target);       // slave addr
            Wire.endTransmission();               // no data, just addr
            print_scan_status(target, all);
        }
        digitalWrite(LED_BUILTIN,LOW); // LED off

        if(!found) Serial.print("No devices found.\n");
        
        delay(100); // delay to space out tests
    }
}

//
// print scan status
//
void print_scan_status(uint8_t target, uint8_t all)
{
    switch(Wire.status())
    {
    case I2C_WAITING:  
        Serial.printf("Addr: 0x%02X ACK\n", target);
        found = 1;
        break;
    case I2C_ADDR_NAK: 
        if(all) Serial.printf("Addr: 0x%02X\n", target); 
        break;
    default:
        break;
    }
}

About the "how to's", as you said, is not like that. I just have the impression that is easy for a beginner to cause the i2c not to work, and the causes can be pretty diverse. Searching through the many threads when one don't have sufficient knowledge to discriminate what is valid for its specific case, or even what comes first, can be difficult. I thought about a way to have this information somehow in a more systematic way. But maybe its just me needing to do some homework to understand better some basics.

best regards,
Gil
 
I2C is fairly easy to use. The typical problem I have is that I get SCL/SDA wires crossed. You need to make sure you have 3.V going to VCC-3.3, SCL to SCL, SDA to SDA and Gnd to Gnd. From your post I really not sure of your wiring. Also, I suggest you use SDA0/SCL0 as a start. These are 18 (SDA0) and 19 (SCL0). Typically, for me the only way I fry an IMU is if I put power to ground (happened once). So make sure of your wiring then use the I2C scanner. The one you originally downloaded.

As for the size of the pullups, I'll let someone else answer. Again, make sure of your wiring. May post a picture.
 
Hi mjs513. Thank you.

Ya, I thought it was easy to use i2c too. But I must being doing something wrong and can't figure out what.

When you fried your IMU how did you know it wasn't something else? I ask because maybe I did the same.

Here is the picture of what I have. The little yellow jumper is almost hidden, but it goes from the + to VCC_3.3V

cheers

IMG_20170607_113735030.jpg
 
Morning gilFuser. It looks like the wiring is correct. But just a quick question. Did you solder the headers onto the GY-80. From the photo is does not look like there is a good connection on the headers same thing for the Teensy? If not that may be your problem.
 
Basic test given the potential for 5V to have been applied here is to remove data and clock and fire blink at one pin while digital reading the other and jumper them (for simplicity maybe pipe the digital read result to pin13). Then swap the two pins over. If you have a scope also informative, looking for things like sluggish rise and fall or other symptoms of unhappyness but you can do the basic checks without.

For hardware abuse most likely death is the final driver or the input buffer so giving those some exercise can be informative even if this leaves out the downstream i2c hardware. Just don't set both pins to output while you have them jumpered or you really will have some dead pins.
 
Last edited:
Hi
Thank you all. I have it working now. Oye!
The board and IMU you see in the foto, that were not soldered, are new. And they work. That means I damaged either one or the other from the ones I had when I started this thread.
Because I just put everything together to send the picture, as mjs513 pointed out, the connections were not good. I just made it properly and now I have it!

I'm still intrigued about what went wrong with the other board and/or IMU and I will investigate soon. The post from GremlinWrangler goes exactly in that direction.

best regards,
Gil
 
Status
Not open for further replies.
Back
Top