Adventures with Arduino: creating an IOT device with a joystick and screen for less than £10

Using the OLED screen

From searching similar product description pages to the device I ordered, it seems that the device I’ve got has a 0.96″ black and white OLED screen which is controlled using an I2C bus on pins D1 and D2 for SDA (the data line) and SCL (the clock line) respectively.

Multiple devices can share the same I2C bus, each with their own address, so we first need to scan each possible address to see if there’s anything connected to it.

Here’s the code I used to discover the address of the OLED screen:


void scanI2C(byte start, byte stop) {
  byte error;
  Serial.println("Starting scan");
  for(byte address = start; address < stop; address++) {
    error = Wire.endTransmission();
    if(error == 0) {
      Serial.print("Device found at 0x");
      if(address < 16)
      Serial.println(address, HEX);
  Serial.println("Scan complete");

void setup() {
  // init I2C bus on pins D1 and D2
  Wire.begin(D1, D2);
  // init serial port
  Serial.println("Scanning I2C bus to find display...");
  // scan all 127 addresses
  scanI2C(0, 127);
  // set the builtin LED pin to work as an output

void loop() {
 digitalWrite(LED_BUILTIN, HIGH);
 digitalWrite(LED_BUILTIN, LOW);

When I run this, I get the following output in the Serial Monitor (Ctrl + Shift + M):

Scanning I2C bus to find display...
Starting scan
Device found at 0x3C
Scan complete

Getting to this point took me a long time – the key thing that got it to work for me was updating the ESP8266 board manager plugin to 2.4.0-rc2 rather than 2.4.0 which allowed the I2C bus to run on pins other than the default ones for the Wire library (in this case pins D1 and D2)

To get your device to speak to the OLED screen you need to download two libraries using Sketch > Include Libraries > Manage Libraries and install the two libraries selected below:

Search for "Brzo" and install this library
Search for “Brzo” and install this library
Search for "OLED" and install this library
Search for “OLED” and install this library







Now it starts to get exciting: the code below will display the text “The screen is working”, starting at the top of the screen but falling down by 1 pixel each time the LED flashes.

#include <OLEDDisplay.h>
#include <SSD1306.h>

// connect to display using pins D1, D2 for I2C on address 0x3c
SSD1306  display(0x3c, D1, D2);

int y;

void setup() {
  // init serial port
  // set the builtin LED pin to work as an output

  // init the display
  // set text y coordinate to start at 0
  y = 0;

void loop() {
  // turn off the LED
  digitalWrite(LED_BUILTIN, HIGH);

  // clear the screen
  // display text on the screen
  display.drawString(0, y%64, "The screen is working!");
  // move text down 1 pixel next time

  // update the display

  // turn on the LED
  digitalWrite(LED_BUILTIN, LOW);

This Post Has 4 Comments

  1. Patrik

    thank you very much for your help 🙂 I couldnt make it work without that

  2. SarahC


    The directional buttons: FLATH, RSET, D5, D6, D7
    What on earth is FLATH?

    Also – won’t RSET reset the board when the “direction” is pressed on the little joystick?

    1. pddring

      Yes, because of the way the joystick is connected up, the board will reset when you press left. I don’t know what FLATH is: it’s on all the description pages when you try to buy it but the joystick is actually connected to D3,D5,D6,D7 (and RSET). Maybe there’s a way to disable the reset-not sure-sorry!

  3. Rafa Dominguez

    I’m pretty sure FLATH is nothing but a typo from the first and original description (that has been copied wrongly every time)
    This is the FLASH button. In order to FLASH another binary (firmware) this button has to be pressed while turning power ON.

Leave a Reply