Trouble using I2C OLED screen, any help appreciated

Anyone familiar with these OLED screens?
See here https://m.aliexpress.com/item/4000804338947.html


Ive been using a regular LCD in my project but wanted to upgrade to OLED since its a pain to get the backlight voltage stable and am forever trimming the pot on the back of the LCD.

Anyway, other people in the comments are reporting the same issue as myself saying that the controller is a us2066, not ks0066.
Basically i get a blank screen, i dont think its a fault.
Do i need a different library or something?
Would i need to significantly rewrite the code to my project?

@nzoomed
Installation and Troubleshooting is for Problems with the Arduino itself NOT your project. It says so in the description of the section. Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

1 Like

Ok sorry, i was doing this on my mobile phone and lots of the categories were condensed. Thought i was innthebright category.

Well, it is not the backlight, but the contrast, and it would not require trimming once set unless your supply voltage is particularly unreliable.

The requirement for a stable contrast voltage generally means it is not practical to operate the LCD from batteries.

Sorry your right, it is the contrast. A friend of mine said he had similar issues.
I have a stable 5v power supply using an lm2596t buck converter but seems that temperature can affect it. I think the issue could be with the i2c board connected to the LCD. Either way i like these oled displays better if i can get them to work

Interesting. I cannot claim extensive experience using these displays, so have not noticed temperature problems, but have not heard others with that problem.

There are "extended temperature range" LCDs which require a greater (negative) contrast voltage, but these are not particularly common,

Others may comment. :wink:

I dont know alot either, from whatni was told, the resistance can drift on the trimmer due to temperature changes. Anyway, i will monitor the voltages and see if it changes.

As far as this screen goes, i would be keen to get it to work. Anyone know much about the controller that it uses?

Looks like you need to instal the googles : 5 Seconds to find Was 3rd in the list.

How hard is it to swap out my regular i2c library for this?

You don't! It's a different library!

Exactly, if i have to replace the library, is ther anything else in the code i need to rewrite or can i simply replace the library and the existing code will treat it the same?

No idea, download it and look at any examples supplied!
I'm not here to hold your hand!

Problem is i know nothing about coding.
I will try and find the library that was used to compare.

May I suggest that you acquire at least the basics of being code literate before you proceed with your project. Do a few examples in the IDE and read the code and try and see what is happening. Once you can do that then you might be at a stage where you can understand the help you are being given.

Well I tell A lie, I know about enough to turn on and off an LED and thats about it.
I know how to add libraries, etc, and have edited values in code to tweak things, and thats about where my skills end.

I think it would be good as a start just to connect this screen up to an arduino to see if i can get it to display something.

Im currently using the LiquidCrystal_I2C.h library for my LCD
I was hoping the routines in the library would be written the same or similar so that little to no code needs changing.

Edit:
Here is the sample code, I cant see in here what part initializes the pins on the arduino.
In the link here (GitHub - pedro11x/Arduino-US2066-OLED: wide.HK 1602 OLED Library)
it says that pins A4 and A5 are to be used.
Any help would be great, have currently uploaded this sketch, but nothing is showing.
The manufacturer provided me the datasheet here: http://surenoo.tech/download/03_SOL/0301_SOC/SOC1602F.pdf
I dont know if this is any use to anyone to see if this library is compatible or not.

/*
Example sketch
*/
#include "US2066.h"
US2066 OLED;
float digit; //Variable to hold sample temperature value



void setup()
{
  Wire.begin();
  OLED.init();
}

void loop()
{ char* buf;
  //Printing, no cursor
  OLED.print("hello");
  //Progress bar!
  for(int i=0;i<=100;i+=5){
    OLED.bar(0, 6, 5, i);
    delay(100);
  }
  
  delay(50);

  //Printing in a particular place, by defining the row and column
  OLED.print(0, 6, "world!");

  delay(500);
  
  //Seting a cursor position, from which to start writing
  OLED.cursor(1, 0);
  
  //Turning on the blinking cursor
  OLED.blinkingCursor(HIGH);

  delay(500);

  //Printing one character at a time
  animatedPrint("The US2066 lib");

  delay(1000);
  
  OLED.cursor(1, 0);
  animatedPrint("Blinking cursor!");
  
  delay(500);
  
  OLED.cursor(1, 0);  
  animatedPrint("Setting contrast");

  //Changing the contrast
  for(uint8_t i =255;i>0;i-=15){
    OLED.contrast(i);
    delay(50);
  }
  delay(200);
  for(uint8_t i =0;i<255;i+=15){
    OLED.contrast(i);
    delay(50);
  }
  
  delay(1500);
  
  OLED.print(1,0,"                 ");//clearing row 1
  OLED.cursor(1,0);
  animatedPrint("Going to sleep");

  delay(100);
  //Turning the display off
  OLED.off();

  delay(1000);
  OLED.print(1,0,"                 ");//clearing row 1
  OLED.cursor(1,0);
  OLED.print(1,0,"Waking up");

  //Waking it up
  OLED.on();
  
  delay(10000);
  OLED.clear();
  OLED.home();
  OLED.blinkingCursor(false);
}

void animatedPrint(String buf){
  for(int i=0;buf[i];i++){
    OLED.print(buf[i]);
    delay(50);
  }
}

There are other things to modify to the hardware as described in the notes of the linked github repository .....have you done that?? :persevere: And suggest run the I2C scanner to ensure the LCD responds

Those mods are not applicable to my screen.
Those instructions apply to a screen that has multiple pins for a parallel interface that needs to be disabled.
The only connections on my screen are for sda and scl plus power
Edit:

Am trying to upload the sketch for i2c scanner to my arduino but get this error:

Yes those two pins carry the I2C signals.
Posting error messages as a screen dump is useless. The box on the right is for copying the whole error message, then you can post it in code tags in your reply.

An you also post the code you are trying to run.

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  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++;
    }
    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");

  delay(1000);           // wait 5 seconds for next scan
}

sda to pin A4 , scl to pin A5

Here is the error message:

Arduino: 1.8.16 (Windows 10), Board: "Arduino Uno"

sketch_feb11a:1:1: error: expected unqualified-id before '/' token

 / ---------------------------------------------------------------- /

 ^

In file included from K:\Desktop\i2c scan\sketch_feb11a\sketch_feb11a.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:86:8: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?

 extern TwoWire Wire;

        ^~~~~~~

        TwoWire_h

K:\Desktop\i2c scan\sketch_feb11a\sketch_feb11a.ino: In function 'void setup()':

sketch_feb11a:15:3: error: 'Wire' was not declared in this scope

   Wire.begin(); // Wire communication begin

   ^~~~

K:\Desktop\i2c scan\sketch_feb11a\sketch_feb11a.ino: In function 'void loop()':

sketch_feb11a:34:5: error: 'Wire' was not declared in this scope

     Wire.beginTransmission(address);

     ^~~~

exit status 1

expected unqualified-id before '/' token



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The code is below, I might try the code cherk has posted to see if i get any different results.

/ ---------------------------------------------------------------- /
// Arduino I2C Scanner
// Re-writed by Arbi Abdul Jabbaar
// Using Arduino IDE 1.8.7
// Using GY-87 module for the target
// Tested on 10 September 2019
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
/ ---------------------------------------------------------------- /

#include <Wire.h> //include Wire.h library

void setup()
{
  Wire.begin(); // Wire communication begin
  Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
  while (!Serial); // Waiting for Serial Monitor
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address; //variable for error and I2C address
  int nDevices;

  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++;
    }
    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");

  delay(5000); // wait 5 seconds for the next I2C scan
}