Go Down

Topic: I2C displays don't work with LoLin NodeMcu Lua ESP8266 CH340G WIFI  (Read 1 time) previous topic - next topic

Zerg00s

I've been trying to to force my ESP8266 to work with different l2C displays for the last 5 hours, but I was unsuccessful and need someone's help.

My setup is super simple:
Controller:
LoLin NodeMcu Lua ESP8266 CH340G WIFI Internet Development Board Module
Display:
Kuman 0.96 Inch I2c 128x64 LCD Display

The display has 4 pins: GND, VCC, SCL, SDA. That are connected to the controller like so:
GND -> G
VCC  -> V3
SCL -> D1 (GPIO 05) 
SDA  -> D2 (GPIO 04)

I have also tried this setup as described in this post, but the results were even worse. I could not get the device detected at all.
GND -> GND
VCC  -> Vin
SCL -> D1 (GPIO 05) 
SDA  -> D2 (GPIO 04)

The issue
Here is the code that I've been using. It works both with Arduino Nano and my ESP8266 controller. But ESP8266 seems to have problems:
  • It detects the address of the device only the first time
  • It does not display anything. the screen is completely blank




More information:
  • I have tried other L2C displays. the result is the same. Arduino Nano works perfectly fine while my wifi-enabled controller either does not recognize displays at all or shows them briefly the first time I press reset
  • Obviously, when I connect i2C display to Nano I use different pins.


Arduino Nano. Works perfectly with the display:


NodeMcu Lua ESP8266. Only finds the display the first time after I press Reset button on the controller.


NodeMcu Lua ESP8266:


Arduino nano:


Update:
I have also tried connecting the display to a separate 3.3V source with a common ground with the wifi-enabled controller. The result is the same. So it's not the problem with the power supply...

Update 2:
There is also a message from this website (https://www.dipmicro.com/store/NODEMCU_V3):
"You need to power the board with external power supply. I used 5V/GND from Arduino powered by 12V/1A adapter on VIN/G on NodeMCU bottom left (USB facing down) - because that is what I had readily available on my desk when testing a batch of samples. Some units may work without external power, other may not even come up as serial port, some may cycle between serial port apearing and disapearing. NodeMCU does not have large power draw, but power surges from it's own working are most likely reseting the device. Some poeple have had success installing additional electrolytic capacitor on the device."

So I went ahead and did as this message suggested. I've connected my Arduino Uno to 12V DC source and used it's 5V output to power NodeMCU via Vin. The result is - no luck. I don't see any difference. The display still does not show anything.

Update 3:
This photo shows the Voltage and currency I'm getting from my Laptops' USB 3.0:


Update 4:
When I connect a different I2C display, it behaves the same way: the address is detected the first time and then nothing happens:

Scanning...
I2C device found at address 0x27  !
Showing stuff...
done

Scanning...
No I2C devices found

Scanning...
No I2C devices found


Any help would be greatly appreciated!

Juraj

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Zerg00s

those boards work with diferent voltage
I power the NodeMcu Lua ESP8266 controller using my USB 3.0 from the laptop. Does it mean it's a problem? Do you suggest something?

Zerg00s

I've just managed to make it work.

Things that helped:

Old code:
Adafruit_SSD1306 display(4); // number 4 works with Arduino Nano, but not with NodeMcu

new code:
Adafruit_SSD1306 display(-1); // -1 means there is no "Reset pin" I have no idea what it really means, but as long as it works - I'm more than happy.


Current version of the code:

Quote
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  while (!Serial);           
  Serial.println("\nI2C Scanner");
}
 
void loop()
{
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 61; 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++;
    }
    else if (error==4)
    {
      Serial.print("Unknown 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");
    DisplayGreeting();
  }     
  delay(1000); 
}

void DisplayGreeting(){
  Serial.println("Showing stuff...");
  Adafruit_SSD1306 display(-1);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(10,0);
  display.clearDisplay();
  display.println("Greetings");
  display.display();
  delay(1);
}
The result:


I hope it helps someone with a similar problem

Go Up