Go Down

Topic: OLED Display 128X64-LCD- Won´t run when not connected to Computer (Read 273 times) previous topic - next topic

pauloadriano

Good Morning,

I´m still kind of new to this Amazing Arduino World but i have been successful already in many interesting projects.

Recently using for the first time this kind of displays from ebay (0-96-I2C-IIC-Serial-128X64-OLED-LCD-Display)

I was able to put it to work with simple program that reads potenciometer and diaplay de values and also some other test caracteres,  but anytime I disconnect from usb and connected to a normal Battery Pack, the Leonardo Card is runing but no Display.

It looks like the code itself is not booting or something...  In previous projects never had this situation.

Can you please give me some hints.

Regards,


Code attached here:

#include <SPI.h>

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

#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

int potPin = 2;    // select the input pin for the potentiometer
int val = 0;       // variable to store the value coming from the sensor

void setup()   {               

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
 
}

void loop() {

  val = analogRead(potPin);    // read the value from the sensor
 
 // Clear the buffer.
  display.clearDisplay();
// Serial.println(val);

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
   display.setTextSize(1);
  display.println("Test of yelloe caract!");
   display.setCursor(0,7);
  display.println("Teste of other size!");
// display.setTextColor(BLACK, WHITE); // 'inverted' text
 display.setCursor(0,15);
 display.setTextSize(2);
 display.println(val);
 // display.setTextSize(2);
 // display.setTextColor(WHITE);
 // display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.display();
  delay(20);

  display.clearDisplay();

  delay(20);

 
}



 


pauloadriano

The scketch is runing on the board because Just added a blink small  test and it is runing , but the Display if connect to external power will not turn on.  Or event to PC if i dont upload it anytime from arduino software.


What could be going on ?  

heninsh

Quote
I was able to put it to work with simple program that reads potenciometer and diaplay de values and also some other test caracteres,  but anytime I disconnect from usb and connected to a normal Battery Pack, the Leonardo Card is runing but no Display.
Hi !

Please post display link or specification.


Quote
the Leonardo Card is runing
What?

Do you use original Arduino Leonardo?


Post your schematic. All problems must be here !


And how your battery pack looks like?

pauloadriano

Let me organize better the sequence.

I guess its no matter what source of power i use.  The program only works after i send it to arduino.  If then I disconnect USB and just connected back de program works but display wont come on.

I attach some fotos of sequence:

1  -  Setup connections

2 -  Connected to PC USB power - no display - just normal leds from arduino

3 - After Loading scketch    Display  comes ON  Fine

4 - Zoom to the display


If I then disconnect and put it back on USB Display wont come on ....


I´m a bit confused why this is happening.     

heninsh

Take away potentiometer physically and try then. ;)

Quote
The program only works after i send it to arduino.  If then I disconnect USB and just connected back de program works but display wont come on.
And what happens when you press reset button?

pauloadriano

When i press Reset button, Arduino Leonardo Card boots. leds com on but display does not.

If then i load arduido software and upload code all works. Until a new reset  or until i disconnect and conenct usb power.


This is werd. I will try with other cards tonight like Nano or mini....


bodmer

The display can be powered from 5V, (connect direct to OLED VCC) it has an onboard 3.3V regulator so you may find the I2C pullups are not pulling the lines high enough for the Arduino to recognise the logic levels. Hopefully that will fix it.

It also looks like the display has 4 pins and no reset, so the display will be more susceptible to I2C bus lock up.

If it locks up with the display powered from 5V then pull the power on the display, plug it back in then press reset to see if it boots. Power cycling the display will remove any bus lockup state.

Since the display does not have a reset you can use:

#define OLED_RESET -1

This will free up pin 4 for other uses and the library will not try to hard reset the display.
Formerly Rowboteer (now a broken user profile!)

pauloadriano

After following your advice there is some progress. I connected 5v directly and no more potenciometer (for testing porpuses) After I solved the problem i will come back to further accessories :)

OK so this is whats happening:

With external batteries or from usb pc power the screen comes on as long as after I connected I press the Hard reset button in arduino.

Is there a way for me to reset the arduino from the sckech command right on the start of the code ?

Also tried the  line you mention
#define OLED_RESET -1

But didn´t worked for me.



I have noteced that if I disconnect power and connected back on in a few seconds interval the dispaly stays on.  If I wait 12 seconds then i do have to press the reset button.



bodmer

Maybe try adding a 2 second delay at the start of setup(). Perhaps the display is not ready for I2C comms for a while after power up.

Can you post a close up of the back of the OLED board so I can see if I2C pullups are in place and what value they are.
Formerly Rowboteer (now a broken user profile!)

pauloadriano

I have attached one image of the Display from the back.

I realized that this problem only happens when  power is supplied via USB port.  If i connect direct 5v and gnd direcly to the arduino board the display comes up imediatly.

So i guess maybe the usb port in Arduindo Leonardo is doing some stuff before and the display does not get it all ...


bodmer

Great picture! I can see that the board has 10K (10,000 Ohm) pullups to 3.3V. Typically (4700 Ohms) are used.

The higher pull-up value makes operating at higher I2C clock rates problematic and combined with the lower pullup voltage makes the line more susceptible to noise pickup from other logic lines which can cause I2C bus lockup.  Adding additional 10K pullups to 3.3V on SCK and SDA lines at the Arduino end will help (these will then be in parallel with the OLED pullups and so you will effectively get a 5K pullup.


Have you tried adding a few seconds delay at the start of setup()? Unfortunately if noise is causing bus lockup then this delay will not help.


I guess the other option is just to live with the problem. At least it boots fine when running direct from 5V.
Formerly Rowboteer (now a broken user profile!)

bodmer

More thoughts.

Are you using Arduino IDE version 1.6.8 by any chance?

That IDE as a bug where it polls the USB ports every second. This upsets some boards like the Nano which has a particular USB serial interface chip fitted and it stopped OLED displays working at boot up...

I've just plugged in an mini Leonardo and I can see the polling because a LED on the board flashes. It does not seem to affect my mini-leonardo board and it drives the OLED normally.

Even though this may not be the cause of your problem, if you are using 1.6.8 then I would upgrade to IDE 1.6.9 as the bug is fixed.
Formerly Rowboteer (now a broken user profile!)

pauloadriano

WOW

Amazing solution. I did what you told me a simple delay did the trick.

void setup(void) {
// Serial.begin(9600);

delay(3000);


It looks pretty stable and I have tryind all kinds power options and it comes on. I guess it was a problem of not giving enough time .

My test with the Display now is with a temperature sensor.

Thank you so much for the Help.








bodmer

Great!

The newest Adafruit_GFX library has built in fonts that look good on the OLED, you might prefer this to the blocky scaled font if you have enough FLASH space (each font used takes up program memory).

Attached is an example to try. It should work without modification.

There is not much documentation on how to use the free fonts, this is unusually lax of Adafruit!

Good luck with your project.
Formerly Rowboteer (now a broken user profile!)

pauloadriano

This Fonts are really nice looking.

It was easy to put them in different sizes and in the right place of the OLED display.

Thank you for sharing.

Regards

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy