Skip to content

OLED Wireling Tutorial

The OLED screen wirelings come in three different sizes, but can all be programmed using the TinierScreen Library.

0.42" OLED Technical Details

HP7240 Specs

  • 72x40 pixel resolution 
  • 0.42" size 
  • White Monochrome
  • Internal boost converter 
  • I²C Interface 

TinyDuino Power Requirements

  • Voltage: 3.0V - 5.5V 

Pins Used

  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line

Dimensions

  • 26mm x 9mm (1.03 inches x 0.355 inches)
  • Max Height (from lower bottom of Wireling to upper top Wireling Connector): 5.00mm (0.197 inches)
  • Weight: 1 gram (.04 ounces)
0.69" OLED Technical Details ER-OLED0.69-1W Specs
  • 96x16 pixel resolution 
  • 0.69" size 
  • White Monochrome
  • Internal boost converter 
  • I²C Interface 
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V  ???
  • Current: x.xxmA 
Pins Used
  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line
Dimensions
  • 26mm x 9mm (1.03 inches x 0.355 inches)
  • Max Height: 5.00mm (0.197 inches)
  • Weight: 1 gram (.04 ounces)
0.96" OLEDTechnical Details

ER- OLED0.96-1W Specs

  • 128x64 pixel resolution 
  • 0.96" size (measured diagonally)
  • White Monochrome
  • Internal boost converter 
  • I²C Interface 

TinyDuino Power Requirements

  • Voltage: 3.0V - 5.5V 

Pins Used

  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line

Dimensions

  • 27mm x 21mm (1.06 inches x 0.827 inches)
  • Max Height (from lower bottom of Wireling to upper top Wireling Connector): 5.00mm (0.197 inches)
  • Weight: 1 gram (.04 ounces)

Materials

Processor
Adapter
Programming Cable
+
-
-
Arduino USB A to B Cable
Raspberry Pi

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).


Hardware Assembly

Assembly of Wireling with WirelingZero & connecting cables

The code provided is setup for the following port assignments:

Wireling Port Assignments
Port 0
Port 1
Port 2

The code can be run as-is with any of the 3 screens plugged into their assigned ports.


Software Setup

For this Wireling, you need the example Arduino sketch included below. Open up the program in the Arduino IDE, and upload it to your board.

Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.

You will need to download and install the TinierScreen Library for this example.


Upload Program

Upload the program to your development board of choice!

Code
/************************************************************************
   OLED Wireling Screen Example Program
   This program uses four of the Wirelings included with the Starter Kit:
   Port 0: 0.42" OLED Screen Wireling
   Port 1: 0.69" OLED Screen Wireling
   Port 2: 0.96" OLED Screen Wireling
   Port 3: None

   This program prints the configured screen type to each screen. This
   text then floats around the screen bouncing off the sides of the screen.

   Hardware by: TinyCircuits
   Written by: Hunter Hykes for TinyCircuits

   Initiated: 01/06/2020
   Updated: --/--/20--
 ************************************************************************/

#include <Wire.h>           // For I2C communication with sensor
#include <Wireling.h>       // For Wireling interfacing
#include <TinierScreen.h>   // For interfacing with the 0.42" OLED
#include <GraphicsBuffer.h> // For building a screen buffer for the 0.42" OLED

// Make compatible with all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

/* * * * * * * * * * 0.42" OLED * * * * * * * * * */
#define OLED_042_PORT 0 // use Port 0 for screen
#define OLED_042_RESET (int) A0 // use Port 0 reset pin
#define OLED_042_WIDTH 72
#define OLED_042_HEIGHT 40
TinierScreen display042 = TinierScreen(TinierScreen042);
GraphicsBuffer screenBuffer042 = GraphicsBuffer(OLED_042_WIDTH, OLED_042_HEIGHT, colorDepth1BPP);

/* * * * * * * * * * 0.69" OLED * * * * * * * * * */
#define OLED_069_PORT 1 // use Port 1 for screen
#define OLED_069_RESET (int) A1 // use Port 1 reset pin
#define OLED_069_WIDTH 96
#define OLED_069_HEIGHT 16
TinierScreen display069 = TinierScreen(TinierScreen069);
GraphicsBuffer screenBuffer069 = GraphicsBuffer(OLED_069_WIDTH, OLED_069_HEIGHT, colorDepth1BPP);

/* * * * * * * * * * 0.96" OLED * * * * * * * * * */
#define OLED_096_PORT 2 // use Port 2 for screen
#define OLED_096_RESET (int) A2 // use Port 2 reset pin
#define OLED_096_WIDTH 128
#define OLED_096_HEIGHT 64
TinierScreen display096 = TinierScreen(TinierScreen096);
GraphicsBuffer screenBuffer096 = GraphicsBuffer(OLED_096_WIDTH, OLED_096_HEIGHT, colorDepth1BPP);

void setup() {
  SerialMonitorInterface.begin(115200);
  Wire.begin();
  Wireling.begin(); // Enable power & select port

  /* * * * * * * * * 0.42" Screen Stuff * * * * * * * */
  Wireling.selectPort(OLED_042_PORT);
  display042.begin(OLED_042_RESET);
  if (screenBuffer042.begin()) {
    //memory allocation error- buffer too big!
  }
  screenBuffer042.setFont(thinPixel7_10ptFontInfo);

  /* * * * * * * * * 0.69" Screen Stuff * * * * * * * */
  Wireling.selectPort(OLED_069_PORT);
  display069.begin(OLED_069_RESET);
  if (screenBuffer069.begin()) {
    //memory allocation error- buffer too big!
  }
  screenBuffer069.setFont(thinPixel7_10ptFontInfo);

  /* * * * * * * * * 0.96" Screen Stuff * * * * * * * */
  Wireling.selectPort(OLED_096_PORT);
  display096.begin(OLED_096_RESET);
  if (screenBuffer096.begin()) {
    //memory allocation error- buffer too big!
  }
  screenBuffer096.setFont(thinPixel7_10ptFontInfo);

}

int pos = 0; // current position
int xMax, yMax, x = 0, y = 0;

void loop() {
  // float around the screen type on each screen
  floatText(OLED_042_PORT, display042, screenBuffer042, "0.42\"");
  floatText(OLED_069_PORT, display069, screenBuffer069, "0.69\"");
  floatText(OLED_096_PORT, display096, screenBuffer096, "0.96\"");

  pos++; // increment the position (floatText is dependent on this)
}

void floatText(int port, TinierScreen screen, GraphicsBuffer &buffer, char *text) {
  // get the buffer size passed to the function to determine screen dimensions
  int bufferSize = buffer.getBufferSize();

  int padding_w = 0;  // how many pixels will go offscreen past the left and right sides
  int padding_h = 0;  // how many pixels will go offscreen past the top and bottom sides

  // each byte in the buffer holds data for 8 pixels (one per byte)
  // because of this, the buffer size is determined by 1/8th the
  // value of the ((display width) * (display_height))
  if (bufferSize == OLED_042_WIDTH * (OLED_042_HEIGHT >> 3)) {        // 0.42" OLED
    xMax = OLED_042_WIDTH + padding_w - buffer.getPrintWidth(text);   // set x bounds
    yMax = OLED_042_HEIGHT + 0 - buffer.getFontHeight();              // set y bounds

  } else if (bufferSize == OLED_069_WIDTH * (OLED_069_HEIGHT >> 3)) { // 0.69" OLED
    xMax = OLED_069_WIDTH + padding_w - buffer.getPrintWidth(text);
    yMax = OLED_069_HEIGHT + 0 - buffer.getFontHeight();

  } else if (bufferSize == OLED_096_WIDTH * (OLED_096_HEIGHT >> 3)) { // 0.96" OLED
    xMax = OLED_096_WIDTH + padding_w - buffer.getPrintWidth(text);
    yMax = OLED_096_HEIGHT + 0 - buffer.getFontHeight();
  }

  x = pos % xMax; if ((pos / xMax) & 1) x = xMax - x;
  y = pos % yMax; if ((pos / yMax) & 1) y = yMax - y;
  x -= padding_w >> 1; // subtract half of the width padding value from the x-coordinate
  y -= padding_h >> 1; // subtract half of the height padding value from the y-coordinate

  Wireling.selectPort(port);  // select the Wireling screen port
  buffer.clear();             // clear the graphics buffer
  buffer.setCursor(x, y);     // set the cursor in the buffer to write text
  buffer.print(text);   // the text to be printed
  Wire.setClock(1000000);
  screen.writeBuffer(buffer.getBuffer(), buffer.getBufferSize()); // write buffer to the screen
  Wire.setClock(50000);
}

After uploading the program you should see the screen size of your display printed. This text then floats around, bouncing off the sides of the screen.


Contact Us

If you have any questions or feedback, feel free to email us at info@tinycircuits.com or make a post on the forum.

Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!

Thanks for making with us!


Downloads

0.42" OLED
0.69" OLED
0.96" OLED
Datasheet
Schematic
EAGLE Files
Arduino Sketch