Unexpected reboot and lock

I wrote a sketch for an e-ink display (see below).
Somehow the code works fine for a day or 6, but then it just goes back to this text: After all this time\nyou will find,\nthat you were \nalready perfect\n\n from the start", that can be seen in the setup part of the code and it just sticks there, arduino doesn't seem to load any random text from the .h file anymore.

Does anyone know or have a clue why and how to fix it?

#include "Texts.h"
#include <LowPower.h>

// Pin definitions
#define EPD_CS 10
#define EPD_DC 9
#define SRAM_CS 8
#define EPD_RESET 5
#define EPD_BUSY 3

// Color settings
#define BLACK EPD_BLACK
#define RED EPD_RED


//----Display selector----//

//Flexible display
//Adafruit_IL0373 display(212, 104, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//#define FLEXIBLE_213 // uncomment for flexible display size setting (required)

// 2.13" Monochrome displays with 250x122 pixels and SSD1680 chipset
ThinkInk_213_Mono_BN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);

const int TimeToWaitInSeconds = (86400 / 8);  // amount of seconds to wait devided by the 8 seconds of powerdown. 86400 seconds = a day
int currentIndex = 0;                     // Variable to keep track of the current text index

const int ENAPin = 4;  // Ultra low power EPD pin

char buffer[MAX_TEXT_LENGTH + 1];  // Buffer to store the retrieved text

int counter = 0;

void setup() {

  display.begin();
#if defined(FLEXIBLE_213) || defined(FLEXIBLE_290)  // for flexible displays
  display.setBlackBuffer(1, false);
  display.setColorBuffer(1, false);
#endif
  drawimageEPD("Selfhelp Teabook\nby:\nCasper\n\nMade with love for:\nAlys" , BLACK);
  delay(3000);
  drawimageEPD("\nAfter all this time\nyou will find,\nthat you were \nalready perfect\n\n  from the start" , BLACK);
  pinMode(EPD_RESET, OUTPUT);
  pinMode(ENAPin, OUTPUT);
}

void loop() {
  if (counter >= TimeToWaitInSeconds) {
    delay(10);
    digitalWrite(ENAPin, HIGH);  // Enable screen
    delay(50);
    drawimageEPD(getNextText(), BLACK);
    delay(10);
    digitalWrite(ENAPin, LOW);  // Disable screen
    counter = 0;
  }
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  // go into sleep mode for extreme power saving
  counter = counter + 1;
}

void drawimageEPD(const char* text, uint16_t color) {
  display.begin();
  display.clearBuffer();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.setTextColor(color);
  display.setTextWrap(true);
  display.print(text);
  display.display();
}

const char* getNextText() {
  strncpy_P(buffer, (char*)pgm_read_word(&(Texts[currentIndex])), MAX_TEXT_LENGTH);
  buffer[MAX_TEXT_LENGTH] = '\0';
  currentIndex = (currentIndex + 1) % TEXT_COUNT;
  return buffer;
}

explain how this happens. Post an annotated schematic showing exactly how you have wired it, be sure all connections, power, ground and [power sources are shown.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.