Reply to topic  [ 35 posts ]  Go to page 1, 2, 3, 4  Next
SSD1306 128x64 Pixel uOLED display module (HCMODU0050&2) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 650
Post SSD1306 128x64 Pixel uOLED display module (HCMODU0050&2)
ImageImage


Image

These tiny 0.96 inch uOLED displasy have a resolution of 128 x 64 pixels and uses a standard (configurable) serial interface for communication. Based on the SSD1306 controller, the module is available in both white and blue pixel colours. By default the module is configured to use an SPI interface for serial interface but can be modified (soldering required) to communicate via I2C protocol. Pre-written libraries for Arduino are freely available.



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 or IIC 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: CLK Clock
4....D1: 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

Code:
/* /* FILE:    HCuOLED_Things_Example
   DATE:    16/04/15
   VERSION: 0.1
   AUTHOR: Andrew Davies
   
REVISIONS:

12/03/15 Created version 0.1


This example uses the line, rectangle and bitmap graphic functions together with
the INVERT DrawMode to create a simple animation.

To use this example connect your uOLED display to the following pins of your
Arduino:


MODULE..........ARDUINO
GND.............GND
VCC.............3.3V
D0 (CLK)........D13
D1 (DATA).......D11
RST (RESET).....D8
DC..............D9
CS (SS).........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 directly for the purpose of promoting 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. */

#include "HCuOLED.h"
#include "SPI.h"

/* Example bitmap */
const PROGMEM byte Tiny_Logo_Resistor[] =
{
  0xC0, 0xE0, 0x30, 0x30, 0xF0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x38, 0x0E, 0x07, 0x1E, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x70, 0x1C, 0x07, 0x0F, 0x3C, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x3C, 0x0F, 0x07, 0x1C, 0x70, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x78, 0x1E, 0x07, 0x0E, 0x38, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xF0, 0x30, 0x30, 0xE0, 0xC0,
  0x00, 0x01, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3C, 0x38, 0x0E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1E, 0x38, 0x1C, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0E, 0x38, 0x38, 0x0E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1C, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0E, 0x38, 0x3C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x01, 0x00,
};


/* Digital pin number for the displays chip select pin */
#define CS_DI 10
/* Digital pin number for the displays data/command pin */
#define DC_DI 9
/* Digital pin number for the displays reset pin */
#define RST_DI 8

/* Array indexes for the X and Y coordinates */
#define X1 0
#define Y1 1
#define X2 2
#define Y2 3

/* Arrays to store coordinates and direction for the line, rectangle and bitmap */
byte Box[4] = {1,1,20,20};
byte BoxDir[4] = {1,1,1,1};
byte Line[4] = {100,25,120,55};
byte LineDir[4] = {-1,-1,-1,-1};
byte Bitmap[2] = {40,40};
byte BitmapDir[2] = {-1,-1};



/* Create an instance of the library (uncomment one of the lines below) */
HCuOLED HCuOLED(SSD1307, SS_DI, DC_DI, RST_DI); // For SSD1307 displays (HCMODU0050 & HCMODU0052)
//HCuOLED HCuOLED(SH1106, CS_DI, DC_DI, RST_DI); // For SH1106 displays (HCMODU0058 & HCMODU0059)


void setup()
{

  /* Reset the display */
  HCuOLED.Reset();
}

void loop()
{
  /* Display some text using a small 8x8 fixed width font */
  HCuOLED.SetFont(Terminal_8pt);
  HCuOLED.Cursor(44,0);
  HCuOLED.Print("HOBBY");
  HCuOLED.Cursor(20,10);
  HCuOLED.Print("COMPONENTS");

  /* Display a number using a large 4 line LCD style font */
  HCuOLED.Cursor(20,24);
  HCuOLED.SetFont(LCDLarge_24pt);
  HCuOLED.Print("HCuOLED");
 
  /* Change the draw mode from NORMAL to INVERT */
  HCuOLED.DrawMode(INVERT);
  while(1)
  {
    /* Move the positions of the 3 objects */
    MoveRect();
    MoveLine();
    MoveBitmap();
   
    /* Draw the objects to the display buffer */
    HCuOLED.Rect(Box[X1],Box[Y1],Box[X2],Box[Y2], SOLID);
    HCuOLED.Line(Line[X1],Line[Y1],Line[X2],Line[Y2]);
   
    HCuOLED.Cursor(Bitmap[X1],Bitmap[Y1]);
    HCuOLED.Bitmap(84, 2, Tiny_Logo_Resistor);
   
    /* Write the display buffer to the screen */
    HCuOLED.Refresh();
   
    /* Draw the objects again. As we are in INVERT mode this will remove them */
    HCuOLED.Rect(Box[X1],Box[Y1],Box[X2],Box[Y2], SOLID);
    HCuOLED.Line(Line[X1],Line[Y1],Line[X2],Line[Y2]);
   
    HCuOLED.Cursor(Bitmap[X1],Bitmap[Y1]);
    HCuOLED.Bitmap(84, 2, Tiny_Logo_Resistor);
  }
}


/* Update the X and Y coordinates for the box */
void MoveRect(void)
{
  if(Box[X1] == 0 || Box[X1] == 127)
    BoxDir[X1] *= -1;
  Box[X1] += BoxDir[X1];
 
  if(Box[Y1] == 0 || Box[Y1] == 63)
    BoxDir[Y1] *= -1;
  Box[Y1] += BoxDir[Y1];
 
  if(Box[X2] == 0 || Box[X2] == 127)
    BoxDir[X2] *= -1;
  Box[X2] += BoxDir[X2];
 
  if(Box[Y2] == 0 || Box[Y2] == 63)
    BoxDir[Y2] *= -1;
  Box[Y2] += BoxDir[Y2];   
}

/* Update the X and Y coordinates for the Line */
void MoveLine(void)
{
  if(Line[X1] == 0 || Line[X1] == 127)
    LineDir[X1] *= -1;
  Line[X1] += LineDir[X1];
 
  if(Line[Y1] == 0 || Line[Y1] == 63)
    LineDir[Y1] *= -1;
  Line[Y1] += LineDir[Y1];
 
  if(Line[X2] == 0 || Line[X2] == 127)
    LineDir[X2] *= -1;
  Line[X2] += LineDir[X2];
 
  if(Line[Y2] == 0 || Line[Y2] == 63)
    LineDir[Y2] *= -1;
  Line[Y2] += LineDir[Y2];   
}

/* Update the X and Y coordinates for the bitmap */
void MoveBitmap(void)
{
  if(Bitmap[X1] == 0 || Bitmap[X1] == 43)
    BitmapDir[X1] *= -1;
  Bitmap[X1] += BitmapDir[X1];
 
  if(Bitmap[Y1] == 0 || Bitmap[Y1] == 47)
    BitmapDir[Y1] *= -1;
  Bitmap[Y1] += BitmapDir[Y1];
}





Image

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

http://forum.hobbycomponents.com/viewtopic.php?f=58&t=1817

Or from github here:
https://github.com/HobbyComponents/HCuOLED



FAQ:

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:
Attachment:
SSD1306.pdf


Old u8glib library:
Attachment:
u8glib_arduino_v1.12.zip


You do not have the required permissions to view the files attached to this post.


Sat Jan 11, 2014 11:53 am
Profile

Joined: Thu Dec 26, 2013 11:32 pm
Posts: 7
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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


Fri Jan 17, 2014 8:15 pm
Profile

Joined: Sun Jan 19, 2014 12:06 am
Posts: 3
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.


Mon Jan 20, 2014 8:49 am
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 645
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.


Mon Jan 20, 2014 2:36 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 645
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.


Mon Jan 20, 2014 5:27 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 645
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.


Tue Jan 21, 2014 3:51 pm
Profile

Joined: Thu Dec 26, 2013 11:32 pm
Posts: 7
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
Quick Q, is there a pull up resistor on the CS ? Can't quite tell from the pic.


Fri Jan 24, 2014 1:21 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 645
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.


Fri Jan 24, 2014 2:40 pm
Profile

Joined: Thu Dec 26, 2013 11:32 pm
Posts: 7
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
Cheers Andrew, that saved me a bit of time this evening :)


Fri Jan 24, 2014 4:26 pm
Profile

Joined: Mon Dec 30, 2013 11:34 am
Posts: 7
Post Re: SSD1306 128x64 Pixel OLED display module (HCMODU0050&2)
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.



Sun Feb 23, 2014 10:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 35 posts ]  Go to page 1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD