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:
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:
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.
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.