简体   繁体   中英

ESP32 Heltec wifi LoRa, Waveshare e-Paper 4.2", how to connect via SPI and how to display something on the display (which library to use)?

I am trying to connect a Waveshare e-Paper display via SPI to the ESP32 board, but I can't get it to work. I am new to the electronics aspect, so I am not sure if I am connecting the pins correctly. Waveshare provides example code for Arduino but when I flash it to my board the display does not do anything. I can see in the serial output that the sketch is flashing fine and running on the board.

I tried editing the code in the example code where the SPI.begin() happens and pass in the pins I am using (on this line ).

After doing that, the code runs past the following block, so it appears the epd.init() works now.

  if (epd.Init() != 0) {
    Serial.print("e-Paper init failed");
    return;
  }

The hardware I am using:

E-Paper display: Waveshare 4.2inch E-Ink display module

Driver board: ESP32 Heltec wifi LoRa (V1)

ESP32 datasheet

If I am on a wrong path all together or if I am meant to use a different library (I came across GxEPD2 , not sure if I am meant to use that one instead?), please feel free to correct me and point me in the right direction. Any help is much appreciated!

My main questions:

  • How do I connect the SPI display, which Pins to use?
  • Which library to use to display stuff on the display?
  • Example code of how to get started?
  • I am afraid that it will be hard to connect the ePaper module to the ESP32 Heltec using the standard library from Waveshare. It is probably do-able, but will require some modification on the standard ePaper library. Looking at epd-library-arduino gives these pins for SPI:
// Pin definition
#define RST_PIN         8
#define DC_PIN          9
#define CS_PIN          10
#define BUSY_PIN        7

All these pins are not freely available on the Heltec. In addition the Heltec uses SPI for LoRa and OLED. You would have to find some other pins and possibly do SPI "bit banging" (not hardware SPI). I would suggest starting with the example code from Waveshare on a ESP-WROOM-32 chip without any other external devices connected to the SPI bus. When you get this working, start porting the code over to the Heltec using different pin setup for the SPI.

  • GxEPD2 is a great library. I've personally used it on a ESP-WROOM-32. Note that GxEPD2 is licensed under GPLv3.0.

  • Both Waveshare, GoodDisplay, GxEPD2 and Adafruit GFX have a lot of example source code to get started.

I don't know if you got any further, but I am on a similar mission with a 5.65 7 colour display. I got the EPaper working using the Driver code here ESP32 Driver Board Code , but then found it was interfering with the LoRa (which had been working fine). I am going to dig deeper but at this stage (rightly or wrongly) I made these changes to DEV_Config:h under the library and if you aren't using LoRa then at least you can validate your EPaper is working :

#define EPD_SCK_PIN 5
#define EPD_MOSI_PIN 27

#define EPD_DC_PIN 13
#define EPD_CS_PIN 17
#define EPD_RST_PIN 14
#define EPD_BUSY_PIN 2

/*
#define EPD_SCK_PIN  13
#define EPD_MOSI_PIN 14
#define EPD_CS_PIN   15
#define EPD_RST_PIN  26
#define EPD_DC_PIN   27
#define EPD_BUSY_PIN 25
*/

I wired the pins accordingly. My theory being it should be able to work on the same SPI as the LoRa, with separate CS Pin. I will be messing with this for a while so maybe come up solution. This may be related to why I was having troubles with the SDCard module I was also trying to get working on same circuit. I am a newbie so go easy on me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM