← Back to Home

Output Devices

This week focused on Output Devices. The goal was to program a board to write or display information. I used an OLED SSD1306 display connected to my XIAO RP2350 to create a visual interface.

Group Assignment

Measure the power consumption of an output device.

View Group Project ↗

Visual Output SystemSSD1306 & I2C

For this task, I integrated a 0.96" OLED display. This device is ideal for projects requiring a compact user interface because it is self-illuminating (doesn't need a backlight) and has very low power consumption.

1

The Controller: XIAO RP2350

XIAO RP2350

The XIAO RP2350 handles the display buffer using its high RAM capacity. This is crucial because, to update the OLED, the microcontroller first "draws" the entire screen in its memory and then sends all the data at once through the I2C bus.

2

OLED SSD1306 Hardware

OLED SSD1306

The SSD1306 is a 128x64 pixel monochrome display. It uses I2C communication, requiring only 4 pins: VCC (3.3V), GND, SDA (Data), and SCL (Clock). The pixel density allows for clear text and even small bitmap graphics.

3

Programming with Adafruit Libraries

To control the display, I used the Adafruit_SSD1306 and Adafruit_GFX libraries. The GFX library is powerful as it provides functions to draw lines, circles, and custom text sizes easily.


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  display.println("Fab Academy 2026");
  display.setCursor(0, 30);
  display.println("Output: OLED");
  display.display(); // Envía el buffer a la pantalla
}

void loop() {}
                
4

I2C Protocol Explanation

I2C (Inter-Integrated Circuit) works using a Master-Slave relationship. The RP2350 (Master) sends a unique address (0x3C for this OLED) to start communication. The SDA line carries the actual pixel data, while the SCL line provides the pulse that tells the display when to read each bit.

5

Final Result

Final Result

The final result shows a clear interface. I tested different font sizes and noticed that using display.display() is the most critical part of the code; without it, the commands remain in the RAM of the XIAO and nothing appears on the screen.

Files of Week 10

OLED Test Code

Download .ino