Hello,
I am trying to use the Adafruit 684 SPI OLED module with an ESP32-WROVER module. Having already proven the OLED and code functioned using an Arduino UNO (guide available from Adafruit on this), I transferred over to ESP32 and changed pin definitions in the code for the SPI pins of the ESP32. I confirmed these were the correct pins using a basic sketch which printed to serial monitor which pins to use for each of the SPI signals.
I don't get good communication from the VSPI lines, and get corrupted data show on the OLED. If I initiate the OLED using SW SPI rather than the HW SPI I can communicate (e.g Adafruit_SSD1331 tft = Adafruit_SSD1331(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST);).
I don't fully understand why the code doesn't work when porting over to ESP32, there are plenty of examples online of others using ESP32 with the same libraries (TFT driver library, Adafruit_GFX.h and Adafruit_ImageReader.h) without issue but none of them mention making any changes. I feel that there must be some element of setup required to get the SPI working on the ESP32 but can't see anything obvious in the libraries.
Has anyone else tried to use an OLED or TFT display using the Adafruit libraries? As a target, I am looking to read .BMP images from an SD card and display them on the OLED module.
Please see below my code, which is an adapted version of the BreakoutSSD1331.ino example which is part of the Adafruit_ImageReader library:
[Codebox]#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_SSD1331.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define TFT_CS 4 // TFT select pin
#define TFT_RST -1 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 3 // TFT display/command pin
#define SD_CS 5 // SD card select pin
#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_SCK 18
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_SSD1331 tft = Adafruit_SSD1331(&SPI, TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(115200);
Serial.println(F("Initializing screen"));
tft.begin(); // Initialize screen
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
Serial.println("Filling screen BLUE");
tft.fillScreen(BLUE);
Serial.println("Screen fill complete");
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
Serial.println(F("OK!"));
// Load full-screen BMP file 'daffodil.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading daffodil.bmp to screen..."));
stat = reader.drawBMP("/daffodil.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?[/Codebox]
Adafruit 684 with ESP32-WROVER
-
- Posts: 2
- Joined: Sun Feb 19, 2023 4:08 pm
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: no_esperience and 99 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.