Introduction: E-Paper Display Partial Refresh With Arduino
In this instructable I use a Waveshare 2.9" E-Paper display with an Arduino Nano to create a partial refresh window in order to display updating values without completely refreshing/rebooting the screen.
Update: Check out my new Istructable as well, where I use the Waveshare display, an ADS1115 and Arduino nano to build a precise voltmeter capable of measuring voltages up to 90v DC: https://www.instructables.com/Waveshare-E-ink-Display-Precise-Voltmeter-0-90v-DC/
Supplies
Supplies Used in this instructable:
1 x Arduino Nano - https://amzn.to/2TiPaHY
1 x Waveshare display - https://amzn.to/33N1XrD
Breadboard and wires - https://amzn.to/2z0KmjH
USB Power Bank - https://amzn.to/3cEhk7Q
CanadianWinters is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn fees by linking to Amazon.com and affiliated sites. By using these links, as an Amazon Associate I earn from qualifying purchases, even if you buy something else--and it won't cost you anything.
Step 1: Wiring the Display
I wired the display to the Arduino Nano as follows:
Display <-> Arduino
BUSY <-> D7
RST <-> D8
DC <-> D9
CS <-> D10
DIN <-> D11
CLK <-> D13
VCC <-> 3.3V
GND <-> GND
Step 2: Code
To test the display, I used the code provided by Waveshare at this link:
https://github.com/waveshare/e-Paper
Once I verified that the display was working, I created my own Arduino Sketch in order to perform a partial update of some values. In my code I use the input pin A0 as a floating value to be displayed on the screen.
The code uses the following libraries:
- GxEPD2
- U8g2_for_Adafruit_GFX
Here is the code:
#define ENABLE_GxEPD2_GFX 0 #include <GxEPD2_BW.h> #include <U8g2_for_Adafruit_GFX.h> #if defined(__AVR) #define MAX_DISPLAY_BUFFER_SIZE 800 #define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8)) GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); #endif U8G2_FOR_ADAFRUIT_GFX u8g2Fonts; void setup() { display.init(); u8g2Fonts.begin(display); // connect u8g2 procedures to Adafruit GFX delay(1000); } void loop() { display.fillScreen(GxEPD_WHITE); displayValues(); delay(1000); } void displayValues() { float number; //A0 Value float number2; // A0 Value converted to voltage number = analogRead(A0); number2 = number/1023 * 5; display.setRotation(1); // 0--> No rotation , 1--> rotate 90 deg uint16_t bg = GxEPD_WHITE; uint16_t fg = GxEPD_BLACK; u8g2Fonts.setFontMode(1); // use u8g2 transparent mode (this is default) u8g2Fonts.setFontDirection(0); // left to right (this is default) u8g2Fonts.setForegroundColor(fg); // apply Adafruit GFX color u8g2Fonts.setBackgroundColor(bg); // apply Adafruit GFX color //u8g2Fonts.setFont(u8g2_font_helvR14_tf); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall u8g2Fonts.setFont(u8g2_font_logisoso32_tr); //u8g2_font_logisoso32_tn--->numbers only to save memory ; u8g2_font_logisoso32_tr , u8g2_font_logisoso32_tf -->numbers&letters uint16_t x = 150; uint16_t y = 50; display.setPartialWindow(0, 0, display.width(), 296); //this sets a window for the partial update, so the values can update without refreshing the entire screen. display.firstPage(); do { display.fillScreen(bg); // Display A0 value u8g2Fonts.setCursor(90, y); u8g2Fonts.print("A0:"); u8g2Fonts.setCursor(x, y); u8g2Fonts.println(number,1); // Display Voltage of A0 u8g2Fonts.setCursor(50, y +40); u8g2Fonts.print("Volts:"); u8g2Fonts.setCursor(x, y + 40); u8g2Fonts.println(number2,1); } while (display.nextPage()); }
I hope you've found this instructable useful!
4 Comments
4 weeks ago
I've now installed the demo epd2in9_V2.ino as detailed in here:
I needed to change row 41 unsigned char image[1024] to [5000] to provide more memory for the display, this then enabled me to set rows 143 & 144 to paint.SetWidth(128) and paint.SetHeight(296) so the whole display can be used in partial refresh mode.
Connections that I have in use for the Waveshare 2.9V2 to the feather are: VCC to 3V, DIN to 13, CLK to 14, CS to 2, DC to 4, RST to 5, Busy to 16. These last four pin numbers needed updating on the epdif.h tab of the epdin9_V2 file.
This code only appears to allow 15 different values to be read as a client so now i am looking for a way to collect additional data. Does anyone have suggestions ?
3 months ago
I have exactly the same problem as lorenzobianchimu.
With the demo code from WaveShare it is working fine (ie: its showing some Chinees letters with Wavesgare Electronics underneath it.
I used the code from the map "epd2in9b_V3"
When I try your code (this and the "Precise Voltmeter") it compiles and uploads fine to the Nano.
However. The screen stays white :-(
The screen I have is the 2.9 inch e-Paper module 296*128 pixel V3.
What version of screen did you test this code with? Could this be the problem?
I really would like to get this to work!
Any help apreciated!
Thank you
1 year ago
Dear Canadian,
I am working around e-ink displays. I found your sketch very interesting for partial refresh and for the use of fonts so I tested it on my hardware. To don't make mistakes I used the same Arduino and Waveshare display as you. Once compiled, there are no errors but display doesn't wake up.
Hardware is tested with other sketches.
Do you have some tips about? Thank you in advance from Italy!
Reply 1 year ago
Hi!
You state "Hardware is tested with other sketches.". Did you test the display per step 2 using the code provided by Waveshare? https://github.com/waveshare/e-Paper