Using Seeeduino XIAO and TFT SPI ST7735 display

A New Miniature Arduino Module

I should make it clear that I am not an Arduino expert so read on at your peril or your amusement.

Myself and a colleague ‘play’ with Arduino devices.   We were impressed by the new tiny module from  Seeeduino called the XIAO.   It has just 14 pins, all of which double or triple up in their use.   See DroneBots blog for more info on the device’s capability.

seeeduino xiao miniature arduino module
The Seeeduino XIAO miniature Arduino module. The connector is a USB-C.

We had some SPI driven ST7735 displays from Adafruit which we had successfully used on conventional Arduino devices.  We wondered if we could drive them from the XIAO.   This resulted in many many hours of frustration.   The SPI bus uses 5 connections and two of these pins (SCK and MOSI) on a normal Arduino device are hardware defined ports with specific pin numbers.  These pin numbers did not match the hardware defined ports on the XIAO and it seemed as a result that it did not want to talk.

Many hours later we seem to have got a solution.   To save others having the same frustration here is the header information we ending up using that brought success.  This is followed by the connections from the XIAO to the display. 

#include <Adafruit_GFX.h> // Include core graphics library
#include <Adafruit_ST7735.h> // Include Adafruit_ST7735 library to drive the display
#include <SPI.h> //Include SPI control library

//Define pins :
static const int TFT_CS = 3;
static const int TFT_RST = 2;
static const int TFT_DC = 1;

// Create display:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
0    -    nc
1    -    DC  (to display pin 4)
2    -    RST (to display pin 3)
3    -    CS (to display pin 6)
4    -    nc
6    -    nc
7    -    nc
8    -    SCK (to display pin 8)
9    -    nc
10   -    MOSI (to display pin 7)
11   -    3V3 output (to display LITE (pin 10)
12   -    GND (to display pin 1)
13   -    5V output (to display power (pin 2)

I believe by using static const int the pins are locked against any further occurrences of these labels downstream in the code.   What isn’t clear is how the SPI protocol knows that the hardware pin numbers for MISO and SCK are not the usual hardware pins as per other Arduino devices.

Similar or related subjects : –

Verified by ExactMetrics