baoshi / ESP-I2C-OLED

ESP8266 I2C OLED Demonstration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with I2c address

samehhady opened this issue · comments

Hello, first of all thank you for your work.

I am having issues tho, I have it all compiled and flashed to my ESP but I am not able to show anything on my screen.

I am only using 1 screen which is Chinese SSD1306 version.

http://www.aliexpress.com/item/Free-shipping-1Pcs-128X64-OLED-LCD-LED-Display-Module-For-Arduino-0-96-I2C-IIC-SPI/2036109567.html

I have updated the i2c.c & ssd1306_i2c.c as you mentioned and changed the pins ( I am using pin 2 & 14 )

When I press init i get failed message & by debugging it seems failing in the i2c_write(ctx->address) part as it seems always coming with false.

Do i have to change this address based on my oled? 0x3c, 0x3d, etc

Can you please help me in figuring out this issue.

Thanks.
Sameh

Well there are many things can go wrong. Let me try to explain.
First, the screen you linked said "for Arduino". Arduino usually uses 5V I/O, but ESP8266 uses 3.3V. You can check if there is a series resistor on SCL and SDA pin. If there is, it should be shorted.
Secondly, please check if the screen module has builtin pull-up resistor on I2C bus.
Above are hardware issues. If you have a oscilloscope or a logic analyzer these will be easy to diagnose.
Then, for software issues, there are some 0.96in Oled screens that are using SH1106 controller instead of SSD1306. I do not know how to differentiate them but the instruction sets are different.
One more possibility is the I2C address, I see there is a jumper on the module labeled address. It should be 1-3D and 0-3C.
Finally you may check the initialization code for GPIO 2 and 14, you may post your code and I can have a try.

cheers

Baoshi

Baoshi,

Thank you for your detailed reply.

Well my screen can work with both 3.3v & 5v, I've tested it on Arduino ( 3.3v ) and it worked perfectly with the U8glib library, and from this library I knew it is the ssd1306 version.

One other test that I did is to try another code for lua which works for ssd1306 & it worked directly beside the idea that is it very simple demo but at least I saw something on my screen. I was using the same 2 pins on the lua script.
http://www.esp8266.com/viewtopic.php?f=24&t=1318&hilit=ssd1306#p7747

So I guess my screen is fine and no need for resistor or shortening anything?

I've tried your code as it is and just modified the pin part and change it to:

i2c.c:

//! @brief GPIO MUX for SDA pin
#define SDA_MUX PERIPHS_IO_MUX_GPIO2_U
//! @brief GPIO FUNC for SDA pin
#define SDA_FUNC FUNC_GPIO2
//! @brief GPIO pin location for SDA pin
#define SDA_PIN 2
//! @brief GPIO bit location for SDA pin
#define SDA_BIT BIT2

//! @brief GPIO MUX for SCL pin
#define SCL_MUX PERIPHS_IO_MUX_MTMS_U
//! @brief GPIO FUNC for SCL pin
#define SCL_FUNC FUNC_GPIO14
//! @brief GPIO pin location for SCL pin
#define SCL_PIN 14
//! @brief GPIO bit location for SCL pin
#define SCL_BIT BIT14

ssd1306_i2c.c:

#define PANEL0_TYPE SSD1306_NONE
//! @brief I2C address for panel 0
#define PANEL0_ADDR (0x3c << 1)
//! @brief If panel 0 has external RESET pin, define this as 1
#define PANEL0_USE_RST 1
//! @brief GPIO MUX for panel 0 RESET pin
#define PANEL0_RST_MUX PERIPHS_IO_MUX_GPIO2_U
//! @brief GPIO FUNC for panel 0 RESET pin
#define PANEL0_RST_FUNC FUNC_GPIO2
//! @brief GPIO bit location for panel 0 RESET pin
#define PANEL0_RST_BIT BIT2

//! @brief Panel 1 type, define to SSD1306_NONE if not used.
#define PANEL1_PANEL_TYPE SSD1306_128x64
//! @brief I2C address for panel 1
#define PANEL1_ADDR (0x3C << 1)
//! @brief If panel 1 has external RESET pin, define this as 1
#define PANEL1_USE_RST 0
//! @brief GPIO MUX for panel 1 RESET pin
#define PANEL1_RST_MUX PERIPHS_IO_MUX_MTMS_U
//! @brief GPIO FUNC for panel 1 RESET pin
#define PANEL1_RST_FUNC FUNC_GPIO14
//! @brief GPIO bit location for panel 1 RESET pin
#define PANEL1_RST_BIT BIT14

and in the init method in the shell file i removed the first screen and only checking ssd1306_init(1)

Hi,
I just tried your code and pin configuration and if works nicely, except mine screen address is 0x3D. You may try both addresses see if it works.
Cheers,
Baoshi