I want to use a NodeMCU ESP8266 (ESP-12F) board with a Waveshare 4.2inch e-Paper display and a button to change pages.
I was able to get the display to work using the GxEPD library connecting it like this:
-
BUSY -> GPIO4 (D2)
-
RST -> GPIO5 (D1)
-
DC -> GPIO0 (D3)
-
CS -> GPIO15 (D8)
-
CLK -> GPIO14 (D5)
-
DIN -> GPIO13 (D7)
-
GND -> GND
-
3.3V -> 3.3V
I tried to connect the button to GPIO12 (D6) and to configure the pin as INPUT_PULLUP
but digitalRead always returns 0 and I can't get it to work.
These are the things I tried to do to fix the problem:
-
I checked for obvious errors in the code but I haven’t found anything
-
I uploaded a simple sketch to check the the button status without the code necessary to run the display and it worked, I did the same thing with a pull-down resistor and it worked as well.
-
I kept the pull-down resistor and I added the code necessary to run the display but the input value remains always 0
This is the code that I'm using, I hope someone can help me out.
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <ArduinoOTA.h>
#include <GxEPD.h>
// select the display class to use, only one, copy from GxEPD_Example
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" b/w
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
#include <Fonts/FreeSansBold9pt7b.h>
// mapping suggestion from Waveshare SPI e-Paper to generic ESP8266
// BUSY -> GPIO4(D2), RST -> GPIO5(D1), DC -> GPIO0(D3), CS -> GPIO15(D8), CLK -> GPIO14(D5), DIN -> GPIO13(D7), GND -> GND, 3.3V -> 3.3V
//RST modified from GPIO2 (factory) to GPIO5
// constructor for AVR Arduino
GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class
GxEPD_Class display(io, /*RST=D1*/ 5, /*BUSY=D2*/ 4); // default selection of D4(=2), D2(=4)
// constants
const int ledPin = 2; // the number of the LED pin
const int buttonPin = 12; // the number of the BUTTON pin
void setup() {
Serial.begin(115200);
delay(5000);
pinMode(buttonPin, INPUT);
display.init();
display.setFont(&FreeSansBold9pt7b);
display.setTextColor(GxEPD_BLACK);
display.fillScreen(GxEPD_WHITE);
display.update();
display.setTextSize(1);
display.setCursor(0, 20);
display.println("TEST");
display.update();
}
void loop() {
Serial.println(digitalRead(buttonPin));
}
Thanks a lot