SSD1306,DIGISpark OLED not working with teensy 3.2

Status
Not open for further replies.

BHARAT

New member
OLED display is not working with teensy3.2 board,but it is working fine with arduino UNO with the same code given below :-

#include <U8glib.h>

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);
int frame=0;
const uint8_t frame1[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFE, 0x00, 0x3F, 0xFF, 0xFF, 0x00, 0x3F, 0xFF, 0xFF, 0x80,
0x30, 0x00, 0x01, 0x80, 0x33, 0xFF, 0x81, 0xC0, 0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xE0,
0x33, 0xFF, 0x81, 0xE0, 0x33, 0xFF, 0x81, 0xC0, 0x30, 0x00, 0x01, 0x80, 0x3F, 0xFF, 0xFF, 0x80,
0x3F, 0xFF, 0xFF, 0x00, 0x0F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00,
};

const uint8_t frame2[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x09, 0x80, 0x00,
0x08, 0xE0, 0x00, 0x08, 0x38, 0x00, 0x08, 0x1C, 0x0C, 0x08, 0x0F, 0x06, 0x08, 0x1C, 0x03, 0x88,
0x70, 0x00, 0xC8, 0xE0, 0x00, 0x79, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x79, 0x80,
0x00, 0xC8, 0xE0, 0x03, 0x88, 0x70, 0x06, 0x08, 0x1C, 0x0C, 0x08, 0x0F, 0x00, 0x08, 0x1C, 0x00,
0x08, 0x38, 0x00, 0x08, 0xE0, 0x00, 0x09, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};

const uint8_t frame3 [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0xC0, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00,
0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x06, 0x40, 0x00,
0x00, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x04, 0x60, 0x00,
0x00, 0x0C, 0x60, 0x00, 0x00, 0x0C, 0x60, 0x00, 0x07, 0xFC, 0x61, 0xFC, 0x07, 0xF8, 0x33, 0xFC,
0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00,
0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x1E, 0x00,
0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};


const uint8_t frame4[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
void setup(void) {
}

void loop(void) {
u8g.firstPage();
do{
draw();
}while(u8g.nextPage());
frame++;
if(frame == 13)
frame=0;
delay(1000);
}
void draw(){
if(frame == 0 )
{ u8g.drawBitmapP(0,0,4,20,frame1);
u8g.drawBitmapP(103,0,3.5,28, frame2);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(20,45,"11:45");
u8g.setFont(u8g_font_helvB12);
u8g.drawStr(100,60,"AM");
}
if(frame == 1 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(0,20,"Heart Rate");
u8g.setFont(u8g_font_helvR24);
u8g.drawStr(25,60,"75");
u8g.setFont(u8g_font_helvB12);
u8g.drawStr(90,60,"BPM");
}
if(frame == 2 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(50,58,"10");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 3 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"9");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 4 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"8");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 5 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"7");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 6 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"6");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 7 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"5");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 8 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"4");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 9 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"3");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 10 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"2");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 11 )
{ u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(10,20,"Analysing");
u8g.drawBitmap(10,30,4,32, frame3);
u8g.setFont(u8g_font_helvR24);
u8g.setColorIndex(1);
u8g.drawStr(60,58,"1");
u8g.setFont(u8g_font_profont22);
u8g.drawStr(90,58,"sec");
}
if(frame == 12)
{ u8g.drawBitmapP(45,0,5.375,43, frame4);
u8g.setFont(u8g_font_profont22);
u8g.setColorIndex(1);
u8g.drawStr(45,58,"Done");
}
}

Their are no compiling errors. The OLED is not even turning on and on scanning the address comes out to be 0x3c. I have searched a lot on google but i think their is an issue in i2c communication.Please help!
 
First of all, have you run the i2cscanner on the Teensy? Does it show the display? On a Teensy, you need to have two separate pull-up resistors, one resistor between pin 18/A4 and 3.3v power, and the other resistor between pin 19/A5 and 3.3v power. If you don't have the resistors, the scanner will not be able to find the display.

Assuming you have the pull-up resistors, some displays need 5v of power. You might try connecting either the VIN power or the 3.3v power to the display, and see if it turns on.

If the display requires 5v of power, the next step is that you might need to convert the i2c signals between 3.3v on the Teensy side and 5v on the display side. There are various voltage shifters out there. The one I tend to us is from pololu.com:
  • https://www.pololu.com/product/2595
  • Connect your Teensy's 3.3v to LV;
  • Connect your Teensy's pin 18 to L1;
  • Connect your Teensy's pin 19 to L2;
  • Connect your Teensy's VIN to both HV and the display's VIN;
  • Connect H1 to the display's SDA;
  • Connect H2 to the display's SCL;
  • Connect your Teensy's ground to the display's ground.

When posting code, use the '#' tool option and put the code inside the brackets. It makes it a lot easier to read.
 
Well... I have already ran i2Cscanner with the two separate pull-up resistors and the display +5V is connected to the Vin (3.6 to 6.0 volts) of the Teensy 3.0 and still there is no output on the display.

Just to clarify, i am using 4 pin Oled display which is working fine with Arduino UNO.
 
On potential problem could be that the Teensy 3.2 is so much quicker than an Arduino UNO and that it may cause the OLED to hang if the first drawing commands arrive already before its internal reset and power up sequence is accomplished. I’d add a 500ms delay in setup() and if this works, reduce it step by step.

One problem here could also be that you use U8G_I2C_OPT_NO_ACK, which means that you instruct the Teensy to not to wait for the OLED acknowledging each byte before the next one is sent which is not good practice.

Another thing to check is the I2C clock speed. It might be (not sure of that) that the Teensy’s default I2C clock rate is higher than the one of the Arduino. A quick look with an oscilloscope or logic analyzer on the SCL pin will confirm or not that the Teensy does not overclock the OLED.
 
Like all that was mentioned earlier. I would first try adding a delay and remove the NO_ACK

And/or - Try a different library. Example Adafruit_SSD1306 or I believe it is Sparkfun Teensyview or...

Why - I beieve that the u8g library is using AVR register manipulation instead of Wire library to talk to the device. The Teensy does have emulation in place for these registers, but you might have better luck when you use the Wire library.
 
Status
Not open for further replies.
Back
Top