Problem with round KEYESTUDIO 2.2'' TFT LCD Display Screen Module for Arduino R3

Hi everyone,
I just received this little tft display. From Keyestudio
There is a demo code that works fine with an arduino uno R3, I attach it.
But I want to use it with a mega board and the display no more works with the same code and connections.
Any idea?
Is there some possible diferences between arduino uno and mega that I miss?
Thank you.


demo_tft.ino (586 Bytes)

More members will see your code if posted properly. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Ouch. Please post a link to the item that you have bought.

You will get the "best" from the Forum if you post a clickable link to your display and if you paste code directly to the message. (obviously small code and within a Code window)

here is the link to the wiki of the display.

include is the description and the code.
Thank you.


And the code directly

#include "DFRobot_ST7687S_Latch.h"

#ifdef __AVR__
uint8_t pin_cs = 3, pin_rs = 5, pin_wr = 6, pin_lck = 7;
uint8_t pin_cs = D3, pin_rs = D5, pin_wr = D6, pin_lck = D7;

DFRobot_ST7687S_Latch tft(pin_cs, pin_rs, pin_wr, pin_lck);

void setup(void)

void loop(void)
  tft.drawTriangle(-20, -50, 0, 0, 50, 20, DISPLAY_ORANGE);  //draw triangle
  tft.fillTriangle(-20, -50, 0, 0, 50, 20, DISPLAY_ORANGE);  //fill triangle with color

The SPI pins on a Mega are 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). So you need to connect SPI-SCL to pin 52 and SPI-MOSI to pin 51.

Please look at the pcb of your display. What level shifter electronics is present.

From the ST7687S datasheet:

9.1 Absolute Maximum Ratings
Supply voltage 1 VDD - 0.3 ~ + 3.6 V
Input voltage range VIN - 0.3 ~ VDD + 0.3 V

It is clearly not 5V compatible. Mind you, ST7735S datasheet is similar and the ST7735S appears to be Input Voltage Tolerant.

Regarding software. I am sure that we could produce an Adafruit_GFX style hardware library within a few hours. It just requires you to confirm “correct electrical spec” and test the software.

I have not looked at the DFRobot code. It is generally quicker to write from scratch.


Thank you.
I was sure, it was that kind of trick.

Ah and I see your message David,

In fact when connecting miso & scl correctly on the mega the is working.
I have check that this display is 3,3 v and 5 v compatible.

Thank you.

Look at the pcb. Are there any components except the terminal pins? e.g. resistors, level shifter chips, ..., voltage regulator, ...

It looks as if DFRobot have a Display library of their own.

If the electrical spec is ok, the DFRobot examples should work fine on the Mega or Uno. Just make sure that you use the correct hardware SPI pins e.g. from 3x2 SPI header.


Hi David,
I attach a photo of the pcb.
Does it talks to you?

Now that have connected the SPI correctly on the mega the display works.
In fact I have loaded the DFRobot libraries, there are some examples, but they are not very clear.

Yes, you have lots of electronics. I can’t read the part numbers. You can.

I suspect that U2 is AMS1117
and U3 is CD4049 or similar.

So my worries are resolved. 5V logic is ok.

The DFRobot examples should work fine. (as you have proved)



My eyes are so poor Ican't read.
The only text I ca, read is CS 595 on U3.

I have got some info on github.
DFRobot use the same library as for ST7687S, but my display is round so there are some strange action for the coordinate.
I found that for the colors. My question is can I change continuously a color? Do you think I can just increment the value?

Thank you.

//color define 
#define DISPLAY_BLACK 0x0000 /* 0, 0, 0 */
#define DISPLAY_NAVY 0x000F /* 0, 0, 128 */
#define DISPLAY_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define DISPLAY_DARKCYAN 0x03EF /* 0, 128, 128 */
#define DISPLAY_MAROON 0x7800 /* 128, 0, 0 */
#define DISPLAY_PURPLE 0x780F /* 128, 0, 128 */
#define DISPLAY_OLIVE 0x7BE0 /* 128, 128, 0 */
#define DISPLAY_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define DISPLAY_DARKGREY 0x7BEF /* 128, 128, 128 */
#define DISPLAY_BLUE 0x001F /* 0, 0, 255 */
#define DISPLAY_GREEN 0x07E0 /* 0, 255, 0 */
#define DISPLAY_CYAN 0x07FF /* 0, 255, 255 */
#define DISPLAY_RED 0xF800 /* 255, 0, 0 */
#define DISPLAY_MAGENTA 0xF81F /* 255, 0, 255 */
#define DISPLAY_YELLOW 0xFFE0 /* 255, 255, 0 */
#define DISPLAY_WHITE 0xFFFF /* 255, 255, 255 */
#define DISPLAY_ORANGE 0xFD20 /* 255, 165, 0 */
#define DISPLAY_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define DISPLAY_PINK 0xF81F

I just guessed CD4049. I should have looked at the HC595.c file in the library.

Another guess: it takes 5V SPI commands from Arduino and uses a HC595 SPI to Parallel chip.
If it works don't fix it.

Regarding colours. Yes you can change any colours. Just like on any TFT library. You increment the R or G or B component. Not the 16-bit value.

Use your imagination to say what you want to do. The DFRobot library looks pretty similar to a regular Adafruit_GFX style library. Just ask.


Hi David,
I am not able to find the right solution to change the color gradually.
Do you have an idea?
My project is to simulate a "magic eye", you know the electronic tube in old radio receiver, tha kind of tube is very difficult to find. So I what to employ that display in place, the only input will be dc from the mf stage.
I am able to transform the input in coordinates but i'd like to simulate the color effect with very subttle variations of green.

Thank you for your help.

All libraries will have some form of constructing a colour from R, G, B e.g.

	uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3); }

The important tip is to control one component at a time. e.g. different intensities of Green
Or perhaps different shades of Magenta.

Personally, I remember the Tuning indicator that was two green bars that met in the middle. I forget the part number of that specialised Vacuum Tube.

Bodmer’s library examples tend to have colour shades.
But most libraries have an example of “Adafruit Graphics Tests”. Look how colour shades are done.


Hi David,

Thank you for your precious information.
Now I can control the color very continuously.
But I discover the weak point of this display, the refreshing time is very slow, when I send a FillScreen you can see the screen filling slowly( 300ms I believe).

The trick is to update the smallest area of the screen. e.g. overwrite a Sensor value or animate a bar graph.

Animating a meter needle is fairly complex. You rub out the old needle by drawing in the background colour and then plot the new needle in the foreground colour.

But most importantly. You only draw something if it has changed. Whether it is a needle, graph point, numeric value, bar, ..., colour, ...

I have not looked at the DFRobot library. The speed should not be noticeable if you follow the above strategy. Bear in mind that humans can only read numbers or text at a moderate pace. No point in updating more often than necessary.

If you have any "other" colour displays, port your code. Compare performance.


Are you sure that you are using the hardware SPI? Can you post your test code that shows the slow refresh?