4

I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode, but just if the USB isn't connected and it is powered by a 9V power supply.

So my routine is:

  • Connect USB and power supply
  • Upload Code
  • --> Doesn't work
  • Disconnect USB and power supply
  • Just connect power supply
  • --> Works
  • Connect USB
  • --> Display crashes

So basically: If the arduino is connected via USB to my PC, with or without an additional power supply, the display won't work properly, it will crash or the Arduino even restarts itself. (some kind of memory error?)

I have no possible explanation for this..

Thanks for your help.

EDIT: I'm running Ubuntu Mate Kernel 4.4.0-43-generic 64bit

If I plug in the cabel without power, display works fine. If I plug in the cabel with 5V, but the PC is shut down, the display works fine. For the display to crash, the pc has to be running.

Test code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
    //lcd.clear();
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Hello there");
    delay(1000);
}

void loop()
{
    lcd.setCursor(0,1);
    lcd.print("Hello World");

    lcd.setCursor(0,0);
    lcd.print("ABCDEFGHIJKLM");

    delay(1800);

    lcd.clear();

}

Before After

  • And both Arduino and display are 5V. Good case! – user31481 Jul 27 '17 at 13:19
  • Does this only happen if your PC is running? If yes: which OS are you using? – zimmerrol Jul 27 '17 at 13:50
  • How do you uploaded your sketch in the first place? Do you have some service running that expect something to be connected via USB (like a smartphone sync ...) – user31481 Jul 27 '17 at 14:17
2

When your computer boots, or when you plug the board in with it booted, most likely the serial port that gets created (/dev/ttyACM0) is opened by the process modem-manager. That will cause the Arduino to reset giving you the same results you see when you reset the board in other ways.

I have had no end of trouble in the same manner with a green version of the same screen. The best results I have had is to control the power to the display and power it up at every boot. You can do it with a simple P-channel logic level MOSFET or PNP transistor:

schematic

simulate this circuit – Schematic created using CircuitLab

If you chose, say, D3 (as an example) as your control GPIO you would go:

void setup() {
    pinMode(3, OUTPUT);
    digitalWrite(3, LOW);
    delay(1000); // Give it time to settle after powering up
    ... rest of setup code ...
}

You can also then use it to save power (if you want to) by turning the display off - simply set the pin back to INPUT and it will be turned off by R1.

| improve this answer | |
  • I'm using Linux Mint 17 & 18 for Arduino development and never have this kind of problem. – user31481 Jul 27 '17 at 15:13
  • @LookAlterno Have you ever used one of these displays though? They are troublesome to say the least. – Majenko Jul 27 '17 at 15:14
  • @LookAlterno also, have you ever noticed how, if you boot your computer with an Arduino plugged in, the Arduino will reset part way through the boot sequence? That's modem-manager. – Majenko Jul 27 '17 at 17:09
  • No, I never. I'm using Linux, my uptime is in the order of months. – user31481 Jul 27 '17 at 17:23
  • @LookAlterno So am I, but I like to sleep at night so I turn my computer off. – Majenko Jul 27 '17 at 17:54
0

I had the same problem but solved it with with the following code:
The noDisplay(); display(); seems to reset the screen to the correct position.

void LCDInit()
{
  lcd.begin(DISPLAY_LINE_LENGHT, DISPLAY_LINES);  
  // We need to do  this to reset the OLED display
  lcd.noDisplay();  
  lcd.display();
  lcd.clear();  
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.