Closed Mearntain closed 1 year ago
Try it again after commenting out the following lines in your setup file thus: //#define TFT_MISO PIN_D6 //#define TFT_MOSI PIN_D7 //#define TFT_SCLK PIN_D5
Also run Read_User_Setup again and check the reported gpio numbers are correct.
The 3 lines have been commented out, ran Read_User_Setup again, but still am unable to get the display to work with the library.
I see that the OP states: TFT_eSPI library version 2.5.0
Yet the Read _User_Setup indicates the version is 2.4.79
Make sure you do not have multiple copies of the library loaded.
I use IDE 1.8.xx but I will try with the new 2.0.4 and see if that makes a difference.
Yep, you are correct that I did have a typo, but I do only have 1 library installed. I downgraded to .79 last night before posting to see if it would fix my issue, and it didnt. .
On another computer with the same setup.h, I am also having the same issue with Arduino 1.8.xx. That computer never had tft_espi until today so that was a fresh library install there.
For what its worth, I did have this working on the same setup in the past (deleted setup file by accident at some point), but I remember there being a "got ya" in the setup file to where I had to add something special but can't remember what it was.
And if it helps any, if you are familiar with the Adafruit_ST7789 library basic example, If i use option one with hardware SPI (plugged into same SPI plugs as my setup.h file, the display doesn't work. If I choose option 2 and explicitly define SCLK and MOSI, it works as expected.
This is the display
https://learn.adafruit.com/adafruit-1-14-240x135-color-tft-breakout/pinouts
Here is my specific board
Ah! You say, "If i use option one with hardware SPI (plugged into same SPI plugs as my setup.h file, the display doesn't work. If I choose option 2 and explicitly define SCLK and MOSI, it works as expected."
The second option works because the Adafruit library will then use software SPI which can be used on any pins. The fact that the first option does not work shows that the hardware SPI pins are not correctly wired to the display.
How can this be? The answer I think is that the Wemos D1 mini comes in different versions. Older boards mapped different pins to say D7!
Check your Wemos board version and try to find the GPIO pin number map for your actual PCB, I think the pin map posted above is incorrect for the board you have. Then use the GPIO numbers ( not Dx or PIN_Dx references) in the setup file.
That is the pinout that was given to me when I originally purchased the chips. Any idea of how to tell which one this is? I've tried every combination of pinouts I could find online and yet to make any work.
UPDATE - I got home, and using a raw chip pinout for the wifi chip, I beep tested MOSI to truly be D7 as expected along with SCLK beeping out to D5 as expected. I have even substituted actual GPIO pin numbers in the setup as well and still get the same result. Even more stumped now..
UPDATE AGAIN - using a multimeter, I am getting what I assume to be proper readings from my MOSI (D7 - GPIO 13) and SCLK (D5 - GPIO 14) pins (all pins defined read about 1.6V while all non-defined pins measure the full 5V). This really makes me think this is a issue with the setup.h file
(edit to clarify - i was testing voltages between 5V pin and each individual output)
A logic 1 will be about 3.3V so measuring from 5V to a logic 1 would give about 1.7V which is what you measure.
There are changes in the latest ESP8266 board package. The board architecture is now signalled by:
#define ARDUINO_ARCH_ESP8266
It used to be:
#define ESP8266
It looks like the Adafruit library still uses lines like:
#if defined (ESP8266)
...
#endif
So that means Adafruit_GFX is not completely compatible with the latest ESP8266 board package. This would explain why hardware SPI does not work.
The latest TFT_eSPI github master library has been updated to handle old and new board packages. Older versions of TFT_eSPI will only work with older ESP8266 board packages.
Maybe try older board packages?
Just downgraded it all the way back from the current package to 2.6.0 and no change. I'm open to try anything else...no exaggeration, I've seriously got around 18 hours of trials trying to get to this to work so far. I even tried on another board, Adafruit Huzzah32 and tried it connected to both the HSPI and SSPI pins and still unable to make this library work (however can get the other libaries to work on the huzzah32 no problem, however not in hardware spi mode. Nothing that I missed over in my setup.h file that I posted? If not, there must be something that I am just vastly misunderstanding
I'll connect up a ESP8266 board to an ST7789 display and see if it works for me.
Which board do you select in the menu:
I have tried several boards in the menu all with the same result, but LOLIN(WEMOS) D1 mini (clone) is my normal go-to for uploading
I have connected an ST7789 screen to an ESP8266 and it is working fine.
Sequence:
My display has no 5V to 3.3V regulator so it is powered from 3.3V only.
Next change to Arduino IDE 2.0.3 (already configured to use the same sketch/libraryfolder and board packages as the older IDE).
I have a 240x240 display but did NOT set the size in the setup file so it will be treated as 240x320 and not all drawn graphics are visible as expected.
So it appears I have wired up the display the same as yours and it works fine.
The only difference is that I used a NodeMCU board as I do not have any Lolin boards. However I would not expect that to make a difference.
Do check your display has a 5v to 3.3V regulator if you are powering from 5V. Make sure the display backlight does not flicker during program execution as that would indicate an inadequate power supply.
Other than that I don't think I can help further.
Sounds good - my display does have a regulator on it. Even powering with 3.3 instead, no change. Tried again with all of your mentioned settings and no new results (see screenshot, was unable to include tft_espi in same screenshot but that is at 2.5.0 fresh install).
I wish I could chalk it up to bad hardware or something like that, but unfortunately that is not that the case as it works perfectly fine (just compiled this after the failed tft_espi attempt) with a different libary. And the fact that I did use this library about a year ago with the exact same hardware, I know it is possiible. I remember searching Google for hours on end and founds tons of people with similar issues, but all seemed to have the same fix. I was only able to find one post (or comment maybe) that had a direct reesolution to my issue. I really wish I could find that link and have been searching over a week now. Only hope is maybe my computer still has browser history saved from that far back to find it again.
I do recall it being a adafruit brand display issue specific to your library if that rings a bell at all?As mentioned in an earlier post, I can not get the library to work on ESP32 either. Maybe I get lucky and find the year old history in the meanwhile
It is supsicious that it does not work with an ESP32 either.
I think the Adafruit displays are 5V tolerant and have inline buffers. Maybe drop the SPI clock speed down to a very low value of 1MHz and see if it works. It could be there is a large delay in the buffers if they are powered froma low voltage?
The display does have a HC4050 level converter so that will limit the maximum SPI rate as I expect it is run off 3.3V.
Well.....I made progress....but unsure of what it was the caused that progress....BUT Sprite example does work now.
I'm making an assumption that there is some sort of time delay issue (too short) or something causing the problem. Or maybe I'm completely wrong?
Upload...nothing happened. Reset button, nothing happens. (THIS NEXT PART MIGHT BE IMPORTANT) Unplugging power and then plugging back in, the LED on board stays solid blue as if boot failed or froze maybe? I hit the reset button, blue light returns to normal operation but display still doesnt work. Wait a few more seconds, reset button, and Sprite starts displaying. At this point I can hit reset a couple more times and the sketch resets and runs as expected and I can repeat as many times as I want.
Since the Read_User_Setup sketch runs as reported above this shows boot occurs correctly after sketch upload.
Did you try a much lower SPI clock speed?
Another option is to change this line: https://github.com/Bodmer/TFT_eSPI/blob/master/TFT_eSPI.h#L132 To invoke mode 0 rather than 3.
Yep, I did try a much lower SPI speed, down to 1mhz as you suggested. That was when I was able to get the display to work from the previous picture.
I changed SPI mode to 0 and that caused the display to power up immediately after pressing the reset button. I played with multiple speeds afterwards and 1mhz seems to be where its at (faster wasn't displaying). I do still have to press reset twice to make it power up, but not with the long delays between now after changing SPI mode. I supposed maybe trying a different reset pin may fix that.
At least its working now and I'll play with the settings to get it optimized. I appreciate you hanging in there with me!
Re. SPI mode. You can invoke mode 0 by adding:
#define TFT_SPI_MODE SPI_MODE0
To the setup file.
Software SPI with the Adafruit library would probably operate at a few MHz.
I suspect the HC4050 logic level translator is introducing signal skew. Powering the display from 5V will raise the chip supply voltage slightly and then the buffer delay will reduce slightly.
You may find changing the GPIO for one of the pins DC, CS or RST solves the boot problem. This is because some of the GPIO have alternative functions at boot time and are required to be in a certain state immediately after power on. This seems to fit with your boot up issues.
You can buy ST7789 displays that do not have the buffer cheaply from China if you are patient with the long postal delay. I have also seen them on Amazon. Purchasing and integrated display plus processor is also relatively inexpensive.
I am going to close this as I think this is a hardware level problem. I think the ESP8266 can bitbash SPI at around 6MHz, so try that speed with hardware SPI. If you solve it or have more info on the required operating constraints then do share.
I did a little playing around just now and it appears that the board does work at 6mhz as you suspected. That seems to be the cutoff and I am unable to get it to display past that. Thanks again for the help in getting things going!
OVERVIEW:
I just want to run any basic example - display an image
User_Setup.h:
OUTPUT FROM DIAGNOSTIC SKETCH: