Teensu 3.2 I2C issues

sremick

Member
Well, at one point earlier in this project I thought I2C was working. However I wasn't seriously using the module while I worked on other things, and I might have killed that module (outside of this project) so I can't go back and test with that same module. I have other I2C modules though that I know are good and I can't get sensible I2C results anymore.

I am using pins 18 & 19. I've seen conflicting info as to the size of the pull-up resistors to use on the Teensy 3.2, but more posts said 2.2K so that's what I'm using. I have one each on SDA and SCL going to my 3.3V source (not the 3V3 pin on the Teensy). It's extremely difficult and risky to the integrity of my project to try and pull the Teensy out of the breadboard and put it onto a clean breadboard for the sake of testing, so I'm testing this "in place" but with clean test code and simply avoiding pins currently connected to other things not being used in the test.

For the sake of testing, I have one of these on the I2C bus by itself:
https://www.adafruit.com/product/2157

It runs fine at 3.3V (tested w/ an Uno) so I have both its I2C logic voltage pin and VCC pin connected to my 3.3V source.

The Teensy is not being powered via USB. The appropriate trace was cut and it's being powered from the actual 3.3V power supply I'll be using in production.

Here's my test code:
Code:
#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(24,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)
    if(digitalRead(24) == LOW)
    {
        all = (digitalRead(24) == 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(500); // 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;
    }
}

I get inconsistent results. When I touch pin 24 to GND to trigger the scan, it comes up with a list of addresses all with "ACK" but then gets to a point and stops. The stop address isn't consistent:

Code:
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
Addr: 0x55 ACK
Addr: 0x56 ACK
Addr: 0x57 ACK
Addr: 0x58 ACK
Addr: 0x59 ACK
Addr: 0x5A ACK
Addr: 0x5B ACK
Addr: 0x5C ACK
Addr: 0x5D ACK
Addr: 0x5E ACK
Addr: 0x5F ACK
Addr: 0x60 ACK
Addr: 0x61 ACK
Addr: 0x62 ACK
Addr: 0x63 ACK
Addr: 0x64 ACK
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
Addr: 0x25 ACK
Addr: 0x26 ACK
Addr: 0x28 ACK
Addr: 0x29 ACK
Addr: 0x2C ACK
Addr: 0x5F ACK
Addr: 0x6A ACK
Addr: 0x6B ACK
Addr: 0x6C ACK
Addr: 0x6D ACK
Addr: 0x6E ACK
Addr: 0x6F ACK
Addr: 0x70 ACK
Addr: 0x71 ACK
Addr: 0x72 ACK
Addr: 0x73 ACK
Addr: 0x74 ACK
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
No devices found.
---------------------------------------------------
Starting scan...
Addr: 0x65 ACK
---------------------------------------------------
Starting scan...
Addr: 0x5F ACK
---------------------------------------------------
Starting scan...
Addr: 0x24 ACK
Addr: 0x2B ACK
Addr: 0x2C ACK
Addr: 0x2D ACK
Addr: 0x2E ACK
Addr: 0x2F ACK
Addr: 0x30 ACK
Addr: 0x31 ACK
Addr: 0x32 ACK
Addr: 0x33 ACK
Addr: 0x34 ACK
Addr: 0x35 ACK
Addr: 0x36 ACK
Addr: 0x37 ACK
Addr: 0x38 ACK
Addr: 0x39 ACK
Addr: 0x3A ACK
Addr: 0x3B ACK
Addr: 0x40 ACK
Addr: 0x41 ACK
Addr: 0x42 ACK
Addr: 0x43 ACK
Addr: 0x44 ACK
Addr: 0x45 ACK
Addr: 0x46 ACK
Addr: 0x47 ACK
Addr: 0x48 ACK
Addr: 0x49 ACK
Addr: 0x4A ACK
Addr: 0x4B ACK
Addr: 0x4C ACK
Addr: 0x4D ACK
Addr: 0x4E ACK
Addr: 0x4F ACK
Addr: 0x50 ACK
Addr: 0x51 ACK
Addr: 0x52 ACK
Addr: 0x53 ACK
Addr: 0x54 ACK
Addr: 0x55 ACK
Addr: 0x56 ACK
Addr: 0x57 ACK
Addr: 0x58 ACK
Addr: 0x59 ACK
Addr: 0x5A ACK
Addr: 0x5B ACK
Addr: 0x5C ACK
Addr: 0x5D ACK
Addr: 0x5E ACK
Addr: 0x5F ACK
Addr: 0x60 ACK
Addr: 0x61 ACK
Addr: 0x62 ACK
Addr: 0x63 ACK
Addr: 0x64 ACK
Addr: 0x65 ACK
Addr: 0x66 ACK
Addr: 0x67 ACK
Addr: 0x68 ACK
Addr: 0x69 ACK
Addr: 0x6A ACK
Addr: 0x6B ACK
Addr: 0x6C ACK
Addr: 0x6D ACK
Addr: 0x6E ACK
Addr: 0x6F ACK
Addr: 0x70 ACK
Addr: 0x71 ACK
Addr: 0x72 ACK
Addr: 0x73 ACK
Addr: 0x74 ACK
Addr: 0x75 ACK
Addr: 0x76 ACK
Addr: 0x77 ACK
Addr: 0x78 ACK
Addr: 0x79 ACK
Addr: 0x7A ACK
Addr: 0x7B ACK
Addr: 0x7C ACK
Addr: 0x7D ACK
Addr: 0x7E ACK
Addr: 0x7F ACK

I've also tried dropping the I2C speed to 200K and 100K with the same results.

I've used a multimeter to confirm continuity between all the pins on the LED backpack module and the appropriate destinations. So I'm at a bit of a loss. I am still quite new to Arduino, so I suppose I could be missing/doing something stupid.
 
Well, no responses so I've continued to try and figure out at my end what I could be doing wrong. It was hard but I managed to extract the Teensy w/o messing everything up, so I mounted it into a separate breadboard so nothing was connected except the I2C. I'm getting the same results, so we can rule out whether it was anything else that was connected in my project.

Also it allowed me to take a clean reference photo.


20210115_171820.jpg
 
The datasheet (Page 4) says, the ht16K33 operates at 4.5 - 5.5Volt. Maybe it works with 3V, too, but this would be luck..

IF you have luck:
On the photo I see no GND connection. Is it there? What is this "ID" Pin on the board? What value are the pullup-resistors (should be 4k7 max on 3 Volt, better less)

ALso, you can try the default I2C library <Wire.h>
 
The datasheet (Page 4) says, the ht16K33 operates at 4.5 - 5.5Volt.
Interesting, as that contradicts their tutorial:
https://learn.adafruit.com/adafruit...anumeric-9b21a470-83ad-459c-af02-209d8d82c462
"Connect VCC+ to power - 5V is best but 3V will work if that's all you've got (it will be dimmer)"
I also tested it at 3.3V supply power with an Uno and it worked fine.
Regardless, in the same setup w/ the Teensy as shown in the photo, I changed the VCC supply voltage to the LCD to be 5VDC (keeping the I2C logic reference voltage the same, 3.3V) and no change.

On the photo I see no GND connection. Is it there?
Green jumper wire (flush on the breadboard)

What is this "ID" Pin on the board?
Not used, the angle of the photo is deceptive. The yellow jumper is going to GND on the Teensy breakout.

What value are the pullup-resistors (should be 4k7 on 3 Volt, better less)
As mentioned in the OP, 2.2K. You're in the minority suggesting 4.7K for 3.3V... most references I found said 2.2K. But I just swapped out w/ 4.7K resistors and still the same.

ALso, you can try the default I2C library <Wire.h>

I was using i2c_t3.h per this page:
https://www.pjrc.com/teensy/td_libs_Wire.html
... where it is referred to as the "improved" I2C library for Teensy.

I just loaded up File -> Examples -> Scanner and loaded it onto the Teensy:

Code:
I2C Scanner
Scanning...
Unknown error at address 0x01
Unknown error at address 0x02
Unknown error at address 0x03
Unknown error at address 0x04
Unknown error at address 0x05
Unknown error at address 0x06
Unknown error at address 0x07
Unknown error at address 0x08
Unknown error at address 0x09
Unknown error at address 0x0A
Unknown error at address 0x0B
Unknown error at address 0x0C
Unknown error at address 0x0D
Unknown error at address 0x0E
Unknown error at address 0x0F
Unknown error at address 0x10
Unknown error at address 0x11
Unknown error at address 0x12
Unknown error at address 0x13
Unknown error at address 0x14
Unknown error at address 0x15
Unknown error at address 0x16
Unknown error at address 0x17
Unknown error at address 0x18
Unknown error at address 0x19
Unknown error at address 0x1A
Unknown error at address 0x1B
Unknown error at address 0x1C
Unknown error at address 0x1D
Unknown error at address 0x1E
Unknown error at address 0x1F
Unknown error at address 0x20
Unknown error at address 0x21
Unknown error at address 0x22
Unknown error at address 0x23
Unknown error at address 0x24
Unknown error at address 0x25
Unknown error at address 0x26
Unknown error at address 0x27
Unknown error at address 0x28
Unknown error at address 0x29
Unknown error at address 0x2A
Unknown error at address 0x2B
Unknown error at address 0x2C
Unknown error at address 0x2D
Unknown error at address 0x2E
Unknown error at address 0x2F
Unknown error at address 0x30
Unknown error at address 0x31
Unknown error at address 0x32
Unknown error at address 0x33
Unknown error at address 0x34
Unknown error at address 0x35
Unknown error at address 0x36
Unknown error at address 0x37
Unknown error at address 0x38
Unknown error at address 0x39
Unknown error at address 0x3A
Unknown error at address 0x3B
Unknown error at address 0x3C
Unknown error at address 0x3D
Unknown error at address 0x3E
Unknown error at address 0x3F
Unknown error at address 0x40
Unknown error at address 0x41
Unknown error at address 0x42
Unknown error at address 0x43
Unknown error at address 0x44
Unknown error at address 0x45
Unknown error at address 0x46
Unknown error at address 0x47
Unknown error at address 0x48
Unknown error at address 0x49
Unknown error at address 0x4A
Unknown error at address 0x4B
Unknown error at address 0x4C
Unknown error at address 0x4D
Unknown error at address 0x4E
Unknown error at address 0x4F
Unknown error at address 0x50
Unknown error at address 0x51
Unknown error at address 0x52
Unknown error at address 0x53
Unknown error at address 0x54
Unknown error at address 0x55
Unknown error at address 0x56
Unknown error at address 0x57
Unknown error at address 0x58
Unknown error at address 0x59
Unknown error at address 0x5A
Unknown error at address 0x5B
Unknown error at address 0x5C
Unknown error at address 0x5D
Unknown error at address 0x5E
Unknown error at address 0x5F
Unknown error at address 0x60
Unknown error at address 0x61
Unknown error at address 0x62
Unknown error at address 0x63
Unknown error at address 0x64
Unknown error at address 0x65
Unknown error at address 0x66
Unknown error at address 0x67
Unknown error at address 0x68
Unknown error at address 0x69
Unknown error at address 0x6A
Unknown error at address 0x6B
Unknown error at address 0x6C
Unknown error at address 0x6D
Unknown error at address 0x6E
Unknown error at address 0x6F
Unknown error at address 0x70
Unknown error at address 0x71
Unknown error at address 0x72
Unknown error at address 0x73
Unknown error at address 0x74
Unknown error at address 0x75
Unknown error at address 0x76
Unknown error at address 0x77
Unknown error at address 0x78
Unknown error at address 0x79
Unknown error at address 0x7A
Unknown error at address 0x7B
Unknown error at address 0x7C
Unknown error at address 0x7D
Unknown error at address 0x7E
No I2C devices found

Here's the code for reference:
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 <Wire.h>


void setup() {
  // uncomment these to use alternate pins
  Wire.setSCL(29);
  Wire.setSDA(30);
  Wire.begin();
  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 0x30: Serial.print(F("Si7210")); break;
    case 0x31: Serial.print(F("Si7210")); break;
    case 0x32: Serial.print(F("Si7210")); break;
    case 0x33: Serial.print(F("MAX11614,MAX11615,Si7210")); break;
    case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
    case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
    case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
    case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
    case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
    case 0x3D: Serial.print(F("SSD1306")); break;
    case 0x40: Serial.print(F("PCA9685,Si7021,MS8607")); 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, SHT3X")); break;
    case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
    case 0x46: Serial.print(F("PCA9685")); break;
    case 0x47: Serial.print(F("PCA9685")); break;
    case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591")); break;
    case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591")); break;
    case 0x4A: Serial.print(F("ADS1115,Qwiic Keypad")); break;
    case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080,Qwiic Keypad")); break;
    case 0x50: Serial.print(F("EEPROM,FRAM")); 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 0x6F: Serial.print(F("Qwiic Button")); break;
    case 0x70: Serial.print(F("HT16K33")); break;
    case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
    case 0x72: Serial.print(F("HT16K33")); break;
    case 0x73: Serial.print(F("HT16K33")); break;
    case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
    case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
    case 0x7C: Serial.print(F("FRAM_ID")); break;
    default: Serial.print(F("unknown chip"));
  }
}

On the chance it was something wrong with pins 18 & 19, I tried the alternate pins 30 & 29. Same results.
 
Which wire is the GND connection to the Teensy?

Edit: ok seems to be "ID"..

the 4k7 are max.. yes 2k2 are better.
 
Ok, it's working w/ pins 16 & 17 and Wire.h

Weird that those are the only I2C pins that work. I can probably wire around the issue, but I don't understand what's wrong.
 
Ok, it's working w/ pins 16 & 17 and Wire.h

Weird that those are the only I2C pins that work. I can probably wire around the issue, but I don't understand what's wrong.

I don't know, too.
Maybe connect LEDs to 18 and 19 and test the pins.

btw, this is their schematic:
led_matrix_schem.png

It says 4.5V minimum, too :)
And, at the moment I can't find the I2C voltage mentioned.. edit: oh found it.
 
Back
Top