i2c Adafruit I2C + Teensy 3.6 issue

Status
Not open for further replies.

usererror

Active member
To begin, the hiccup I'm trying to solve is: I get a Teensy running the program, but absolutely nothing on the OLED.
I suspect that its not using the right i2c lines.


More info:

I just got a 3.6 in hand, and immediately plugged it in, saw a blinking light, and soldered some wires to the 46-47 pins for an i2c display.

It is the 1.3" SPI/I2C (selectable) 128x64 OLED display from Adafruit. I choose I2C because its already set up for I2C, its what I've been using for a long time, and last I checked I2C displays were the cheap ones on Ebay so if I ever need to make a few of something I can do that (the Adafruit ones were quite expensive). This display is both 5v tolerant, but also can run at 3.3v.

After a bit of reading, and not a lot of comprehending, I believe it should be outputting a signal to SCL0 and SDA0 (pins 47 and 48) just fine, and my reset pin should work fine (digital pin 46). I looked at the i2c_t3 library, in this thread, but as far as I can tell unless I heavily modify the Adafruit_SSD1306 library, it wouldn't be my fix, if that is even the problem.

I came across a thready that said something about the teensy needs 4.7kohm resistors in line with the data/clk, so I gave that a try. No change. They are still in place.


Image to show my work. Sorry, 100% white wires, and a bit blurry. I checked all the connections, and they all passed my admittedly hurried inspection with a meter. The forum wants to reject my images and when I use the IMG tags it wants to show it at full resolution (huge), so I am linking it instead.

https://i.imgur.com/CqoGwIV.jpg




Code:
/*********************************************************************

  This is intended for Monocrome OLED from Adafruit based on SSD1306 drivers
  128x64, set up to use I2C.
  ------> http://www.adafruit.com/category/63_98


  Using Pin Data Pin #46 as reset, I2C pins 47 (SCL0) and 48 (SDA0), and of course 3.3v + GND.

  ---
  this program for testing purposes:
    turns on the built in LED on pin 13
    starts serial
    initializes the display (and might clear it right away to skip the splash logo built into library)
    sets up what the OLED will display and how it will display it
    turns off the LED
    and displays on the oled
    sends a serial message


    PINOUT  | Teensy Pins | OLED Pins

                  46          RST
                  47          CLK
                  48          DATA
                  3.3v        3v3
                  GND         GND
                  
      

*********************************************************************/


/**************************************

      Wire    3.5/3.6  I2C_PINS_47_48    47     48
      https://forum.pjrc.com/threads/21680-New-I2C-library-for-Teensy3

**************************************/

const int ledPin = 13;

/* *************************************************** */
// OLED DISPLAY:
#include <SPI.h>
#include <Wire.h> //#include <i2c_t3.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 46
Adafruit_SSD1306 display(OLED_RESET);
/* *************************************************** */

void setup()
{
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);   // set the LED on

  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)
  //display.clearDisplay();
  //display.display();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Boot Successful");

  digitalWrite(ledPin, LOW);    // set the LED off

  display.display();

  Serial.println("Boot Successful");
}



void loop()
{
}
 
Last edited:
From what I can tell, it should send the same signal to all of the SCL[0]/SDA[0] pins, and you just can only populate one of those for 0, one for the set on 1 (only 1 on 1,, but ya get the idea).
Unless there is somewhere I can hard-code it to look elsewhere, that seems like its how it goes.

?

Maybe I'm wildly wrong here.


from (linux):
/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h
lines 343-352
I modified some of the indentation here so it would translate to the forum
Code:
#elif defined(__MK66FX1M0__) // 3.6
    enum i2c_pins {I2C_PINS_3_4,            //  3 SCL2   4 SDA2
                           I2C_PINS_7_8,              //  7 SCL0   8 SDA0
                           I2C_PINS_16_17,          // 16 SCL0  17 SDA0
                           I2C_PINS_18_19,          // 19 SCL0  18 SDA0
                           I2C_PINS_33_34,          // 33 SCL0  34 SDA0
                           I2C_PINS_37_38,          // 37 SCL1  38 SDA1
                           I2C_PINS_47_48,          // 47 SCL0  48 SDA0
                           I2C_PINS_56_57};         // 57 SCL3  56 SDA3
#endif
 
Looks like my solution lives somewhere in the village of `modify the adafruit OLED library` ?

when switching to the i2c_t3 library I get a lot of:

/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `i2c0_isr':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.cpp:780: multiple definition of `i2c0_isr'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.cpp:1389: first defined here
/usr/share/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Disabling relaxation: it will not work with multiple definitions
/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `TwoWire::available()':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.h:132: multiple definition of `i2c1_isr'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:911: first defined here
/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `TwoWire::available()':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.h:132: multiple definition of `i2c2_isr'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:911: first defined here
/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `TwoWire::available()':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.h:132: multiple definition of `Wire2'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:911: first defined here
/usr/share/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire2' changed from 20 in /tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o to 108 in /tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o
/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `TwoWire::available()':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.h:132: multiple definition of `Wire1'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:911: first defined here
/usr/share/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire1' changed from 20 in /tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o to 108 in /tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o
/tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o: In function `TwoWire::available()':
/usr/share/arduino/hardware/teensy/avr/libraries/Wire/WireKinetis.h:132: multiple definition of `Wire'
/tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o:/usr/share/arduino/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:911: first defined here
/usr/share/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire' changed from 20 in /tmp/arduino_build_889586/libraries/i2c_t3/i2c_t3.cpp.o to 108 in /tmp/arduino_build_889586/libraries/Wire/WireKinetis.cpp.o
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.6.

That looks like a lot of conflicts I don't even know where to begin with.
 
With Wire library the default pins are as mentioned in #2 post

However you have it setup for some alternate pins.

So try adding the lines:
Code:
Wire.setSDA(48);
Wire.setSCL(47);

Before the line
Code:
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)
 
With Wire library the default pins are as mentioned in #2 post

However you have it setup for some alternate pins.

So try adding the lines:
Code:
Wire.setSDA(48);
Wire.setSCL(47);

Before the line
Code:
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)



Oh, wow, thanks! I was expecting something more involved. That did the trick 100%. I'll have to do some reading on Wire to learn a bit more about setting pins like this in the future.
 
Status
Not open for further replies.
Back
Top