Hello everyone!
I could need some help with my project in which i am using a waveshare eink display.
First a quick description about my project
I am using two arduino microcontrollers.
One nano IoT, which retrieves a message from the IoT cloud and sends it via I2C communication to the second controller (This part of the project seems to work just as intended)
The other controller is an nano 33 BLE. It retrieves the message from the IoT cia I2C, stores it in a char array, that is then null-terminated. I then use regex to split that message up into 3 parts (i get the initial message in the format "16. September 2023 author: Me : This is an example message" and basically split it up into the date, author name and full text) Finally i display these 3 strings on my display, which is a waveshare 7.5" eink display (the number 2)
I have build my code on the waveshare-own epd7in5b_V2, and the GxEPD2_BW.h library is included. (in addition to others, which are used for the regex and I2C)
The problem
The project seems to work initially, but when i run it for a while, i get the error of "Busy Timeout!". First i suspected a cabeling issue, which is why i have replaced the e-paper Driver HAT (also by waveshare). After that it worked again for a while, but now i am facing the Busy Timeout again.
The serial monitor then looks like this: ("Ich bin wach" signifies the beginning of the code when a message is recieved before anything has been done with the message)
19:42:19.276 -> Ich bin wach
19:42:32.264 -> Busy Timeout!
19:42:32.264 -> _PowerOn : 10004975
19:42:48.750 -> Busy Timeout!
19:42:48.750 -> _Update_Full : 10005192
19:42:58.860 -> Busy Timeout!
19:42:58.860 -> _PowerOff : 10000963
I have suspected that the message i send might be too long, and therefore take longer to process (?), but the issue stays no matter the length.
I dont want to just slap my code in here and ask for help, but unfortunately i cant realy find any parts that might be the source of the error. So if there is any part that seems suspicious, i am happy for any help!
#include <Wire.h>
#include <SPI.h>
#include <GxEPD2_BW.h>
#include "epd7in5b_V2.h"
#include <avr/pgmspace.h>
#include <Arduino.h>
#include <Regexp.h>
#include <Fonts/FreeSansBold24pt7b.h>
#include <Fonts/FreeSerifBoldItalic18pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
// Define the pins used for communication
#define CS_PIN 5 // Chip Select pin
#define DC_PIN 4 // Data/Command pin
#define RST_PIN 3 // Reset pin
#define BUSY_PIN 2 // Busy pin
GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(CS_PIN, DC_PIN, RST_PIN, BUSY_PIN));
MatchState ms;
char receivedData[500] = " ";
void(* resetFunc) (void) = 0;
void setup() {
Wire.begin(8);
display.init(115200); // Default baud rate for the Waveshare Universal e-Paper Driver HAT
display.setRotation(2); // Set the display rotation if needed (0, 1, 2, or 3), 0= horizontal
display.fillScreen(GxEPD_BLACK);
Wire.onReceive(receiveEvent);
}
void loop (){
}
void receiveEvent(int random){
Serial.println("Ich bin wach");
display.init(115200);
int i = 0;
while (Wire.available()) {
receivedData[i] = Wire.read();
i++;
}
receivedData[i] = '\0'; // Null-terminate the char array#
String TEXT = String(receivedData);
String DATUM = String(receivedData);
String AUTOR = String(receivedData);
ms.Target (receivedData);
char resultDatum = ms.Match("[0-9][0-9]..([A-Z][a-z]*).[0-9][0-9][0-9][0-9]");
int indexDatum = ms.MatchStart;
int lengthDatum = ms.MatchLength;
if (resultDatum > 0){
DATUM.remove(lengthDatum);
//Serial.println(DATUM);
}
char resultAutor = ms.Match("Autor:.([A-Z].*).:.");
int indexAutor = ms.MatchStart;
int lengthAutor = ms.MatchLength;
// Serial.println(resultAutor);
if (resultAutor > 0){
AUTOR.remove(0, lengthDatum);
AUTOR.remove(lengthAutor-2);
AUTOR.remove(0, 8);
TEXT.remove(0, lengthDatum); // Remaining part is the text
TEXT.remove(0, lengthAutor);
}
//digitalWrite(BUSY_PIN, HIGH);
display.firstPage();
//delay(5000);
do {
display.fillScreen(GxEPD_WHITE); // Set background color to white
display.setTextColor(GxEPD_BLACK); // Set text color to black
display.setFont(&FreeSansBold24pt7b); // Use a built-in font
display.setCursor(/*x*/350, /*y*/50); // Set text position
display.println(DATUM);
display.setCursor(/*x*/10, /*y*/90); // Set text position
display.println("_____________________________");
display.setCursor(/*x*/20, /*y*/400); // Set text position
display.println("_____________________________");
display.setFont(&FreeMonoBold18pt7b);
display.setCursor(/*x*/10, /*y*/150); // Set text position
display.println(TEXT);
display.setFont(&FreeSerifBoldItalic18pt7b);
display.setCursor(/*x*/50, /*y*/470); // Set text position
display.println(AUTOR);
delay(3000);
} while (display.nextPage());
display.powerOff();
resetFunc(); //call reset
}
Thank you very much in advance and for reading, any ideas are welcome !