View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
#ADAFRUIT_ST7789 LIBRARY #ARDUINO #CODING #ESP32-S3 #HARDWARE SPI #SOFTWARE SPI #SPI #TROUBLESHOOTING

A few people commented on my Arduino Nano ESP32 video around the speed of the display updates. A kind commenter pointed out the issue - the default constructor of the Adafruit_ST7789 library uses software SPI when you use custom pins.

With the ESP32-S3 we can use any pins for hardware SPI - but the library assumes that it needs to use software SPI which makes things really slow.

The fix is to use the hardware SPI constructor of the library. This doesn’t seem to be documented particularly well - at least I can’t find any good references. But for future me, here’s the code:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>             // Arduino SPI library
 
// ST7789 TFT module connections
#define TFT_CS    10
#define TFT_DC    9
#define TFT_SCLK  13
#define TFT_MOSI  11
#define TFT_RST   8

Adafruit_ST7789 *_tft = NULL;

void setup(void) {
  Serial.begin(115200);
  Serial.print(F("Hello! ST77xx TFT Test"));
 
  SPIClass *spi = new SPIClass(HSPI);
  spi->begin(TFT_SCLK, -1, TFT_MOSI, TFT_CS);
  tft = new Adafruit_ST7789(spi, TFT_CS, TFT_DC, TFT_RST);
  // 80MHz should work, but you may need lower speeds
  _tft->setSPISpeed(80000000);
  // this will vary depending on your display
  _tft->init(240, 280, SPI_MODE0);

Have a look at the video to see the difference in action - it’s pretty mind blowing!

#ADAFRUIT_ST7789 LIBRARY #ARDUINO #CODING #ESP32-S3 #HARDWARE SPI #SOFTWARE SPI #SPI #TROUBLESHOOTING

Related Posts

Self Organising WS2811 LEDs - I've successfully used addressable WS2811 LED strings and an ESP-CAM board to create an adjustable lighting system. The best part is that the image processing code can be duplicated in JavaScript which allows you to use a plain dev board to drive the LEDs instead of needing a camera on your ESP32 board. If you want to replicate this project, you'll need your own ESP32 dev board and some addressable LEDs. After figuring out the location of each LED in 2D space, it's easy to map from each LED's x and y location onto a pattern you want to show on the frame buffer. Desiring to keep it accessible, I've posted detailed instructions and my sample code on GitHub, making sure anyone with basic knowledge can undertake this fun technological DIY project!
Connecting up the MCP23S17 and HD44780U based LCD - Ever wondered how to hook up an LCD display with your Raspberry Pi without using up all your GPIO pins? With the right tools, such as the MCP23S17 and wiringPi, you can effortlessly keep your I2C, UART, and SPI functionalities free for other worthwhile endeavors. This blog post truly proves that the GPIO is quite flexible with the I2C or SPI pins and setting up the MCP23S17 is as simple as connecting the pins. And with support for 5v LCD modules, I can assure you that this setup is definitely lit!
The PCBs are in production - what have I messed up? - After some stress and trepidation, I finally took the plunge and sent my PCB design off for manufacturing. My design centers around building a large seven-segment clock with LED filaments. Jumping hurdles such as voltages, pin usage, and limiting the load on my power supply, I've settled on the ESP32 as the system's heart and come up with a final circuit design. While doing this, I've quickly realized I could improve my layout and fixed a small mistake. Also, I've prepared for either types of LED filaments - the high-voltage ones or the larger, 3v ones. However, I did bungle up a couple of things on the enable line of the shift registers and board layout. But hey, this is a learning curve, right? Can't wait to get the boards and see what other exciting errors surface!
Minimalist Microcontroller: Building a Bare-Bones Dev Board - In a thrilling DIY endeavour, I attempted to build the most minimalist ESP32 dev board possible. Diving deep into the schematic of the ESP32 S3 WROOM module, I chopped out the non-essentials and whittled our needs down to bare bones. The experiment saw me juggling USB data lines and voltage regulators, waving goodbye to an array of capacitors and connectors and boldly embracing the simplicity of direct connections. Despite a few hitches, the miniature Frankenboard came alive, proving that sometimes less is more...at least in the world of microcontrollers.

Related Videos

Arduino Nano ESP32 - It's nice - But probably not for me. - In this video, I took a deep dive into the Arduino Nano ESP32 and compared it with other available boards in the market. Despite its seemingly high cost as compared to the options on AliExpress, its overall quality, fantastic documentation, and the fact that it fits neatly into the Arduino ecosystem makes it a good buy, especially if you've already invested in the Arduino Nano and its shields. The board has a few interesting peculiarity, including the use of a NORA-W106 module, a switch mode step-down converter for power, and an RGB LED. However, I was disappointed to find out it doesn't come with built-in battery charging. The pin labelling and remapping could definitely cause some confusion, especially if you're transitioning from other ESP32 boards. It's a fairly decent ESP32-S3 board if that's what you're after. But given a choice, I'm keener on the Unexpected Maker boards or the cheap boards on AliExpress.
Unlocking the Power of ChatGPT: Effortlessly Generate Arduino Code for Your Projects! - Witness ChatGPT's impressive potential for generating working Arduino code, as demonstrated in a step-by-step ESP32-based project utilizing a potentiometer and dot star LED.
ESP32 Over The Air (OTA) Update - no wires required! - Learn how to easily update an ESP32 over the air in this quick and exciting tutorial that uses Wi-Fi and a few lines of code to remotely update your device!
ESP32 HTTP Web Server With Content Served from SPIFFS Filesystem - Learn how to create a simple ESP32 web server and user interface using basic HTML and JavaScript, and control an LED via an HTTP endpoint. This tutorial demonstrates the ease of setting up a web server on ESP32 devices and serving compressed content from SPIFFS.
Supersize Seven Segment Clock - Learn about the process of assembling a large LED filament clock in this hands-on project video, covering both hardware and software aspects. Watch as the creator troubleshoots and implements improvements throughout the build, resulting in a functional and impressive timepiece!
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts