QR Code displayed on a 1.54″ TFT LCD Display with ESP8266

Description: A QR Code .bmp file is uploaded to a Micro-SD Card and displayed on a 1.54″ TFT LCD with a Wemos Lolin D1 Mini Pro V2.

QR Code displayed on 1.54 TFT LCD Display with ESP8266

Notes: In order for an image to be displayed on the LCD it must be converted to .bmp format and then uploaded to the folder named “picture” on the Micro-SD card. An image can be converted online to bmp with: Online-Convert.

Supplies:

1 – Breadboard 400 Points
1 – Wemos Lolin D1 Mini Pro V2
1 – 1.54” 240×240 TFT LCD Display with MicroSD Card Breakout (DF Robot)  >> Link <<

Arduino Code:

#include “DFRobot_GDL.h”
#include <SD.h>
#include <SPI.h>
#include “DFRobot_Picdecoder_SD.h”

DFRobot_Picdecoder_SD decoder;

#define TFT_DC 0
#define TFT_CS 15
#define TFT_RST 2
#define TFT_SD 4

DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);

void setup() {

  //Initialize the serial port
  Serial.begin(115200);
  //Initialize screen
  screen.begin();
  //Initialize the SD card, wait until the initialization is successful
  while(1)
{
  
}
  #if defined ESP8266
  if (SD.begin(/*sdcs=*/TFT_SD)){
  #else

  if (SD.begin(/*sdcs=*/TFT_SD)){
  #endif
  Serial.println(“initialization done.”);
  break;
}
  Serial.println(“initialization failed!”);
}
}

void loop() {

  /* Set the screen color to white */
  screen.fillScreen(COLOR_RGB565_WHITE);
  decoder.drawPicture(/*filename=*/”picture/QR.bmp”,/*sx=*/0,/*sy=*/0,/*ex=*/screen.width(),/*ey=*/screen.height(),/*screenDrawPixel=*/screenDrawPixel);
  delay(30000);
}

//For decoding function calling, the function of this function is to draw a pixel on the screen
void screenDrawPixel(int16_t x, int16_t y, uint16_t color) {

  //Draw a point on the screen
  screen.writePixel(x,y,color);

}

Leave a Comment

17 + = 19