Cannot get GxEPD2 library to work with Arduino and get error "Compilation error: 'display' was not declared in this scope"

Hi, I've been stuck on this for about 3 days and have come here for some help.

I have a LilyGO T8 ESP32 S3 and am using this Waveshare 3.7inch e-Paper e-Ink Display HAT. I am struggling with my EDP32 so I first installed the GxEPD2 library through Arduino's IDE but cannot get it to work. I have opened the helloworld sample (.ino file) but when I uncomment my display in GxEPD_display_new_style.h

(#define GxEPD2_DRIVER_CLASS GxEPD2_370_TC1 // ED037TC1 280x480, SSD1677, (ICA-FU-20 ichia 2029), Waveshare 3.7" )

I get the error Compilation error: 'display' was not declared in this scope.

When I uncomment my board in GxEPD_display_section.h, I get nothing displayed on the screen but it compiles fine.

Does anyone know what is the problem? Also I am unsure on which pins to use for this specific board. (LilyGO)

Thanks in advance,
Best wishes -ewan

Welcome to the forum

Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Hi, I haven't changed anything from the examaple code provided by the librray apart from this on line 62

`
#define GxEPD2_DRIVER_CLASS GxEPD2_370_TC1 // ED037TC1 280x480, SSD1677, (ICA-FU-20 ichia 2029), Waveshare 3.7"

`

I don't have the library installed so I don't have the example. Please post it here

It would also help if you posted the full error message copied from the IDE using the button provided for the purpose. Please post the error message in code tags

Hi, all the files are too long to paste into here. Here's the GitHub repo if it helps GxEPD2/examples/GxEPD2_HelloWorld at master · ZinggJM/GxEPD2 · GitHub

and here is the error message `/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino: In function 'void setup()':
/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino:48:3: error: 'display' was not declared in this scope
display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
^~~~~~~
/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino:48:3: note: suggested alternative: 'delay'
display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
^~~~~~~
delay
/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino: In function 'void helloWorld()':
/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino:57:3: error: 'display' was not declared in this scope
display.setRotation(1);
^~~~~~~
/private/var/folders/b5/wdr56hts38dgcn8m04mhy3rr0000gn/T/.arduinoIDE-unsaved2024112-95408-n20cpu.g87rk/GxEPD2_HelloWorld/GxEPD2_HelloWorld.ino:57:3: note: suggested alternative: 'delay'
display.setRotation(1);
^~~~~~~
delay

exit status 1

Compilation error: 'display' was not declared in this scope`

Did you uncomment the appropriate line for your display in the GxEPD2_display_selection.h file ?

yes, i have done this but nothing displays on the screen; it compiles and uploads with no error.
however when I use ..._new_style.h I get the display error

Hi @ewan_dev , welcome to the forum!

For compilation related issues I need to know which board you select to compile for in the Arduino IDE. And I also need to know the version of GxEPD2 you use.

Please report the line you uncommented, in a code window, to check.

For this issue I also need to know which board you select to compile for.
And you could tell which line you uncommented, for check.

For execution related issues, please report diagnostic output from Serial Monitor, in a code window, please.
-jz-

Hi. I am using GxEPD2 and an ArduinoRev2 Uno WiFi. That is what I selected.

In new style I uncommented //#define GxEPD2_DRIVER_CLASS GxEPD2_370_TC1 // ED037TC1 280x480, SSD1677, (ICA-FU-20 ichia 2029), Waveshare 3.7"

and in the old style GxEPD2_display_section.h I uncommented //GxEPD2_BW<GxEPD2_370_TC1, MAX_HEIGHT(GxEPD2_370_TC1)> display(GxEPD2_370_TC1(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // ED037TC1 280x480, SSD1677, Waveshare 3.7"

The exact name of the board you selected!

Here I expect to get the line number! I can match the pins parameters, but want to be sure.

I can't follow a moving target.

Don't expect any more answers, unless everything is stated clearly.
-jz-

Please answer:
The board I use to connect the e-paper to is: name and link
The board I select to compile for is: name

Hello, for some reason I can’t get in my primary account. I am using an Uno Rev2 Wi-Fi to connect to the screen, not a LilyGO. I apologise.
In the IDE it says "Arduino UNO WiFi Rev2", which is what I use to compile. For the new style I am using line 62. And 663 for the old style. I am not using both display selection files at the same time but have tried both

Thanks for the information.

I don't have a Uno Rev2 Wi-Fi. So it is not directly supported by GxEPD2 examples.

In GxEPD2_display_selection_new_style.h you would need to modify line 184:

#if defined(ARDUINO_ARCH_MEGAAVR)
#if defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_AVR_UNO_WIFI_REV2)

to enable compilation for this board.

And you may need to adapt pin parameters.
pins_arduino.h for this board confuses me, and I don't have time to study it. But:
C:\Users\xxx\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\uno2018\pins_arduino.h
has

#define PIN_SPI_MISO  (33)
#define PIN_SPI_SCK   (34)
#define PIN_SPI_MOSI  (32)
#define PIN_SPI_SS    (22)

static const uint8_t SS   = PIN_SPI_SS;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK  = PIN_SPI_SCK;

which defines the HW SPI pins.
-jz-

Thanks, after some look it appears I need to use the ICSP pins for my specific board. I'll see how it goes and will get back. Thanks for your time thus far.

After a bit of trying i can't find a way to reference Icsp pins. I'm thinking of trying to use a different microcontroller.

I just saw this post:
SPI Not Useable - Hardware / Arduino WiFi Rev2 - Arduino Forum

You should be able to reference them by number. From pins_arduino.h:

#define PIN_SPI_MISO  (33)
#define PIN_SPI_SCK   (34)
#define PIN_SPI_MOSI  (32)
#define PIN_SPI_SS    (22)

  PC,  // 32 PC0/MOSI
  PC,  // 33 PC1/MISO
  PC,  // 34 PC2/SCK

  PIN0_bp,  // 32 PC0/MOSI
  PIN1_bp,  // 33 PC1/MISO
  PIN2_bp,  // 34 PC2/SCK

But GxEPD2 uses HW SPI, per default the global SPIClass instance SPI by Arduino IDE.
The SPIClass "knows" the pin numbers, taken from pin_arduino.h.
For CS you can use any pin you like, or the default SS pin 22.
-jz-

I am sorry for being a bit slow but how and where would I reference these specific pins in display selection?

Post created by Jean-Marc Zingg

You can't, and you don't need to.

GxEPD2 uses the only HW SPI channel available on your processor, and its pins that can't be changed.

GxEPD2 uses HW SPI, per default the global SPIClass instance SPI by Arduino IDE.

Thank you so much, you are an absolute life-saver. I'll give you a star on GitHub.

I did not adjust any of the default parameters from the library as there was no need and here is my wiring ;

E-PAPER --> UNO REV2
VCC --> ICSP VCC PIN (2)
GND --> ICSP GND PIN (6)
DIN --> ICSP MOSI PIN (4)
CLK --> ICSP SCK PIN (3)
CS --> DIGITAL PIN 10
DC --> DIGITAL PIN 8
RST --> ICSP RESET PIN (5)
BUSY --> DIGITAL PIN 7

update: unrelated to this but my chip is now locked :frowning: