Arduino MKR WiFi 1010 - OLED 128x64 Display

Introduction

Ready to add a crystal-clear display to your Arduino MKR WiFi 1010 projects? OLED displays offer stunning contrast, wide viewing angles, and vibrant visuals that bring your projects to life! In this comprehensive tutorial, you'll learn everything you need to use an OLED 128x64 display with your Arduino MKR WiFi 1010.

Unlike traditional LCD displays, OLED (Organic Light-Emitting Diode) screens produce their own light, resulting in perfect blacks, excellent contrast, and no backlight requirements. The SSD1306 OLED display is the most popular choice for Arduino MKR WiFi 1010 projects, and you'll master it in this guide!

What You'll Learn:

Real-World Applications:

Arduino MKR WiFi 1010 OLED 128x64 display

By the end of this tutorial, you'll be able to create stunning visual displays for your Arduino MKR WiFi 1010 projects using OLED 128x64 screens!

Hardware Preparation

1×Arduino MKR WiFi 1010
1×Micro USB Cable
1×SSD1306 I2C OLED Display 128x64
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

About OLED Displays

OLED (Organic Light-Emitting Diode) displays are a modern alternative to traditional LCD screens. Each pixel in an OLED generates its own light, which means:

  • Perfect blacks - Pixels can turn completely off
  • High contrast - Stunning visual clarity
  • Wide viewing angles - Readable from almost any position
  • No backlight needed - Lower power consumption
  • Thin profile - Compact and lightweight

Common OLED Types for Arduino MKR WiFi 1010

There are many OLED displays available, but the most popular for Arduino MKR WiFi 1010 projects are:

  • SSD1306 I2C OLED 128x64 - The most common size, perfect for text and simple graphics
  • SSD1306 I2C OLED 128x32 - Smaller version for space-constrained projects

Both use the I2C interface, which requires only two wires for communication, making them easy to connect to your Arduino MKR WiFi 1010!

OLED display

I2C OLED Display Pinout

Most SSD1306 OLED displays have four pins for easy connection:

  • GND pin: Connect to ground (0V) on your Arduino MKR WiFi 1010
  • VCC pin: Power supply - connect to 3.3V or 5V (most OLED modules work with both)
  • SCL pin: Serial Clock Line for I2C communication
  • SDA pin: Serial Data Line for I2C communication
OLED pinout

※ NOTE THAT:

  • The connections on the OLED module might be different depending on who made it and its type. Please use the labels shown on your OLED module. Look carefully!
  • This guide uses an OLED screen that works with the SSD1306 I2C driver. We tested it with the OLED display from DIYables and it works great.

Wiring Diagram

Connecting your OLED display to the Arduino MKR WiFi 1010 is straightforward thanks to the I2C interface. Here's the complete wiring setup:

The wiring diagram between Arduino MKR WiFi 1010 OLED

This image is created using Fritzing. Click to enlarge image

Connection Table

Follow this table to wire your OLED display to the Arduino MKR WiFi 1010:

OLED Module Arduino MKR WiFi 1010
Vin 3.3V
GND GND
SDA A4
SCL A5

How To Use OLED with Arduino MKR WiFi 1010

Install SSD1306 OLED Library

Before you can program your OLED display, you need to install the necessary libraries in the Arduino IDE. Follow these simple steps:

  1. Open Library Manager - Click on the Libraries icon on the left sidebar of the Arduino IDE (it looks like a stack of books).
  2. Search for SSD1306 - Type SSD1306 in the search box and look for the Adafruit SSD1306 library.
  3. Install the library - Click the Install button next to the Adafruit SSD1306 library.
Arduino MKR WiFi 1010 OLED library
  1. Install dependencies - A popup will appear asking to install additional required libraries. Click Install All to add the Adafruit GFX library and other dependencies.
Arduino MKR WiFi 1010 Adafruit GFX sensor library

What These Libraries Do:

  • Adafruit_SSD1306: Controls the OLED display hardware
  • Adafruit_GFX: Provides graphics functions for drawing shapes, text, and images

Programming Your OLED Display

Now let's walk through the essential code structure for controlling your OLED with Arduino MKR WiFi 1010.

Step 1: Include Required Libraries

Start every OLED sketch by including the necessary libraries:

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

Step 2: Define Display Dimensions

Specify your OLED's resolution. For a 128x64 display:

#define OLED_WIDTH 128 // Defines the OLED display's width in pixels #define OLED_HEIGHT 64 // Defines the OLED display's height in pixels

Step 3: Create an OLED Display Object

Initialize the display object with the dimensions and communication settings:

// Initialize an SSD1306 display instance for I2C communication Adafruit_SSD1306 oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1);

Step 4: Initialize the Display in setup()

In your setup() function, initialize the OLED display with its I2C address (typically 0x3C):

// Begin initializing the OLED display at I2C address 0x3C for a 128x64 resolution if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); }

What This Does:

  • SSD1306_SWITCHCAPVCC: Sets the internal voltage mode
  • 0x3C: The I2C address of most OLED displays (some use 0x3D)
  • If initialization fails, the code stops and prints an error message

Step 5: Display Content

After initialization, you can display text, draw graphics, and show images using the library's functions!

Arduino MKR WiFi 1010 Code - Display Text on OLED

Here's a complete example that displays text on your OLED screen:

/* * This Arduino MKR WiFi 1010 code was developed by newbiely.com * * This Arduino MKR WiFi 1010 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-mkr/arduino-mkr-wifi-1010-oled-128x64-display */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // declare an SSD1306 display object connected to I2C Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Serial.begin(9600); // initialize OLED display with address 0x3C for 128x64 if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); } delay(2000); // wait for initializing oled.clearDisplay(); // clear display oled.setTextSize(1); // text size oled.setTextColor(WHITE); // text color oled.setCursor(0, 10); // position to display oled.println("Hello World!"); // text to display oled.display(); // show on OLED } void loop() { }

Essential OLED Text Functions

The Adafruit libraries provide powerful functions for displaying text on your OLED:

  • Oled.clearDisplay() – Turns off every pixel on the screen.
  • Oled.drawPixel(x, y, color) – Draws a pixel at the specified x and y position.
  • Oled.setTextSize(n) – Sets how big the text will be; you can choose a size between 1 and 8.
  • Oled.setCursor(x, y) – Moves the starting point for writing text to the x and y coordinates.
  • Oled.setTextColor(WHITE) – Sets the text color to white.
  • Oled.setTextColor(BLACK, WHITE) – Sets the text color to black and the background color to white.
  • Oled.println("message") – Writes a text message on the screen.
  • Oled.println(number) – Writes a number on the screen.
  • Oled.println(number, HEX) – Writes a number in hexadecimal (base 16) format.
  • Oled.display() – Updates the screen so that your changes appear.
  • Oled.startscrollright(start, stop) – Scrolls the text from left to right between the chosen start and stop points.
  • Oled.startscrollleft(start, stop) – Scrolls the text from right to left between the chosen start and stop points.
  • Oled.startscrolldiagright(start, stop) – Scrolls the text from the bottom left to the top right.
  • Oled.startscrolldiagleft(start, stop) – Scrolls the text from the bottom right to the top left.
  • Oled.stopscroll() – Stops the scrolling text.

Centering Text on Your OLED Display

Want perfectly centered text on your OLED 128x64 display? Calculating the position manually can be tricky, but we've got you covered!

For a detailed guide with code examples on how to center align text both vertically and horizontally on your OLED display, check out this comprehensive tutorial: How to vertical/horizontal center on OLED.

Quick Tip: To center text, you'll need to:

  1. Calculate the pixel width of your text using getTextBounds()
  2. Subtract half the text width from half the screen width
  3. Do the same for vertical centering with text height

Arduino MKR WiFi 1010 Code - Drawing Shapes on OLED

Beyond text, you can create lines, circles, rectangles, and other shapes on your OLED display:

/* * This Arduino MKR WiFi 1010 code was developed by newbiely.com * * This Arduino MKR WiFi 1010 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-mkr/arduino-mkr-wifi-1010-oled-128x64-display */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // declare an SSD1306 display object connected to I2C Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Serial.begin(9600); // initialize OLED display with address 0x3C for 128x64 if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); } delay(2000); // wait for initializing oled.setCursor(0, 0); } void loop() { // draw rectangle oled.clearDisplay(); oled.drawRect(0, 15, 60, 40, WHITE); oled.display(); delay(2000); // fill rectangle oled.clearDisplay(); oled.fillRect(0, 15, 60, 40, WHITE); oled.display(); delay(2000); // draw the round rectangle oled.clearDisplay(); oled.drawRoundRect(0, 15, 60, 40, 8, WHITE); oled.display(); delay(2000); // fill the round rectangle oled.clearDisplay(); oled.fillRoundRect(0, 15, 60, 40, 8, WHITE); oled.display(); delay(2000); // draw circle oled.clearDisplay(); oled.drawCircle(20, 35, 20, WHITE); oled.display(); delay(2000); // fill circle oled.clearDisplay(); oled.fillCircle(20, 35, 20, WHITE); oled.display(); delay(2000); // draw triangle oled.clearDisplay(); oled.drawTriangle(30, 15, 0, 60, 60, 60, WHITE); oled.display(); delay(2000); // fill triangle oled.clearDisplay(); oled.fillTriangle(30, 15, 0, 60, 60, 60, WHITE); oled.display(); delay(2000); }

Common Drawing Functions:

  • drawLine(x1, y1, x2, y2, color) - Draw a straight line
  • drawRect(x, y, width, height, color) - Draw rectangle outline
  • fillRect(x, y, width, height, color) - Draw filled rectangle
  • drawCircle(x, y, radius, color) - Draw circle outline
  • fillCircle(x, y, radius, color) - Draw filled circle
  • drawTriangle(x1, y1, x2, y2, x3, y3, color) - Draw triangle outline

Experiment with these functions to create custom interfaces and visualizations!

Arduino MKR WiFi 1010 Code - Display Images on OLED

Want to display custom images, logos, or icons on your OLED? You'll need to convert your images into a special bitmap array format that the Arduino MKR WiFi 1010 can understand.

Converting Images to Bitmap Arrays

  1. Choose your image - Any format works (JPG, PNG, GIF, etc.)
  2. Use the online converter - Visit image2cpp
  3. Configure settings:
  • Set canvas size to 128x64 (or your display size)
  • Choose "Arduino code" as output format
  • Select "Vertical - 1 bit per pixel" for drawing mode
  1. Generate the array - Copy the generated code

Here's an example showing the conversion process with an Arduino MKR WiFi 1010 icon:

image to bitmap array

Using the Bitmap in Your Code

After converting your image, copy the generated array and replace the ArduinoIcon array in this code:

/* * This Arduino MKR WiFi 1010 code was developed by newbiely.com * * This Arduino MKR WiFi 1010 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-mkr/arduino-mkr-wifi-1010-oled-128x64-display */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // declare an SSD1306 display object connected to I2C Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // bitmap of arduino-icon image const unsigned char ArduinoIcon [] PROGMEM = { // 'arduino-icon', 128x64px 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xe0, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xf0, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x00, 0x0f, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x3f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x07, 0x80, 0x00, 0x7f, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x03, 0x80, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xf0, 0x7f, 0xff, 0x00, 0x0f, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x0f, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x03, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x01, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xe0, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x07, 0x80, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xe0, 0x00, 0x7f, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xf8, 0x00, 0x3f, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x00, 0x1f, 0xe0, 0x00, 0x1f, 0xff, 0xff, 0xf0, 0x00, 0x3f, 0xf8, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x3f, 0xe0, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xfc, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; void setup() { Serial.begin(9600); // initialize OLED display with address 0x3C for 128x64 if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); } delay(2000); // wait for initializing oled.setCursor(0, 0); } void loop() { oled.clearDisplay(); // display bitmap oled.drawBitmap(0, 0, ArduinoIcon, 128, 64, WHITE); oled.display(); delay(2000); // invert display oled.invertDisplay(1); delay(2000); }

Tips for Best Results:

  • Use high-contrast images with clear outlines
  • Simple black and white images work best
  • Resize your images to 128x64 before converting
  • Smaller images load faster and use less memory on your Arduino MKR WiFi 1010

OLED Troubleshooting Guide

If your OLED display isn't working properly, follow these troubleshooting steps:

Display Not Turning On

Check Your Wiring:

  • Verify VCC connects to 3.3V (not 5V if your module is 3.3V only)
  • Confirm GND connects to GND
  • Make sure SDA goes to A4 and SCL goes to A5 on Arduino MKR WiFi 1010
  • Check for loose connections or broken wires

Verify the Driver Chip:

  • Most OLED displays use the SSD1306 driver chip
  • Look at your module's specifications or markings
  • Some modules use SH1106 or other drivers (these need different libraries)

Finding Your OLED's I2C Address

Most OLED displays use address 0x3C, but some use 0x3D. If your display isn't working, scan for the correct address:

I2C Scanner Code:

// I2C address scanner program #include <Wire.h> void setup() { Wire.begin(); Serial.begin(9600); Serial.println("I2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for (address = 1; address < 127; address++ ) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address < 16) Serial.print("0"); Serial.print(address, HEX); Serial.println(" !"); nDevices++; } else if (error == 4) { Serial.print("Unknown error at address 0x"); if (address < 16) Serial.print("0"); Serial.println(address, HEX); } } if (nDevices == 0) Serial.println("No I2C devices found"); else Serial.println("done"); delay(5000); // wait 5 seconds for next scan }

Upload this code and check the Serial Monitor. You should see:

COM6
Send
Scanning... I2C device found at address 0x3C ! done Scanning... I2C device found at address 0x3C ! done
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

If your address is different (like 0x3D), update your code:

// Change from 0x3C to your address if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {

Common Issues and Solutions

"SSD1306 allocation failed" Error:

  • Wrong I2C address - run the scanner code above
  • Incorrect wiring - double-check all connections
  • Faulty display - try a different OLED module

Display Shows Random Pixels:

  • Add oled.clearDisplay() at the start of your loop
  • Make sure you call oled.display() to update the screen

Text is Too Small/Large:

  • Use oled.setTextSize(2) or higher for bigger text
  • Text size 1 is the smallest, size 8 is the largest

Display is Upside Down:

  • Physically rotate the display, or
  • Add oled.setRotation(2) after initialization

Quick Steps for OLED Projects

New to Arduino MKR WiFi 1010? Complete our Getting Started with Arduino MKR WiFi 1010 tutorial first to set up your development environment.

  1. Wire the OLED - Connect your OLED display to the Arduino MKR WiFi 1010 following the wiring diagram (VCC to 3.3V, GND to GND, SDA to A4, SCL to A5)
  2. Install libraries - Open Library Manager in Arduino IDE and install Adafruit SSD1306 and Adafruit GFX libraries
  3. Connect your board - Plug your Arduino MKR WiFi 1010 into your computer via USB
  4. Select board and port - Choose Arduino MKR WiFi 1010 and the correct COM port in Arduino IDE
  5. Upload example code - Copy one of the code examples above, paste into Arduino IDE, and click Upload
  6. Test the display - Your OLED should light up and show the programmed content!

Challenge Yourself - Creative OLED Projects

Once you've mastered the basics, try these exciting enhancements:

Sensor Data Display

Combine your OLED with sensors to create real-time monitoring displays:

// Display temperature from DHT sensor oled.clearDisplay(); oled.setTextSize(2); oled.setCursor(0, 0); oled.print("Temp: "); oled.print(temperature); oled.print(" C"); oled.display();

Animated Graphics

Create simple animations by updating the display in a loop:

// Bouncing ball animation int x = 0; int direction = 1; void loop() { oled.clearDisplay(); oled.fillCircle(x, 32, 5, WHITE); oled.display(); x += direction; if (x >= 128 || x <= 0) direction *= -1; delay(10); }

Custom Menu System

Build an interactive menu using buttons and your OLED display - perfect for standalone projects!

Advanced Ideas to Explore

  1. Scrolling text ticker - Display long messages that scroll across the screen
  2. Graph sensor data - Plot real-time values as line graphs
  3. Display WiFi status - Show connection status and IP address
  4. Game graphics - Create simple games like Snake or Pong
  5. QR codes - Generate and display QR codes for WiFi credentials
  6. Weather station - Show temperature, humidity, and forecast icons

Check out our other Arduino MKR WiFi 1010 sensor tutorials to combine with your new OLED display skills!

Video

Language References

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!