Wemos Lolin D1 mini and ILI9341 Display

Hi,

Having problems getting this adafruit TFT 2.4"display working with the above Wemos Mini, using the "Adafruit ILI9341 Breakout and Shield demo example"
code with the pins numbers as shown.
I have had the display working fine with a UNO.
Here's the code (part ), which uploads fine with no errors:
Can anyone tell me where Im going wrong .... Ive played with this for hours... and have also tried using the GPIO numbers too .
board type is Wemos Lolin D1 mini as recommended by Hobby components (whereI bought it). The pinout is from their web site and matches that stenciled on the actual board.
IDE is 1.8.19

/***************************************************
  This is our GFX example for the Adafruit ILI9341 Breakout and Shield
  ----> http://www.adafruit.com/products/1651

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/


//#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default: modified !!!
#define TFT_DC D1
#define TFT_CS D8
#define TFT_MOSI D7
#define TFT_MISO D6
#define TFT_CLK D5
#define TFT_RST D2

// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);


void setup() {
  Serial.begin(9600);
  Serial.println("ILI9341 Test!"); 

  tft.begin();

Serial.println("TFT started"); 

  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(ILI9341_RDMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDPIXFMT);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDIMGFMT);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDSELFDIAG);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); 
  
  Serial.println(F("Benchmark                Time (microseconds)"));
  delay(10);
  Serial.print(F("Screen fill              "));
  Serial.println(testFillScreen());
  delay(500);

  Serial.print(F("Text                     "));
  Serial.println(testText());
  delay(3000);

  Serial.print(F("Lines                    "));
  Serial.println(testLines(ILI9341_CYAN));
  delay(500);

  Serial.print(F("Horiz/Vert Lines         "));
  Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
  delay(500);

The display backlight comes on but nothing more !
The serial output is

⸮Hl⸮⸮H⸮$M⸮⸮B,n⸮⸮⸮$:I⸮X⸮⸮h⸮⸮ILI9341 Test!
TFT started
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
Benchmark                Time (microseconds)
Screen fill              31392202
Text                     1195492
Lines                    
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

Exception (4):
epc1=0x40101069 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffd90 end: 3fffffd0 offset: 0160
3ffffef0:  00004e20 00000000 0000000d 401002c3  
3fffff00:  00004e20 00000000 3ffee628 402032f7  
3fffff10:  0000000e 00000000 3ffee628 40203378  
3fffff20:  40105d41 00000000 0000000f 000000f0  
3fffff30:  00000000 00000000 00000140 40203601  
3fffff40:  00000000 3ffee628 049ba5e3 00c339c5  
3fffff50:  00009d1f 3ffee818 00000bb8 3ffee840  
3fffff60:  000007ff 000000ff 3ffee628 402011f0  
3fffff70:  000000f0 00000140 fdf3b645 00b5acfd  
3fffff80:  00000019 0000007f 00000080 3ffee840  
3fffff90:  000000ff 00009d1f 00000bb8 3ffee840  
3fffffa0:  000000ff 000000ff 3ffee7c0 40201bc9  
3fffffb0:  3fffdad0 00000000 3ffee814 40204c80  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100cf5  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
⸮⸮܆⸮⸮⸮`⸮⸮@H⸮⸮hR⸮_⸮ILI9341 Test!
TFT started
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
Benchmark                Time (microseconds)
Screen fill              

Your ESP8266 has watchdog timeouts. I was never able to disable these timeouts on ESP8266.

You could add either yield(); or delay(1); between the tests.

Just tried that but no different ... maybe a issue somewhere else causing the WDT to time out ??

Has anyone some code for this setup to try ??

Am I misremembering or aren't the GPIO numbers supposed to be used with the wemos core (as opposed to the Dnumber paradigm with the nodemcu)?

From what I’ve gleaned you can use the “D” numbers or the numbers “straight” for the GPIO . I’ve the 8266 core and the sketch compiles with either method ( I’ve tried both !) -and spots the error if you try to define ,say, D15 .

between the tests may not be enough, some tests may take too long. Add more of these.

It depends on the board you select, if Dx names are defined.

Using the F_macro buys you nothing in ESP-land (hurts nothing, but nothing gained or saved).

You may want to give the GPIO numbers approach a shot.
And mind your boot pins.

Using LOLIN (WeMos) D1 R1.
This works --

const byte blinker = 0;  // D3

void setup() 
{
  pinMode (blinker, OUTPUT);
}

void loop() 
{
  digitalWrite(blinker, HIGH);
  delay(250);
  digitalWrite(blinker, LOW);
  delay(250);
}

This does not --

const byte blinker = D3; 

void setup() 
{
  pinMode (blinker, OUTPUT);
}

void loop() 
{
  digitalWrite(blinker, HIGH);
  delay(250);
  digitalWrite(blinker, LOW);
  delay(250);
}

(Had to get out my D-GPIO cheatsheet - I always do.)

Still no joy ......

I've tried a simple sketch and also all combinations of pin definitions as below, these notes relate to the last but one setting

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// the combinations tried in turn:
/*
#define TFT_DC D1
#define TFT_CS D8
#define TFT_MOSI D7 
#define TFT_CLK D5   
#define TFT_RST D2
#define TFT_MISO D6


#define TFT_DC 1
#define TFT_CS 8
#define TFT_MOSI 7 
#define TFT_CLK 5
#define TFT_RST 2
#define TFT_MISO 6

*/ 
//notes refer to this comination 
#define TFT_DC 5
#define TFT_CS 15
#define TFT_MOSI 13 
#define TFT_CLK 14
#define TFT_RST 0
#define TFT_MISO 12
/*
 this combination will not compile "D15 not declared in this scope"
#define TFT_DC D5
#define TFT_CS D15
#define TFT_MOSI D13 
#define TFT_CLK D14
#define TFT_RST D0
#define TFT_MISO D12
*/

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup() {
  Serial.begin(9600);
  Serial.println("ILI9341 Test!"); 
  delay(1);
  tft.begin();
 delay(10);

  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(ILI9341_RDMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDPIXFMT);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDIMGFMT);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDSELFDIAG);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); 
delay(1);

tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(2);
  tft.println("Hello World!");
  Serial.println("Hello World!");
  tft.setCursor(50, 50);
   tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);
    tft.println("Hello World2!");
  Serial.println("Hello World2!");
delay(1000);  
 }

 void loop(void) 
{ 
}

with the sketch loaded and no display connected :
I see activity on the clock line on my scope, the reset line briefly goes low ,MISO & MOSI go high during the reset pulse, but then nothing. CS also goes low during reset but only from 3.3 to 0.8volts

When the display is connected:
nothing shown on the TFT screen itself , just lit up background
and this is the serial monitor output:

⸮HQ⸮$⸮t⸮⸮x⸮⸮⸮dh⸮H⸮⸮⸮l$hSKZ⸮ILI9341 Test!
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
Hello World!
Hello World2!

Are you using the LOLIN "3V" for power?

The NodeMCU's 3V is 600mA, supposedly, but the Wemos is much less (I believe).

[ I was getting some Comp failures w/ your sketch from yesterday, pin assignments notwithstanding. ]

I have used the Lolin and tried external 5v, 3v3 supplies to the display .
Lolin powered from usb connection.

0v commoned !!

You've been around awhile (so I know you know - or should by now).

You can hardwire Reset, I believe.
Same for CS (unless there will be another SPI device).

PE)
If you don't need data back from the display then you won't need MISO either - something less to wire at this stage.

I'm using the Adafruit ILI9341 display with its 'VIN' connected to my NodeMCU's 3V3 out.
This works on/with NodeMCU esp8266 --

#include <Adafruit_GFX.h>       // include Adafruit graphics library
#include <Adafruit_ILI9341.h>   // include Adafruit ILI9341 TFT library
 
#define TFT_CS    D2     // D2, GPIO4) TFT CS  pin is connected to NodeMCU pin D2
#define TFT_RST   D3     // D3, GPIO0) TFT RST pin is connected to NodeMCU pin D3
#define TFT_DC    D4     // D4, GPIO2) TFT DC  pin is connected to NodeMCU pin D4
// initialize ILI9341 TFT library with hardware SPI module
// SCK (CLK) ---> NodeMCU pin D5 (GPIO14)
// MOSI(DIN) ---> NodeMCU pin D7 (GPIO13)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
 
void setup() {
  Serial.begin(19200);
  Serial.print("\r\n\r\n");
  Serial.println("ILI9341 Test!"); 
 
  tft.begin();
 
  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(ILI9341_RDMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDPIXFMT);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDIMGFMT);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDSELFDIAG);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); 
  
  Serial.println(F("Benchmark                Time (microseconds)"));
 
  Serial.print(F("Screen fill              "));
  Serial.println(testFillScreen());
  delay(500);
 
  Serial.print(F("Text                     "));
  Serial.println(testText());
  delay(3000);
 
  Serial.print(F("Lines                    "));
  Serial.println(testLines(ILI9341_CYAN));
  delay(500);
 
  Serial.print(F("Horiz/Vert Lines         "));
  Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
  delay(500);
 
  Serial.print(F("Rectangles (outline)     "));
  Serial.println(testRects(ILI9341_GREEN));
  delay(500);
 
  Serial.print(F("Rectangles (filled)      "));
  Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
  delay(500);
 
  Serial.print(F("Circles (filled)         "));
  Serial.println(testFilledCircles(10, ILI9341_MAGENTA));
 
  Serial.print(F("Circles (outline)        "));
  Serial.println(testCircles(10, ILI9341_WHITE));
  delay(500);
 
  Serial.print(F("Triangles (outline)      "));
  Serial.println(testTriangles());
  delay(500);
 
  Serial.print(F("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  delay(500);
 
  Serial.print(F("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  delay(500);
 
  Serial.print(F("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  delay(500);
 
  Serial.println(F("Done!"));
 
}
 
 
void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(1000);
  }
}
 
unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9341_BLACK);
  tft.fillScreen(ILI9341_RED);
  tft.fillScreen(ILI9341_GREEN);
  tft.fillScreen(ILI9341_BLUE);
  tft.fillScreen(ILI9341_BLACK);
  return micros() - start;
}
 
unsigned long testText() {
  tft.fillScreen(ILI9341_BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(ILI9341_RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(ILI9341_GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}
 
unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();
 
  tft.fillScreen(ILI9341_BLACK);
 
  x1 = y1 = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t     = micros() - start; // fillScreen doesn't count against timing
 
  tft.fillScreen(ILI9341_BLACK);
 
  x1    = w - 1;
  y1    = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;
 
  tft.fillScreen(ILI9341_BLACK);
 
  x1    = 0;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;
 
  tft.fillScreen(ILI9341_BLACK);
 
  x1    = w - 1;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
 
  return micros() - start;
}
 
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  unsigned long start;
  int           x, y, w = tft.width(), h = tft.height();
 
  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
  for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
 
  return micros() - start;
}
 
unsigned long testRects(uint16_t color) {
  unsigned long start;
  int           n, i, i2,
                cx = tft.width()  / 2,
                cy = tft.height() / 2;
 
  tft.fillScreen(ILI9341_BLACK);
  n     = min(tft.width(), tft.height());
  start = micros();
  for(i=2; i<n; i+=6) {
    i2 = i / 2;
    tft.drawRect(cx-i2, cy-i2, i, i, color);
  }
 
  return micros() - start;
}
 
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
  unsigned long start, t = 0;
  int           n, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;
 
  tft.fillScreen(ILI9341_BLACK);
  n = min(tft.width(), tft.height());
  for(i=n; i>0; i-=6) {
    i2    = i / 2;
    start = micros();
    tft.fillRect(cx-i2, cy-i2, i, i, color1);
    t    += micros() - start;
    // Outlines are not included in timing results
    tft.drawRect(cx-i2, cy-i2, i, i, color2);
  }
 
  return t;
}
 
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
 
  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(x=radius; x<w; x+=r2) {
    for(y=radius; y<h; y+=r2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
 
  return micros() - start;
}
 
unsigned long testCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int           x, y, r2 = radius * 2,
                w = tft.width()  + radius,
                h = tft.height() + radius;
 
  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros();
  for(x=0; x<w; x+=r2) {
    for(y=0; y<h; y+=r2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
 
  return micros() - start;
}
 
unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;
 
  tft.fillScreen(ILI9341_BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(0, 0, i));
  }
 
  return micros() - start;
}
 
unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = tft.width()  / 2 - 1,
                   cy = tft.height() / 2 - 1;
 
  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(0, i, i));
    t += micros() - start;
    tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(i, i, 0));
  }
 
  return t;
}
 
unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;
 
  tft.fillScreen(ILI9341_BLACK);
  w     = min(tft.width(), tft.height());
  start = micros();
  for(i=0; i<w; i+=6) {
    i2 = i / 2;
    tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
  }
 
  return micros() - start;
}
 
unsigned long testFilledRoundRects() 
{
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;
 
  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) 
  {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  }
 
  return micros() - start;
}

I ran it through Verify(Compile) with GPIO numbers and the LOLIN D1 R1 board selected.
It compiled ok and the serial outputting did fine. I haven't tried running the Display with it.
(I don't know if/how the library deals with GPIO_vs_D#.)
Maybe select the NodeMCU board (not the LOLIN) and Upload the sketch (above) that way.

I grabbed "the code" from --

@runaway_pancake

Thx for that , I’m putting the display back on the uno to make sure it still works !
I think I have that example code , but I’ll check the display first

I moved CS from D2 to D8 and all's well.
That leaves D1 and D2 free for I2C.

I have fixed it !!

Early on , few days back, I tried using the SD card slot to load a picture (which worked) then I removed the card and the cables from IM1,2&3.

At the same time I moved over to using the Wemos board , when it didn't work. I tried today with the UNO and it just gave the white screen too . just about to bin the board when.......

I remade these IM1,2,3 connections and it now works on "Graphics test" (even without an SD card or a sketch to use it, or any of the wiring for the SD end of the board.)!

Maybe in loading code for the SD it has modded the firmware in the display board , I have no idea ???

Haven't "used" the IM bits, just blob (short) them on the board, as nec., set and forget.
I haven't ever worked them on the fly (or whatever is going on over there).

Another issue I’ve come across is the display is sensitive to power supply noise - running off a 12-5v buck convertor it does not like !!

Just thinking about , this noise may have been the real reason for the display not working , difficult to be sure .. and I’ve spent too long on this !

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