Hi everyone. Happy holidays!
Um I have a dumb question. I’ve bought this small display a while back and it’s confusing as to how to wire it. I’ve attached a picture of the front and back. On the back it sez it’s an spi interface. On the front it lists pins that look like they are for I2C (sda,scl). Can someone point to an article that explains how to wire this?
So sorry but the pics I took are jpeg format and they won’t accept.
Model zjy-ips130-v2.0
Pixel 240x240
Driver ic-st7789
Interface spi
Pin
- Gnd
- VCV
- SCL
- SDA
- RES
- DC
- BLK
As facing the led pins from left to right.
As I said before everything I read about wiring to a wemos mini sez I should wire to miso, mosi, m-clk. This is confusing. Can I please get some direction on how to search for answers?
I do not see any pictures.
I presume you mean something like
It is SPI but with a single bidirectional pin e.g.
LED backlight, sometimes called BL. (it might be LED anode or cathode)
SDA bidirectional data pin. Connect to MOSI
SCK clock. sometimes called SCLK, SCL, ...
A0 data/command pin. sometimes called DC, RS, ...
RESET reset pin. you must connect. (or pullup)
CS chip select
Regular SPI has SCK, MOSI, MISO. In which case TFT pins are called SCK, SDI, SDO.
If the pin is bidirectional, it is called SDA. You can use it unidirectionally via MOSI. MISO pin is unused. The AVR hardware can not handle bidirectional data pin.
David.
Ah-ha. You have a 3.3V ST7789 display that has no CS pin. It needs SPI mode#3.
Either use Adafruit_ST7789 with bit-bang constructor or edit SPITFT to use "settings" to use mode#3 in Adafruit_SPITFT_Macros.h (in the Adafruit_GFX directory)
1 Like
Hi David! Again thank you for your time and energy
I have this same display:
https://nl.aliexpress.com/item/Nieuwe-IPS-1-3-inch-3-3-v-12PIN-SPI-HD-Full-Color-TFT-Scherm-ST7789/32859772356.html?spm=a2g0z.search0104.3.18.460a81d3WF9OD4&transAbTest=ae803_4&ws_ab_test=searchweb0_0%2Csearchweb201602_8_10065_10068_10890_319_10546_317_10548_10696_10084_453_454_10083_10618_10304_10307_10820_537_536_10902_10843_10059_10884_10887_321_322_10103%2Csearchweb201603_70%2CppcSwitch_0&algo_pvid=94ca7889-37a1-497a-a89d-5612414879c9&algo_expid=94ca7889-37a1-497a-a89d-5612414879c9-2
and I just don't succeed in letting it work with my UNO...
So I have these 7 pins, from which I connect two, one to ground and the other to 3,3V on the uno. Where do I connect the rest to?
display Uno
GND --> GND
VCC --> 3,3V
SCL
SDA
RES
DC
BLK
david_prentice:
Ah-ha. You have a 3.3V ST7789 display that has no CS pin. It needs SPI mode#3.
Either use Adafruit_ST7789 with bit-bang constructor or edit SPITFT to use "settings" to use mode#3 in Adafruit_SPITFT_Macros.h (in the Adafruit_GFX directory)
How can I change the code in Adafruit_SPITFT_Macros.h to use SPI mode 3?
Thank you,
D
The clue is looking for "MODE"
#ifdef SPI_HAS_TRANSACTION
#define HSPI_BEGIN_TRANSACTION() _spi->beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE3))
#define HSPI_END_TRANSACTION() _spi->endTransaction()
#else
#define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); _spi->setBitOrder(MSBFIRST); _spi->setDataMode(SPI_MODE3)
#define HSPI_END_TRANSACTION()
#endif
But your main problem is Uno. It has 5V GPIO. You must use level shifters on every signal. Most chips are NOT input voltage tolerant. You can connect VCC to 3.3V but all the Uno signals are 5V. e.g. SCK high level will be 1.7V above VCC.
Life is much simpler if you use a proper 3.3V Arduino e.g. Zero, Due, ...
Or buy a Uno clone with switchable 3.3V / 5V.
David.
Thank you, David for your help!
Luckyly I have a bidirectionel logic level converter here so I can use it with my uno. I feed it at HV and LV respectivelly with 5V and 3.3 V. Grounds are also connected. This way I have 4 channels to convert data signals from 5V to 3.3V. Still don't see which pins I have to conect to get it working...
On the arduino Uno, there are pins
10 - SS
11 - MOSI
12 - MISO
13 - SCK
On the display I have
GND (connected to GND UNO)
VCC (connected to 3,3V UNO)
SCL
SDA
RES
DC
BLK
Which pins from the uno (10,11,12 and 13) and where do I connect via the logic level converter to the other pins on the display (SCL,SDA,RES,DC,BLK)?
My other question is about the Adafruit_GFX directory, I use this library:
The Adafruit_SPITFT_Macros.h is empty besides a few lines of comment in it, I can't find these lines in the code:
#ifdef SPI_HAS_TRANSACTION
#define HSPI_BEGIN_TRANSACTION() _spi->beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE3))
#define HSPI_END_TRANSACTION() _spi->endTransaction()
#else
#define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); _spi->setBitOrder(MSBFIRST); _spi->setDataMode(SPI_MODE3)
#define HSPI_END_TRANSACTION()
#endif
or am I using the wrong library?
Thank you for your help, I appreciate it.
grtz,
David
God gave you the Library Manager. Use it.
GND (connected to GND UNO)
VCC (connected to 3,3V UNO)
SCL SCK level-shifter
SDA MOSI level-shifter
RES 8 level-shifter
DC 9 level-shifter
BLK n.c.
If you want to switch the backlight on and off, connect BLK via 10k to any GPIO pin. You may find that you need a stronger resistor than 10k.
A level shifter would be better.
I use 8 for RES and 9 for DC. Just make sure that these match the constructor.
You can use -1 for CS or some unused GPIO pin.
When you have investigated library versions via the Library Manager the answer is obvious.
David.
david_prentice:
God gave you the Library Manager. Use it.
I always use what God gave us.
david_prentice:
When you have investigated library versions via the Library Manager the answer is obvious.
I did the research for every version of this library, looked into every Adafruit_SPITFT_Macros.h file , all point to the Adafruit_SPITFT class, but still can't find this code to change it to spimode 3...
Ok. What version of Adafruit_GFX is reported by the Library Manager?
Where have you been installing libraries?
When you build a sketch the verbose compile shows the library version, location, and whether it found multiple locations.
Copy-paste just those lines. Do not paste all the reams of verbose report.
Look at my posts. I tend to show libraries, flash size, SRAM size.
David.
My apologies. I was using Adafruit_GFX v1.3.6. Meanwhile Adafruit have hacked the whole project in the last few weeks.
The mode is now set in Adafruit_SPITFT.cpp
void Adafruit_SPITFT::initSPI(uint32_t freq) {
...
#if defined(SPI_HAS_TRANSACTION)
hwspi.settings = SPISettings(freq, MSBFIRST, SPI_MODE0);
#else
...
I have not tried this new arrangement yet.
Bear in mind that Adafruit have their own product range.
It is not in their interest to support all Ebay displays.
Adafruit have been doing a lot of work improving the performance on ARM and Expressif e.g. with DMA.
This appears to be hard coded in MODE0
Your CS-less display does not like MODE0.
Your CS-less display is a real pain without CS. It responds to everything on the SPI bus. I intend to experiment with the NOP command. Perhaps I can make it ignore traffic with a NOP followed by DC=1.
David.
david_prentice:
Ok. What version of Adafruit_GFX is reported by the Library Manager?
version of the Adafruit_gfx library in library manager is 1.4.7
david_prentice:
Where have you been installing libraries?
on my desktop
david_prentice:
When you build a sketch the verbose compile shows the library version, location, and whether it found multiple locations.
Copy-paste just those lines. Do not paste all the reams of verbose report.
Look at my posts. I tend to show libraries, flash size, SRAM size.
Here is part of the output:
Using library Adafruit_GFX_Library at version 1.4.7 in folder: C:\Users\David\Desktop\libraries\Adafruit_GFX_Library
Using library Adafruit_ST7735_and_ST7789_Library at version 1.2.8 in folder: C:\Users\David\Desktop\libraries\Adafruit_ST7735_and_ST7789_Library
Using library SPI at version 1.0 in folder: C:\Users\David\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI
Sketch uses 18466 bytes (57%) of program storage space. Maximum is 32256 bytes.
Global variables use 753 bytes (36%) of dynamic memory, leaving 1295 bytes for local variables. Maximum is 2048 bytes.
What I'm trying to do is run the graphicstest sketch from the Adafruit_ST7735_and_ST7789_Library.
Meanwhile I read your reply and modified the SPI mode to mode 3 in Adafruit_SPITFT.cpp
Now it works but shows only a small part of the images. The rest is randomly greyed. I gues it has something to do with the 240*240 resolution.
We're getting there slowly...
Thanks anyway for your help.
David