ESP32-S3 + Waveshare 4.2 e-ink + GxEPD2

I've been using 0.96" OLED displays for awhile now no problem, but I cannot seem to get e-ink working. Not sure what I'm doing wrong.

Been trying GxEPD2 with my e-ink display, but it never works. Super hard to figure out if it's a bad board, a bad display, or my code (most likely). Some of the pins like DIN (is this MISO? or MOSI?), CLK (is this SCK?) and CS (is this SS?), are automagically setup for you in pins_ardunio.h for a given board, although CS seems assignable in GxEPD2, but maybe I'm supposed to set that to what's defined for SS? I don't know. I can't get any signs of life from the e-ink, no matter how I define the pins:

display(GxEPD2_DRIVER_CLASS(/*CS=*/ 10, /*DC=*/ 9, /*RST=*/ 46, /*BUSY=*/ 3);

with
VCC connected to a 3v3 pin
GND connected to GND pin
DIN connected to GPIO13
CLK connected to GPIO12

Any suggestions? I do see signals on most of these pins (e.g. hi, or hi/lo data like pulses). I'm currently suspecting CLK is wrong since while it does contain hi/lo transitions on it, it's few and far between, hardly the regular square wave you'd expect of a clock signal.

That's why you should report the board you selected to compile for.
Then we can take a look at the pins_arduino.h used.

DIN is MOSI, short for Master Out Slave In.
CLK is SCK. SCK is the name generally used for clock for SPI.
SS is Slave Select. But any pin can be used for CS with GxEPD2.

1 Like

That's why you should report the board you selected to compile for.

Oops. Yeah, forgot that:
ESP32S3 Dev Module

Based on what's in boards.txt, I'm pretty sure it resolves to:
C:\Users\xxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\variants\esp32s3

Which gives:

static const uint8_t SS = 10;
static const uint8_t MOSI = 11;
static const uint8_t MISO = 13;
static const uint8_t SCK = 12;

DIN is MOSI, short for Master Out Slave In.

Ah, this might be my issue. Thanks! I thought I already tried that, but totally possible I screwed something up. Will try again. Need to spend more time understanding how SPI works.

Thanks for helping with my newbie q's! Really appreciate it.

Ugh. Still no dice. Even tried Waveshare's demo code (GDEW042T2_Arduino). Log looks fine, pins seem remapped correctly:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x508
load:0x403c9700,len:0x4
load:0x403c9704,len:0xad0
load:0x403cc700,len:0x29e4
entry 0x403c9880
[    96][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006040
[   108][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x4200600c
[   119][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42005fd8
[   130][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42005fa4
[   142][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006040
[   153][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x4200600c
[   164][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42005fd8
[   176][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42005fa4
[   187][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006040
[   198][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x4200600c
[   209][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42005fd8
[   221][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42005fa4
[   250][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 44 successfully set to type UART_RX (2) with bus 0x3fc92520
[   260][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type UART_TX (3) with bus 0x3fc92520
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32-S3
  Package           : 0
  Revision          : 2
  Cores             : 2
  CPU Frequency     : 240 MHz
  XTAL Frequency    : 40 MHz
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : No
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   386652 B ( 377.6 KB)
  Free Bytes        :   354528 B ( 346.2 KB)
  Allocated Bytes   :    27188 B (  26.6 KB)
  Minimum Free Bytes:   349340 B ( 341.2 KB)
  Largest Free Block:   319476 B ( 312.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         : 16777216 B (16 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Jul  5 2024 18:15:45
  Compile Host OS   : windows
  ESP-IDF Version   : v5.1.4-358-gbd2b9390ef-dirty
  Arduino Version   : 3.0.2
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32S3_DEV
  Arduino Variant   : esp32s3
  Arduino FQBN      : esp32:esp32:esp32s3:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,PSRAM=disabled,LoopCore=1,EventsCore=1,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default
============ Before Setup End ============
[   592][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   603][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 15 successfully set to type GPIO (1) with bus 0x10
[   613][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   624][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 16 successfully set to type GPIO (1) with bus 0x11
[   634][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   645][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 17 successfully set to type GPIO (1) with bus 0x12
[   655][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   666][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 18 successfully set to type GPIO (1) with bus 0x13
[   676][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_SCK (34) successfully set to 0x4200428c
[   688][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_MISO (35) successfully set to 0x420041b4
[   700][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_MOSI (36) successfully set to 0x420040dc
[   712][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_SS (37) successfully set to 0x42003fc8
[   724][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   735][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 12 successfully set to type GPIO (1) with bus 0xd
[   745][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 12 successfully set to type SPI_MASTER_SCK (34) with bus 0x1
[   756][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   767][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 13 successfully set to type GPIO (1) with bus 0xe
[   776][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 13 successfully set to type SPI_MASTER_MISO (35) with bus 0x1
[   787][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42027cf0
[   798][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 11 successfully set to type GPIO (1) with bus 0xc
[   808][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 11 successfully set to type SPI_MASTER_MOSI (36) with bus 0x1
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   386652 B ( 377.6 KB)
  Free Bytes        :   353944 B ( 345.6 KB)
  Allocated Bytes   :    27628 B (  27.0 KB)
  Minimum Free Bytes:   348752 B ( 340.6 KB)
  Largest Free Block:   319476 B ( 312.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
    11 : SPI_MASTER_MOSI[0]
    12 : SPI_MASTER_SCK[0]
    13 : SPI_MASTER_MISO[0]
    15 : GPIO
    16 : GPIO
    17 : GPIO
    18 : GPIO
    43 : UART_TX[0]
    44 : UART_RX[0]
============ After Setup End =============

What version is your Waveshare board? There might be a sticker on it.
What is the inking mark on the flexible connector of the panel?
How many connection pins does the board have? Is there a pin marked PWR?

Thanks again for helping! Totally appreciated!

No pin marked PWR, just VCC which is connected to 3.3v on the S3. Did just find some posts re: driver, so I cycled thru those marked for the 400x300 but didn't have any success.

4.2inch e-Paper Module
400x300 Pixels Rev2.2

Sticker: V2

pinouts on the header (in order from top to bottom of the back of the board):

BUSY
RST
DC
CS
CLK
DIN
GND
VCC


Luckily I've got an ESP-WROOM-32 board, which is the board used in Waveshare's demo code. I'm going to try wiring it up in a bit and see if I can at least rule out some "operator error".

Hrm. No luck. I wired it up with a brand new ESP-WROOM-32 board (ESP32 Dev Module) and am using the A32-GDEW042T2-P\A32-GDEW042T2-P-20230908\GDEW042T2_Arduino example direct from Waveshare, with the default values:

A14 (GIOP13) BUSY
A15 (GIOP12) RES
A16 (GIOP14) DC
A17 (GIOP27) CS
GIOP23 DIN/MOSI
GIOP18 CLK/SCK

void setup() {
   pinMode(A14, INPUT);  //BUSY
   pinMode(A15, OUTPUT); //RES 
   pinMode(A16, OUTPUT); //DC   
   pinMode(A17, OUTPUT); //CS   
   //SPI
   SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0)); 
   SPI.begin ();  
}

Correct me if I'm wrong , but isn't SCK supposed to be a clock signal, i.e. a square wave? Like shouldn't I be seeing this on the SCK/CLK pin?

Because using an o-scope, I'm not seeing a continuously repeating signal like that on any of the pins regardless of which board I use. Maybe it's some config I'm supposed to know to set somewhere?

The SPI clock is not a continuous signal. It is only active during transfers. You should see repeated sequences of 8 pulses.

If your display doesn't work with the Waveshare code, then I can't help.

1 Like

This looks like a demo code from Good Display. But it is for an older panel.

The Waveshare code can be found here:
e-Paper/Arduino/epd4in2_V2 at master · waveshareteam/e-Paper · GitHub

it might work with

//#define GxEPD2_DRIVER_CLASS GxEPD2_420_GDEY042T81 // GDEY042T81 400x300, SSD1683 (no inking)

with GxEPD2.

but it will not work, as the panel from Waveshare doesn't seem to have the waveform table (LUT) in OTP, in contrast to the Good Display version.
See e-Paper/Arduino/epd4in2_V2/epd4in2_V2.cpp at master · waveshareteam/e-Paper · GitHub at line 612:

const unsigned char LUT_ALL[233]={							
0x01,	0x0A,	0x1B,	0x0F,	0x03,	0x01,	0x01,	
0x05,	0x0A,	0x01,	0x0A,	0x01,	0x01,	0x01,	
...
1 Like

Joy! I got it up and running on an ESP-WROOM-32 (Board: ESP32-WROOM-DA Module) in GxEPD2

Never thought I'd be so happy to see "Hello World!"

FTR, you were right, the "no inking" driver is what finally worked. I want to say I did try that on the S3 but I probably had something else wrong at the time that I missed. Going to try switching back to the S3 now, since this is clearly working.

You made my day :wink: Thanks!

Oh, and I also had to use the B/W panel for it to work:

GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> display(GxEPD2_420_GDEY042T81(/*CS=*/ 26, /*DC=*/ 25, /*RST=*/ 33, /*BUSY=*/ 32)); // GDEY042T81, 400x300, SSD1683 (no inking)

...

#define GxEPD2_DRIVER_CLASS GxEPD2_420c_GDEY0420F51 // GDEY0420F51 400x300, HX8717 (no inking)

As I was trying to figure out how to get it's two grays working, I ran across the gray scale library that does work with this panel:
https://github.com/ZinggJM/GxEPD2_4G

So for that:

GxEPD2_4G_4G<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> display(GxEPD2_420_GDEY042T81(/*CS=5*/ 26, /*DC=*/ 25, /*RST=*/ 33, /*BUSY=*/ 32)); // GDEY042T81, 400x300, SSD1683 (no inking)

...

#define GxEPD2_DRIVER_CLASS GxEPD2_420_GDEY042T81 // GDEY042T81 400x300, SSD1683 (no inking)

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