Example Code for Arduino-Line Chart Display

Last revision 2025/12/22

This article guides you through the process of displaying a line chart on an Arduino using the FireBeetle ESP32-E microcontroller and a 1.47" IPS LCD. It covers hardware setup, software installation, wiring connections, and provides a sample code to visualize the chart on the LCD screen.

Hardware Preparation

Software Preparation

Wiring Diagram

The following provides two ways to connect 1.47" display to the FireBeetle ESP32-E:

  1. Directly connect to GDI via FPC.
  2. Connect to SPI function pin.

Connection 1:

DFR0995-FPC connection

Wire Sequence for GDI connection:

FPC PINS FireBeetle ESP32 PINS Description
VCC 3V3 3.3V
BLK 12/D13 Backlit
GND GND GND
SCLK 18/SCK SPI Clock
MOSI 23/MOSI Master output, slave input
MISO 19/MISO Master input, slave output
DC 25/D2 Data/Command
RES 26/D3 Reset
CS 14/D6 TFT Chip-select
SDCS 13/D7 SD chip-select
FCS 0/D5 Font library
TCS 4/D12 Touch
SCL 22/SCL I2C clock
SDA 21/SDA I2C data
INT 16/D11 INT
BUSY-TE 17/D10 Anti-tear pin
X1 NC User-defined pin 1
X2 NC User-defined pin 2

Connection 2:

DFR0995-SPI connection

Wire sequence for SPI connection:

LCD Display ESP32-E
VCC 3V3
GND GND
SCLK 18/SCK
MOSI 23/MOSI
CS 14/D6
RES 26/D3
DC 25/D2
BLK 13/D7

Sample Code

Coordinate line chart drawing program.

#include "DFRobot_UI.h"
#include "Arduino.h"
#include "DFRobot_GDL.h"
#include "DFRobot_Touch.h"

#define TFT_DC  D2
#define TFT_CS  D6
#define TFT_RST D3
#define TFT_BL  D4


DFRobot_ST7789_172x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST,/*bl=*/TFT_BL);
/* M0 mainboard DMA transfer */
//DFRobot_ST7789_172x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST,/*bl=*/TFT_BL);

DFRobot_UI ui(&screen, NULL);

int16_t point3[7][2] ={{0,50},{10,55},{15,65},{20,70},{63,75},{70,80},{80,90}};//Coordinates for line points 
void setup()
{
  ui.begin();
  DFRobot_UI::sCoordinate_t &coord = ui.creatCoordinate();
  coord.setPoint(point3,7,COLOR_RGB565_RED);//Line color 
  ui.draw(&coord);

}
void loop()
{
  ui.refresh();
}

Result

Burn the codes into the ESP32-E, then the screen shows a line chart.

DFR0995-Line chart

Was this article helpful?

TOP