Oled display only functions when connected to arduino ide

Status
Not open for further replies.

mr.hacker

New member
Hi everyone,

Using my teensy 3.2 microcontroller with the featherwing adapter, I was able to connect to the "128x64 Monochrome OLED Featherwing SH1107" after using the example program found below. I'm currently using an external power supply to power the teensy and display instead of using the USB power. I noticed that I had to have the micro usb plugged into the teensy and connected to my computer for my display to function correctly. Every time I powered up the device with no PC connection the display would not come on. After doing much troubleshooting, I noticed that even with the teensy plugged into my computer the display wouldn't work unless I have the arduino IDE open. I'm open to try any suggestions, thank you for your help in advance. I've seen similar posts about this but nothing that is exactly the same.




#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

Adafruit_SH110X display = Adafruit_SH110X(64, 128, &Wire);

// OLED FeatherWing buttons map to different pins depending on board:
#if defined(ESP8266)
#define BUTTON_A 0
#define BUTTON_B 16
#define BUTTON_C 2
#elif defined(ESP32)
#define BUTTON_A 15
#define BUTTON_B 32
#define BUTTON_C 14
#elif defined(ARDUINO_STM32_FEATHER)
#define BUTTON_A PA15
#define BUTTON_B PC7
#define BUTTON_C PC5
#elif defined(TEENSYDUINO)
#define BUTTON_A 4
#define BUTTON_B 3
#define BUTTON_C 8
#elif defined(ARDUINO_NRF52832_FEATHER)
#define BUTTON_A 31
#define BUTTON_B 30
#define BUTTON_C 27
#else // 32u4, M0, M4, nrf52840 and 328p
#define BUTTON_A 9
#define BUTTON_B 6
#define BUTTON_C 5
#endif

void setup() {
delay(1000); // Added this due to my USB being slower to connect after startup
Serial.begin(115200);

Serial.println("128x64 OLED FeatherWing test");
display.begin(0x3C, true); // Address 0x3C default

Serial.println("OLED begun");

// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(1000);

// Clear the buffer.
display.clearDisplay();
display.display();

display.setRotation(1);
Serial.println("Button test");

pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);

// text display tests
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0,0);
display.print("Connecting to SSID\n'adafruit':");
display.print("connected!");
display.println("IP: 10.0.1.23");
display.println("Sending val #0");
display.display(); // actually display all of the above
}

void loop() {
if(!digitalRead(BUTTON_A)) display.print("A");
if(!digitalRead(BUTTON_B)) display.print("B");
if(!digitalRead(BUTTON_C)) display.print("C");
delay(10);
yield();
display.display();
}
 

Attachments

  • OLED_featherwing.ino
    2 KB · Views: 53
Last edited:
My first question, is have you got your power connections in order? The program not working without the USB connection would suggest to me that there's a problem with that, I'm going to leave the whole IDE open thing for now, let's make sure the power is good first.
If you put

Code:
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);

at the start of your void setup() function, you can use this as a simple check that power is on and the teensy is working properly. You can then put it at different points through the code to see how far the execution gets. Where the problem is might be revealing.
 
Last edited:
Thank you for your help Edward. Unfortunately, the teensy feather adapter causes a short when the RST or Program pin of the adapter gets connected to the the reset button on the screen. For people with this problem, do not connect the PRGM Pin from the feather adapter to the RST Pin on the SH1107 Screen. This will fix your problems.
 
Status
Not open for further replies.
Back
Top