The W25Q128JVSIQ from Winbond is a 128Mbit SPI NOR flash memory chip ideal for embedded storage. When paired with an ESP32 microcontroller using the Arduino IDE, it provides a low-cost, high-capacity solution for applications like sensor data logging, offline storage, and OTA buffering.
Why Use External SPI Flash?
Although the ESP32 has internal flash, it's limited in capacity and used for the file system and firmware. External flash like the W25Q128JVSIQ offers:
- Dedicated data logging space (16MBit = 16MB)
- Non-volatile memory for offline storage
- SPI interface allows fast, low-pin communication
- Flexibility for OTA, logs, or large assets
Wiring Diagram
Connect W25Q128JVSIQ to ESP32 using the SPI interface:
- CS → GPIO5
- CLK → GPIO18
- MOSI → GPIO23
- MISO → GPIO19
- VCC → 3.3V
- GND → GND
Required Libraries
- SPIMemory by Marzogh (for Arduino)
Example Code
Below is a basic example using SPIMemory to write and read data:
#include
SPIFlash flash(5); // CS on GPIO5
void setup() {
Serial.begin(115200);
if (flash.begin()) {
Serial.println("Flash memory initialized");
} else {
Serial.println("Flash memory init failed");
while (1);
}
// Write string to memory
flash.eraseSector(0);
flash.writeStr(0, "ESP32 data logging test");
}
void loop() {
String data = flash.readStr(0);
Serial.println("Read: " data);
delay(3000);
}
Applications
- Sensor data logging in remote environments
- Firmware and OTA update buffering
- Audio or image storage for ML/AI projects
- Offline event or debug logging
FAQ
Q1: Can I use other SPI pins on ESP32?
Yes, ESP32 supports SPI on many GPIOs, but GPIO5/18/19/23 are the most commonly used hardware SPI pins.
Q2: How do I erase the flash?
Use flash.eraseSector(address)
to erase 4KB sectors. You must erase before overwriting.
Q3: Is the W25Q128JVSIQ compatible with Quad-SPI?
Yes, but most Arduino libraries use standard SPI mode. QSPI access may require advanced drivers or ESP-IDF.
Conclusion
The W25Q128JVSIQ is a reliable choice for adding external flash to your ESP32 projects. With Arduino IDE and libraries like SPIMemory, you can easily integrate high-capacity, non-volatile storage for data logging and more. For robust applications like remote sensing or OTA buffering, this chip expands your ESP32's potential significantly.