Help: Waveshare 4 color epaper 3.0" with ESP32

Hi, guys! I'm having trouble getting the Waveshare 4 color 3.0" ePaper display working with an ESP32. I am using the Waveshare demo code(e-Paper/Arduino/epd3in0g at master · waveshare/e-Paper · GitHub). I am connecting the display using pins from their wiki (waveshare.com/wiki/E-Paper_ESP32_Driver_Board) and changing the callouts on the epdif.h file on the demo code. I have also tried using the hardware SPI pins (DIN-23; CLK-18; CS-5) without any success. The display is blank.

I can get the demo code working on an Arduino Uno, but not an ESP32. Anybody that has experience with these devices know why that is?

@junegloom, Hi,

The Waveshare demo example uses HW SPI. You need to use the HW SPI pins on your ESP32 Driver Board, not the SPI pins used on the FPC connector that would require SPI pin remapping.

I have the 4.37" 4-color board. I think I tried it also with the Waveshare demo code, but I can't find the modified epdif.h I might have used.

// Pin definition
//#define RST_PIN         8
//#define DC_PIN          9
//#define CS_PIN          10
//#define BUSY_PIN        7

#define RST_PIN         16
#define DC_PIN          17
#define CS_PIN          5
#define BUSY_PIN        4

Anyway, I certainly used the same wiring as used with GxEPD2, see GxEPD2_wiring_examples.h

// mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
// NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
// BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V

-jz-

Thank you so much! With that information I was able to get the example partially working. When running the demo code, I can only run one command before it freezes up. It gets hung up when it calls epd.Init() on line 46 of epd3in0g.ino. When debugging, I found that it gets hung up when it is trying to call SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); in the IfInit() function. Anybody know what is causing this? I'm just curious.

Thank you, @ZinggJM for helping me get my project up and running.

This occurs on ESP32 when beginTransaction is called twice, when beginTransaction and endTransaction calls are not matched.
Does this occur with the unmodified demo code? Or did you modify it?
I could take a look at it.

Added:

In epdif.cpp change

int EpdIf::IfInit(void) {
    pinMode(CS_PIN, OUTPUT);
    pinMode(RST_PIN, OUTPUT);
    pinMode(DC_PIN, OUTPUT);
    pinMode(BUSY_PIN, INPUT); 

    SPI.begin();
    SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
    return 0;
}

to

int EpdIf::IfInit(void) {
    pinMode(CS_PIN, OUTPUT);
    pinMode(RST_PIN, OUTPUT);
    pinMode(DC_PIN, OUTPUT);
    pinMode(BUSY_PIN, INPUT); 

    SPI.begin();
    SPI.endTransaction(); // ignored if no beginTransaction() has been called
    SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
    return 0;
}

still not clean, but a hack that should make it work on ESP32.
-jz-

2 Likes

Thanks! The demo code works perfectly after adding that line. Thanks for explaining why it happens. I need to learn a lot about SPI.

If anybody in the future needs to get this demo code to work on the ESP32, here are the changes I made:

  • Changed const unsigned char to unsigned char in imagedata.cpp and imagedata.h
  • Changed #include <avr/pgmspace.h> to #include <pgmspace.h> in imagedata.h
  • Changed pin definitions in epdif.h to use the ESP32 hardware SPI pins
  • Added SPI.endTransaction(); to the IfInit() function in epdif.cpp
1 Like

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