Hello,
i'am new here. I apologize in advance for my bad english. But i hope you understand me . I'am new with Teensy. I have a little bit experience with Arduino and I2C. I have the same Display running with an Arduino and it is working fine. Now
i would to move my project to an Teensy but i get trouble with my SainSmart I2C OLED Display with an SH1106 controller. At the moment i try to get that code running:
i get than this response in the Serial Terminal:
I2C Scanner
Scanning...
I2C device found at address 0x3C !
done
so i think that I2C is running. But my display doesn't showes anything. I would to use the u8glib for that.
I didn't have build in the pullup resistors. But i have 4,7 kOHM here. Do i need they because the I2C is responding.
Is hat possible to get any help for that?
I hope for a positive response.
Greetings
4styler
Edit1:
Sorry i will get that compiler errors too (only by the first compiling):
C:\Users\xxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_com_i2c.c:44:16: warning: 'u8g_i2c_opt' defined but not used [-Wunused-variable]
static uint8_t u8g_i2c_opt; /* U8G_I2C_OPT_NO_ACK, SAM: U8G_I2C_OPT_DEV_1 */
^
C:\Users\xxxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_rot.c:48:1: warning: initialization from incompatible pointer type [enabled by default]
u8g_dev_t u8g_dev_rot = { u8g_dev_rot_dummy_fn, NULL, NULL };
^
C:\Users\xxxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_rot.c:48:1: warning: (near initialization for 'u8g_dev_rot.dev_fn') [enabled by default]
Edit2:
I have added 2 4,7kOhm restors between 3 volt and Pin 18, 19. It didn't work
i'am new here. I apologize in advance for my bad english. But i hope you understand me . I'am new with Teensy. I have a little bit experience with Arduino and I2C. I have the same Display running with an Arduino and it is working fine. Now
i would to move my project to an Teensy but i get trouble with my SainSmart I2C OLED Display with an SH1106 controller. At the moment i try to get that code running:
Code:
#include "Arduino.h"
#include "U8glib.h"
#include <i2c_t3.h>
// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST); // Dev 0, Fast I2C / TWI
byte error;
int ok;
byte address;
int nDevices;
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_unifont);
//u8g.setFont(u8g_font_osb21);
u8g.drawStr( 0, 22, "Hello World!");
}
void setup(void) {
delay (1000);
ok = 1;
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
//####################################################
while (ok <= 2) {
Serial.println("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("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
ok = 3;
}
else if (error==4)
{
Serial.print("Unknow error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(50); // wait 5 seconds for next scan
}
//####################################################
// flip screen, if required
// u8g.setRot180();
// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);
// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}
}
void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
// rebuild the picture after some delay
delay(50);
}
i get than this response in the Serial Terminal:
I2C Scanner
Scanning...
I2C device found at address 0x3C !
done
so i think that I2C is running. But my display doesn't showes anything. I would to use the u8glib for that.
I didn't have build in the pullup resistors. But i have 4,7 kOHM here. Do i need they because the I2C is responding.
Is hat possible to get any help for that?
I hope for a positive response.
Greetings
4styler
Edit1:
Sorry i will get that compiler errors too (only by the first compiling):
C:\Users\xxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_com_i2c.c:44:16: warning: 'u8g_i2c_opt' defined but not used [-Wunused-variable]
static uint8_t u8g_i2c_opt; /* U8G_I2C_OPT_NO_ACK, SAM: U8G_I2C_OPT_DEV_1 */
^
C:\Users\xxxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_rot.c:48:1: warning: initialization from incompatible pointer type [enabled by default]
u8g_dev_t u8g_dev_rot = { u8g_dev_rot_dummy_fn, NULL, NULL };
^
C:\Users\xxxxxxxx\Documents\Arduino\libraries\U8glib\utility\u8g_rot.c:48:1: warning: (near initialization for 'u8g_dev_rot.dev_fn') [enabled by default]
Edit2:
I have added 2 4,7kOhm restors between 3 volt and Pin 18, 19. It didn't work
Last edited: