-->
Page 1 of 2

ESP12 I2C just will not work

PostPosted: Fri Apr 14, 2017 12:48 am
by TomTheFrustrated
First thanks to everyone in this great community! I have searched and read and learned a lot here.

But I've come up against a problem (well a few) that I just cannot figure out and I'm hoping someone can help: I2C simply refuses to work or be recognized.

I have an ESP12 (not the NodeMCU, just the chip soldered to a breakout board) connected with an FTDI. I've had this chip connected to my local network, gotten OTA working on it, and hooked up the MFRC522 via SPI to it, all without issue. Now I am trying to connect an OLED using I2C to it (without anything else connected) and it just will not work (I should also mention I have a regulated 3.3V external power supply connected)

I tried using several SSD1306 libraries including this one that has been recommended here by others: https://github.com/squix78/esp8266-oled-ssd1306

I've tried using Wire with GPIO 4,5 using Wire.begin(4,5) (also 5,4 just in case). I've tried GPIO 2,0 (and 0,2) with Wire.begin() and no matter what I do the OLED will never even turn itself on.

Using the exact same ssd1306 library, sketch and OLED hooked up to an Arduino UNO on A4 and A5 the OLED works 100% fine, so I know its not the actual screen.

So I guess my question is, what are the pins I should be trying with the OLED to get it to work? I have seen about 700 different versions of pin-outs online and am utterly confused.

The sketch I've been using is very basic just to get it to turn on. Any help at all is appreciated!

Code: Select all#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`

// Initialize the OLED display using Wire library
SSD1306  display(0x3c, 4, 5);   //display(I2C address, SDA, SCL)
// Wemos D1 + SD1306 display(I2C address, SDA = D2, SCL = D1)
// ESP-12 + SD1306 display(I2C address, SDA = GPIO4, SCL = GPIO5)

void setup() {
  Wire.begin(4,5);
  Serial.begin(115200);   //for debug by terminal
  Serial.println();   //for debug by terminal
  Serial.println("Debug");   //for debug by terminal

 
  display.init();  // Initialising the UI will init the display too.
  display.flipScreenVertically();   // up side down or straight
  display.setFont(ArialMT_Plain_10);  //default font. Create more fonts at http://oleddisplay.squix.ch/

}

void loop() {
  String MyTekst = "Hello world";
  display.clear();    // clear the display

  display.setFont(ArialMT_Plain_24);    // change font
  display.drawString(0, 26, MyTekst);   // draw string (column(0-127), row(0-63, "string")

  display.display();  //display all you have in display memory

  delay(10);  // give some time to finish function loops
}

Re: ESP12 I2C just will not work

PostPosted: Sat Apr 15, 2017 12:53 am
by TomTheFrustrated
Still no luck with I2C on this thing....I found this post https://github.com/esp8266/Arduino/issues/576 and added 10k pull-ups to both SDA and SCL: no change. I tried the patched Adafruit library here: https://github.com/canadaduane/Adafruit_SSD1306 and no change.

I've tried other spots on the breadboard, I've tried different cables, different resistors.....I am literally out of ideas. I have no clue how to get I2C working on this ESP board so please help!

Anything at all I can try I am willing to give it a shot to get this working.

Re: ESP12 I2C just will not work

PostPosted: Fri Apr 21, 2017 8:30 am
by Ocsav
Use an I2C scanner. I know that I2C works ok in ESP-12, I have a node-mcu accessing 2 I2C sensors, and I've use them in different pins, at first I had 4,5 but now in 0,2 so, it works ok.
Unless you have some problem in your breakout board wring the scanner should clear the matter.
My OLED is still in SPI mode, so I can't help you here...

Re: ESP12 I2C just will not work

PostPosted: Fri Apr 21, 2017 9:47 am
by rudy
I tried your sketch as is, no changes, and it worked. :o

I didn't add pull-up resistors since I think the module I have has some. I had previously checked. Normally I use 0 and 2 for my I2C but I decided to just use the sketch as is.

Are you sure you don't have SDA and SLC swapped? And as has been suggested, try a scanner to see if it is seen as an I2C device.

EDIT:

I used this library https://github.com/squix78/esp8266-oled-ssd1306