SSD1306 128x64 Pixel uOLED display module (HCMODU0050&2)

LCD, TFT, OLED, LED modules
admin
Site Admin
Posts: 865
Joined: Sun Aug 05, 2012 4:02 pm

SSD1306 128x64 Pixel uOLED display module (HCMODU0050&2)

Post by admin » Sat Jan 11, 2014 11:53 am

Image


Image

These tiny 0.96 inch uOLED displays have a resolution of 128 x 64 pixels and use a standard (SPI) serial interface for communication. Based on the SSD1306 controller, the module is available in both white and blue pixel colours. Pre-written libraries for Arduino are freely available including our own HCuOLED library for Arduino compatible development boards.



Image

Module size: 27.3*27.8mm
High pixel density
Resolution: 128X64
Super wide viewing angle: more than 160°
Ultra-low power consumption: normal display 0.06W (far below the TFT display)
Wide supply range: DC 3V-5V (without any changes, directly compatible with common 3.3V and 5V power supply system)
Industrial grade: Operating temperature range -30 C ~ 70 C
Ultra-small size: (length) 27.8MM * (W) 27.3MM * (thickness) 4.3MM
Chip select CS signal allows for multiple SPI devices on the same bus.
Compatible tolerant interface.
OLED screen, internal drive chip: SSD1306

Pixel Colour: White (HCMODU0050), Blue (HCMODU0052)


Image

1....GND: Power ground
2....VCC: 3.3V or 5V power supply
3....D0 / SCK: CLK Clock
4....D1 / SDA: MOSI data
5....RST: Reset
6....DC: data / command
7....CS: Chip select signal



Dimensions:
Image



Image

Image


Connecting multiple displays:

Image

Note that when using the HCuOLED library, if you don't require the option of resetting multiple displays individually you can connect the reset pins on each module together and drive them from one digital pin on your Arduino. Therefore you will only require an additional 2 digital pins per display.



Image
  1. #include "HCDisplay.h"
  2.  
  3. // Default pins
  4. #define CS_PIN      4
  5. #define DC_PIN      3
  6. #define RST_PIN     2
  7.  
  8. HCDisplay HCDisplay;    //Creates an instance of the HCDisplay library
  9.  
  10. unsigned int MaxX, MaxY;
  11. boolean FGColour = 1;
  12.  
  13.  
  14.  
  15. void setup()
  16. {
  17.   // Initialise the display
  18.   HCDisplay.Init(CS_PIN, DC_PIN, RST_PIN);   //Initialise the display
  19.  
  20.   /* Get the screens X & Y resolution */
  21.   MaxX = HCDisplay.ResX() - 1;
  22.   MaxY = HCDisplay.ResY() - 1;
  23.  
  24.   /* Draw a boarder */
  25.   HCDisplay.Rect(0 , 0, MaxX, MaxY, OUTLINE, 1);
  26.   HCDisplay.Rect(0 + 3 , 0 + 3, MaxX - 3, MaxY - 3, OUTLINE, 1);
  27.  
  28.   /* Print some text */
  29.   HCDisplay.Pos(44,8);
  30.   HCDisplay.Print("Hobby");
  31.   HCDisplay.Pos(24,18);
  32.   HCDisplay.Print("Components");
  33.  
  34.   HCDisplay.Pos(16,30);
  35.   HCDisplay.Print("0.9\" I2C OLED");
  36.  
  37.   /* Change the font */
  38.   HCDisplay.SetFont(MedProp_12ptFont);
  39. }
  40.  
  41.  
  42. void loop()
  43. {
  44.   /* Make some text flash by swapping the texts foreground and background colours */
  45.   HCDisplay.SetFG(FGColour);
  46.   HCDisplay.SetBG(!FGColour);
  47.   HCDisplay.Pos(10,42);
  48.   HCDisplay.Print("HCMODU0150");
  49.  
  50.   FGColour = !FGColour;
  51.  
  52.   delay(200);
  53. }



Image

HCDisplay Arduino library for above sketch is available for download from the software section of our support forum here:

viewtopic.php?f=58&t=2827




FAQ:

Does this module support I2C?

By default this module uses an SPI interface. The module can be modified to support I2C but this requires removal and linking surface mount components and pads. Which pads will require linking or unlinking will depend greatly on the version of display shipped but will normally be shown in screenprint on the rear of the display.

Connections to the display via I2C are as follows:

MICRO.......DISPLAY
GND.........GND
3.3V........VDD
SCK.........SCK
SDA.........SDA
DIO.........RES

The DC pin will set the I2C address where DC low = 0x3C & DC high = 0x3D.

The HCuOLED library does not support these displays in I2C mode but they are supported via the U8GLIB library. You will need to uncomment the following constructor:

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does not send AC

Also note that at time of writing, the U8GLIB library does not support automatic resetting of the display so you will need to connect the modules RES (reset) pin to a spare DIO pin on your Arduino and manually reset the display by pulsing the pin low before the U8GLIB is initialised. Alternatively you can connect the RES pin to the reset pin of your Arduino so that the display is reset when your Arduino is reset.

**PLEASE NOTE** These modules are sold as SPI displays and as they require a hardware modification to work in I2C we do not support them in this configuration. We cannot replace displays that have been damaged due to improper modification. The information above is only given for customers that are comfortable making this modification. We provide no guarantees or warranty as to its accuracy.



How do I connect this display to my Arduino Mega?

The HCuOLED library makes use of the Arduinos hardware SPI interface. This is actually in a different place on a Mega and so you will need to connect the display to the following pins:


MODULE..............MEGA
GND....................GND
VCC.....................3.3V
D0 (CLK)..............D52
D1 (DATA)............D51
RST (RESET).........D8
DC......................D9
CS (SS)...............D10

If you are using one of the example sketches remember to change the appropriate pin definitions at the top of the sketch.


I want to use the display with an Ethernet shield but the display doesn't work properly. How can I make it work?

This is because both the Ethernet shield and HCuOLED library both use the Arduinos hardware SPI interface causing a pin conflict. This can simply be resolved by moving the default pin for the displays CS (chip select) from D10 to a free pin such as D7. If you are using one of the example sketches remember to change the appropriate pin definition at the top of the sketch.



Datasheet:
SSD1306.pdf



Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

pocketmoon
Posts: 7
Joined: Thu Dec 26, 2013 11:32 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by pocketmoon » Fri Jan 17, 2014 8:15 pm

Hi,

In the diagram both s1 and s2 look like they are pulled to ground which would make the default SPI ? Is that correct ? The module I have is the same.

[EDIT}

Yep, it's SPI by default, which is good for me.

Rob

david.prentice
Posts: 3
Joined: Sun Jan 19, 2014 12:06 am

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by david.prentice » Mon Jan 20, 2014 8:49 am

I bought one of these displays because it was advertised as being I2C.

When it arrived on Saturday, I noted that it was configured for 4-wire SPI.
The Adafruit Arduino SPI sketch works fine on this module.

I then changed the BPn links to select I2C. According to the data sheet, you have to link D2, D1 pin for SDA. D0 for SCL. I tried to isolate the D2 pin by cutting the pcb trace but it seems to be hard-wired to GND with the other D2-D7 pins.

I also tried using the module without using ACK from the device without success.

Is it possible to use this module in I2C mode?

David.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by andrew » Mon Jan 20, 2014 2:36 pm

I'm going to set one up now to see if I can figure out what the problem is. Please bear with me.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by andrew » Mon Jan 20, 2014 5:27 pm

Just to update, I've not manged to get it working yet, unfortunately I'm not very familiar with the Adafruit library. A few comments though, there should be no good reason why it wouldn't work in I2C mode. The D2 pin acts as the Dout pin in I2C mode and although it does say to connect it to D1, further down in the datasheet it does say that D2 can be left disconnected if not requiring an acknowledge. Also the Adafruit library seems to expect an I2C address of 0x3D so the DC pin (SA0) should be pulled high.

I will continue to see if I can get the Adafruit library working.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by andrew » Tue Jan 21, 2014 3:51 pm

A little more experimenting has led me to the following conclusions: As you mentioned, D2 which is the Dout pin in I2C mode, is grounded by a via on the ribbon cable. Cutting the track before this point and connecting it to D1 (Din) allows the module to respond to I2C writes with an ACK. This allows sketches based on the wire library to work such as the Microduino OLED example and library available elsewhere in this forum (uses same controller) to work on this module.

So when modified to work in the I2C mode this module does not send acknowledges by default and therefore sketches using the standard arduino wire library (which uses the hardware two wire interface) will not work with this module as they test for an acknowledge. So the library would either need modifying or you would have to use an alternative software I2C interface. I will speak to the factory to see if they can confirm this and get their opinion. In the interim I'm going to add a comment to the description.

For reference here are the connections I used:

OLED Module Uno
GND...............GND
VCC...............+5V
D0 (SCK)..........A5
D1 (SDA/Din).....A4
RESET.............D4 (Depending on library used)
DC (SA0).........GND
CS................GND
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

pocketmoon
Posts: 7
Joined: Thu Dec 26, 2013 11:32 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by pocketmoon » Fri Jan 24, 2014 1:21 pm

Quick Q, is there a pull up resistor on the CS ? Can't quite tell from the pic.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by andrew » Fri Jan 24, 2014 2:40 pm

We don't currently have a schematic for this module but from my own measurements I believe there is a resistor in series with the CS line and a 10K resistor to ground.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

pocketmoon
Posts: 7
Joined: Thu Dec 26, 2013 11:32 pm

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by pocketmoon » Fri Jan 24, 2014 4:26 pm

Cheers Andrew, that saved me a bit of time this evening :)

ChrisJ
Posts: 7
Joined: Mon Dec 30, 2013 11:34 am

Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)

Post by ChrisJ » Sun Feb 23, 2014 10:57 pm

Hi All

I've been playing around with this display as I wanted to use it to show the data from Analogue pins using a wireless link from another board. The problem was, how do you get it to print variables?

Looking on this site http://code.google.com/p/u8glib/wiki/us ... ence#print I found there was a 'print' command, but there's a 'gotchya', you have to use 'u8g.setPrintPos(x,y);' first, then 'u8g.print(x);' works (x is my variable).

It's like using a Print At statement, but you have to define them on two lines of code.

I've adapted Andrews code to include this feature, hope you don't mind Andrew. I've altered the font size to the smallest value for this font to get all the chatacters on one line, If A0 and A1 are not connected to anything you'l get random numbers from the 'floating' high impedance input, if you tie one down to 0V you'll get 0, if you connect to 5V you'll get 1024 or close to it.

/* FILE: ARD_SSD1306_Graphic_OLED_Module_Example
DATE: 09/01/14
VERSION: 0.1

REVISIONS:

09/01/14 Created version 0.1

This is an example of how to use the Hobby Components SSD1306 based 128x64 OLED
module (HCMODU0050 & HCMODU0052).

This example sketch uses the U8glib library to output text and graphics to the
screen in SPI mode.

PINOUT:

MODULE` UNO
GND GND
VCC +3.3V
D0 (SCK) D13
D1 (MOSI) D11
RST N/A
DC (A0) D9
CS (CS) D10

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of promoting or selling products
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.

U8glib library copywrite notice:

Universal 8bit Graphics Library, http://code.google.com/p/u8glib/

Copyright (c) 2012, olikraus@gmail.com
All rights reserved.
*/



/* Include the U8glib library */
#include "U8glib.h"

/* Define the SPI Chip Select pin */
#define CS_PIN 10

/* Create an instance of the library for the SSD1306 OLD display in SPI mode */
U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);

int x=0;
int y=0;

void setup()
{
}

/* Main program */
void loop()
{
/* Start of a picture loop */
u8g.firstPage();

x = analogRead(A0);
y = analogRead(A1);

/* Keep looping until finished drawing screen */
do
{
/* Set the font */
u8g.setFont(u8g_font_courB10);// smallest value for this font, B12 and B14 are allowed too.

/* Display some text */
u8g.drawStr( 1, 26, "A0 Value =");
u8g.setPrintPos(94,26);
u8g.print(x);
u8g.drawStr( 1, 50, "A1 Value =");
u8g.setPrintPos(94,50);
u8g.print(y);

/* Draw a simple border */
//u8g.drawFrame(5,5,117,54);
//u8g.drawFrame(0,0,128,64); //borders of the screen
//u8g.drawLine(0,0,128,64);

}while(u8g.nextPage());
}

I apologise for the 'rough' code with a lot of // and such, it's just a proof of concept at this stage. Now to get two 2.4GHz tranceivers connected.

Chris
Last edited by ChrisJ on Mon Feb 24, 2014 12:24 pm, edited 1 time in total.

Post Reply

Return to “Display”