Trying to use Bodmers Artificial Horizon code with 160x80 7735S mini display

I am trying to use Bodmers artificial horizon code with my st7735S Mini 160x80 display but his st7735 display library will not work with my display, I have got the display working using the UTFT Library then started trying to port the code to that library but it is proving too dificult. I defined my pins correctly with bodmers lib and I also tried the Adafruit Lib and changed spi mode from 0 to 3 but still am only able to get UTFT library to work on this display. Any sugestions?

Start with Adafruit_ST7735 library. Run all the examples.

Then run simple examples e.g. from Bodmer's TFT_ST7735 or TFT_eSPI libraries.

Make notes.
Type your notes to your message(s)


Thankyou David I have tried the GraphicsTest Example with pin defines

 #define TFT_CS        10
 #define TFT_RST        8 
 #define TFT_DC         9

and uncomment


leaving the rest commented and the screen stays black
on/offtest only has two options st7735 or 7789 so i use 7735 and serial monitor shows
21:37:17.576 -> ⸮ -- not sure what that is
the hallowing_m0 test leaves screen grey with
Hello! ST77xx TFT TestInitialized
21:43:29.300 -> 58
21:43:45.423 -> done
on serial mon

i went back to graphictest to check serial monitor but am now getting compile error 'tft' was not declared in this scope on line 345 (tft.fillScreen(ST77XX_BLACK):wink:

hallowing M4 is giving a compile error 'SPI1' was not declared in this scope on line 28

i will check it is not trying to use another library

What Arduino are you using?

It is always wise to start with the Software SPI constructor. Check your wiring.

You must use VCC=3.3V because there is no regulator on the display pcb.
U1 is a J3Y transistor for the backlight.


I have reinstalled library and now graphicstest compiles again with
22:15:05.848 -> Hello! ST77xx TFT TestInitialized
22:15:07.048 -> 58
22:15:23.212 -> done
on serial monitor.
when i said screen is grey earlier i guess i mean black with slight backlight ilumination this is all i get with all examples tried so far except utft using exact same wiring and pin defines
I am using nano but i am using npn transitor level shiftor with three 10k resistors i have scoped these ins and out with 4.89 on 5 v side and 3.46 on 3.3 side

i am using pin 11 spi data and 13 clk then 10 cable select 9 ds and 8 for reset all going through seperate transistor shifters , I am frequently switching back to utft library without changing wiring and screen displays the sign cos tan waves rectangles etc fine unless there is a difference in spi speed that is creating incompatability the display has a green tab and i tried both green tab inits in bodmers lib aswell as adding an 0x04 init which i beleive this screen uses

If the display works with UTFT, it should work with Adafruit.

Please paste your UTFT constructor.
Please paste your Adafruit constructor. Note that the example uses DC=8, RST=9

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
     tft.initR(INITR_MINI160x80);  // Init ST7735S mini display

Nothing will work if you have the pins wired differently to the constructor.


I have also tried rotation test screen stays black serial monitor shows
22:49:21.344 -> Hello! Adafruit ST77XX rotation testinit
22:49:22.544 -> This is a test of the rotation capabilities of the TFT library!
22:49:22.624 -> Press (or type a character) to advance
22:49:22.664 -> 0
22:49:37.825 -> 1
22:49:41.907 -> 2
22:49:42.827 -> 3

here is my constructor for adafruit i swap dc and reset

 #define TFT_CS        10
 #define TFT_RST        8 // Or set to -1 and connect to Arduino RESET pin
 #define TFT_DC         9

and this is my utft

// Initialize display
// Library only supports software SPI at this time
//NOTE: support  DUE , MEGA , UNO   If you use MEGA and UNO boar, you need to add level conversion.
//SDI=11  SCL=13  /CS =10  /RST=8  D/C=9
UTFT myGLCD(ST7735S_4L_80160,11,13,10,8,9);    //LCD:  4Line  serial interface      SDI  SCL  /CS  /RST  D/C    NOTE:Only support  DUE   MEGA  UNO

which i have just uploaded again and my screen is again working??
just remembered how to insert code sorry edited the posts with code.
You painfully helped me before with an mcufriend shield speccial on a bluepill I had faulty io pins giving strange read responses I am still greatfull to this day and can now write my own specials but this is just bizzare

This is my constructor : (I always have CS=10, DC=9, RST=8 on every display)

UTFT myGLCD(ILI9341_S5P,11,13,10,8,9);

So I don't trust your wiring / UTFT constructor.

I also don't trust your MODEL. UTFT v2.8.3 does not have any model : ST7735S_4L_80160

If you have installed a hacked library instead of from RinkyDink, please post a link.


Ok the Library that I can get working, I found on this page

and this is the file

because I had already wired my screen clk to 13 data to 11 cs to 10 dc to 9 and reset to 8 i have to swap the dc and reset pins in software constructor with each library i use but the one i link to above works a treat nothing else will .

I just took photos of it working with the above defines showing wiring and level shift
but need to find a host before i can post them

Ok I have uploaded the photos and also link to my level shift circuit I have 9 of them for use with other sensors etc not yet wired in So here is the level shift circuit
and photo one showing screen working latest sketch upload still running
and picture 2 close up on wiring to level shift
not sure why photos are not showing but i am inserting links instead
close up
screen working

I have just resoldered dc and reset swapped to fit original defines

and changed the code in utft from UTFT myGLCD(ST7735S_4L_80160,11,13,10,8,9); 

toUTFT myGLCD(ST7735S_4L_80160,11,13,10,9,8); 
and that still works

I have uploaded the adafruit sketch with new wiring and following code

#if defined(ESP32)
  #define TFT_CS         5
  #define TFT_RST        22 
  #define TFT_DC         21
  // define not needed for all pins; reference for ESP32 physical pins connections to VSPI:
  // SDA  GPIO23 aka VSPI MOSI
  // SCLK GPIO18 aka SCK aka VSPI SCK
  // D/C  GPIO21 aka A0 (also I2C SDA)
  // RST  GPIO22 aka RESET (also I2C SCL)
  // CS   GPIO5  aka chip select
  // LED  3.3V
  // VCC  5V
  // GND - GND
#elif defined(ESP8266)
  #define TFT_CS         4
  #define TFT_RST        16                                            
  #define TFT_DC         5

  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
  #define TFT_CS        10
  #define TFT_RST        9 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_DC         8
  // Use this initializer if using a 1.8" TFT screen:
  //tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

  // OR use this initializer (uncomment) if using a 1.44" TFT:
  //tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

  // OR use this initializer (uncomment) if using a 0.96" 160x80 TFT:
  tft.initR(INITR_MINI160x80);  // Init ST7735S mini display

  // OR use this initializer (uncomment) if using a 1.3" or 1.54" 240x240 TFT:
  //tft.init(240, 240);           // Init ST7789 240x240

  // OR use this initializer (uncomment) if using a 2.0" 320x240 TFT:
  //tft.init(240, 320);           // Init ST7789 320x240

  // OR use this initializer (uncomment) if using a 1.14" 240x135 TFT:
  //tft.init(135, 240);           // Init ST7789 240x135

again nothing that is using original wiring and correct constructs but works fine with the library i linked to

latest shot working on hacked library with untrusty wiring

Here is my code
and resoldered wiring dc and reset crossed back to dc pin9 and reset pin 8
still nothing on other libraries

I have tried spi mode3 changed in spitft.h and st77xx.h no joy changed back to 0 in both files also change spi freq from 32000000 to 10000000 and 2000000 and even 1mhz but still no joy just black screen everytime i go back to buydisplays hacked utft library and the example works ok again I think its time to go dream about it.

I am gobsmacked by your wiring. Hey-ho. If it works for UTFT it should work for Adafruit.

From #12 you say that you have DC=9, RST=8 and UTFT is working with:

UTFT myGLCD(ST7735S_4L_80160,11,13,10,8,9);

So I would expect you to:

  1. install Adafruit_ST7735 and Adafruit_GFX via IDE Library Manager
  2. edit the Adafruit example to match your wiring e.g.
 #define TFT_CS        10
 #define TFT_RST        8 // Or set to -1 and connect to Arduino RESET pin
 #define TFT_DC         9
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(    10,     9,       11,       13,        8);
     tft.initR(INITR_MINI160x80);  // Init ST7735S mini display

You have obviously been clutching at straws. So I strongly advise that you re-install Adafruit libraries.

I don't have your 160x80 display.
The EastRising code from BuyDisplay is a modified UTFT v2.7.9 when current UTFT is v2.8.3.
It looks as if it should work fine. And you have confirmed this.

Seriously. Life is much simpler with civilised 3.3V GPIO.


When Adafruit is verified with the Software constructor, you can try the Hardware SPI constructor:

//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(    10,     9,        8);

Hi David thanks for you reply , I think you missed the picture in post twelve that shows I not only changed the wiring to original layout but also the code , so yes I have tried both libraries with my odd setup and only one works then corrected the wiring to match standard and changed defines back to original with only the utft working in all cases I have also tried reinstalling the adafruit library with a fresh download but no joy. So my wiring is now clk-13 mosi-11 cs-10 dc-9 and reset-8 , I changed it just incase the other libraries did not like my swapping pins although i could not see why when the code allows for that on cs dc and reset , and it works both ways in utft. Could you link me to the best Adafruit library download please.

I have some bluepills that i could use but they are for more important projects and because my transistor shifter shows clean signals on scope at both the 5 volt side and 3.3 side give take 0.2 volt max and it works on utft library I decided to carry on the way I am going with this one.

God gave you the IDE Library Manager. Use it.

The most important lesson is to verify wiring with "working code" e.g. UTFT

Do not alter physical wiring.
Configure the appropriate constructor on a different library example.

Always try Software SPI constructor first.

Never edit library code. Unless the author advises it.
Always use the Library Manager.
Remove any extraneous folders e.g. manually installed versions.

Life would be much simpler with a BluePill or ESP8266. Cheaper too !!


In post 11 is where I show that i changed wiring and defines of pin changes then in post 12 I took a picture of the screen with defines back to original . I have lost count how many times i have removed libraries then reinstalled with library manager and tried again but I will keep trying different versions I also updated two libraries originally with the dropdown version in library manager but I mean surely if one library is working through my bodged level shifter (which I like very much, as I get clean square waves on both levels and i checked all 9 with all 27 resistors and they are all similar) then the other library should work with the same signals unless it is a different speed which is why I tried changing the spi speed but I will delete every library and reinstall with library manager by typing in adafruit 7735 and selecting latest version but having tried so many times already I am not very hopeful. Anyway thanks for your time and views David I will post updates .
May I just add a little sarcasm without trying to deliberately upset anyone especially my God whom I love dearly
"God gave us a government why can't we get it to work?" Most inventors were experimentors! Take care All :smiley:

God gave us many good things.
I don't think She was guilty of "government"

I have several regular ST7735 SPI displays. 128x160 and 128x128. All of them with 3.3V GPIO. All work fine with several different libraries.
I don't think that I have ever used ST7735 with UTFT. I have now. It is fine (but SLOW)