OLED text from file D1 Mini

Hey guys! I have a quick question for you. I’ve been on the Google machine for a while now trying to find a solution, but alas, I can’t seem to come up with one.

My project uses a Wemos D1 Mini to get the contents of a text file and display it on an OLED display. It also prints out the text to the serial monitor. When it prints to serial, the whole message is displayed as expected, but I can not for the life of me get the entire thing on the OLED. It’s probably beyond my knowledge right now, so I’d like to borrow some of yours.

Below is the current code that I have.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "ESP8266WiFi.h"
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET     -1 
#define SCREEN_ADDRESS 0x3C 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
ESP8266WiFiMulti WiFiMulti;
void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  Serial.println();

  for (uint8_t t = 4; t > 0; t--) {
    Serial.printf("[SETUP] WAIT %d...\n", t);
    Serial.flush();
    delay(1000);
  }

  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP("Winternet", "password");
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello world!");
  display.display();
}

void loop() {
  if ((WiFiMulti.run() == WL_CONNECTED)) {

    WiFiClient client;

    HTTPClient http;

    Serial.print("[HTTP] begin...\n");
    if (http.begin(client, "http://callmecarlos.com/carlos.txt")) {  // HTTP


      Serial.print("[HTTP] GET...\n");
      int httpCode = http.GET();

      if (httpCode > 0) {
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = http.getString();
          Serial.println(payload);
          display.setTextWrap(false);
          display.startscrollleft(0x00, 0x07);
          const char* printout = payload.c_str();
          display.clearDisplay();
          display.setCursor(0,0);
          display.println(printout);
          display.display();
          
        }
      } else {
        Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
      }

      http.end();
    } else {
      Serial.printf("[HTTP} Unable to connect\n");
    }
  }

  delay(10000);
}

I’ve also tried to do the below section with just a normal variable.

        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = http.getString();
          Serial.println(payload);
          display.clearDisplay();
          display.setCursor(0,0);
          display.println(payload);
          display.display();

So, can you please point me in the right direction? Thank you so much for your time.

What exactly do you see on the OLED when the whole message is displayed on Serial ?

So the message in the text file and what is displayed by the serial monitor is “I’m going to go ahead and edit this tto be something that is long and it is long and happy.” The OLED shows only “I’m going to go aheadI’m going to go aheadI’m going to go ahead…” looping as it scrolls. I was hoping that it’d scroll the entire contents of the variable or of the const char.


So I’m still working on this. One of the things that I thought I might be able to try was converting the string like this:

const char* first = payload.substring(0, 8);
const char* second = payload.substring(8, 16);
display.print(first);
delay(1000);

display.print(second);

But this isn’t working either. I get an error "cannot convert ‘String’ to ‘const char*’ in initialization
"
I’m sure there is a fairly easy way to do this, but I’m working on it! If anyone has a suggestion, please chime in. :smiley: