Welcome! Log In Create A New Profile

Advanced

DIY Tiny OLED I2C full graphics controller

Posted by enif 
DIY Tiny OLED I2C full graphics controller
April 20, 2015 04:17PM
This describes a little DIY project I did for building a I2C based tiny full graphic controller using the SSD1306 128x64 OLED display.

This OLED display comes in two sizes, 0.96" and 1.3", and can be ordered on eBay for a few dollars. So far I only have the 0.96" version, but I have now ordered the 1.3" version. Fortunately, the SSD1306 interface is already supported in U8GLIB, so no programming is needed, just some configuation changes. Since the OLED display uses the I2C, only 4 wires (VCC, GND, SCL, SDA) are needed for the display itself. Add to that the 3 signals for the rotary encoder plus one signal for an (optional!) piezo buzzer, to a total need for only 8 wires. I found this especially useful for the Sanguinololu, where not so many additional pins are available.

Other advantages of the OLED display are that is really bright, does not need any fiddling with the contrast, only draws a total current of about 8mA and, last but not least, works with either 5V or 3.3V supply and signals - the latter being particularly interesting for ARM based controller boards.

For building the controller you need the following:
  • an SSD1306 I2C 128x64 OLED display (available as 0.96" or 1.3" versions)
  • a rotary encoder with integrated click switch
  • a piezo buzzer (optional, just for audible feedback of click)
  • a piece of prototype PCB board (about 1.5"x2.5" is enough)
  • some wires and pin headers

Here first the schematic how I wired the components and connected them to either RAMPS or Sanguinololu...


... a photo of the working display controller

... the front and back of the prototype board


... connected to the RAMPS

... and to the Sanguinololu


The modifications to Marlin are only minimal changes in the files Configuration.h, Conditionals.h, dogm_lcd_implementation.h, pins_SANGUINOLOLU_11.h and pins_RAMPS_13.h. The attached patch file contains all the changes needed to the current version 1.0.3 of Marlin.

For those wanting printing from an SD-card (I don't), it is easy to add one of these cheap SPI based micro-SD modules that can be ordered on eBay for less than 2$, since the standards SPI pins used for the SD-cards are left untouched by the OLED display. Here pictures of my test using the tiny OLED controller together with an micro-SDcard module, on both RAMPS and Sanguinololu:





I know, buying a ready made 2004 or full graphic LCD controller is so cheap today, that you won't save any money by building things yourself. But that was not my aim for this project, rather my goal was (other than the fact that I really like tinkering) to have something really small, need only a minimum of cabling, draws only little current and is also working on 3.3V...
Attachments:
open | download - Marlin103-tinyoled.patch (2.8 KB)
Re: DIY Tiny OLED I2C full graphics controller
April 20, 2015 04:31PM
There's also a 2.42" version.

ebay link

Thanks for sharing!
Re: DIY Tiny OLED I2C full graphics controller
April 20, 2015 06:11PM
Thank you very much enif for posting this complete information, that is a great project by itself! thumbs up

I have ordered a 1.3" OLED module and will be testing it shortly. smiling bouncing smiley

Just one small detail to add: when driving the buzzer with one of the Arduino Due pins, I would suggest adding a single transistor current amplifier, the Due output drivers are really weak compared to the Arduino Mega ones.
Re: DIY Tiny OLED I2C full graphics controller
April 21, 2015 03:42AM
wow Thats Great, finally small displays, for my small printers grinning smiley

Thanks for sharing smiling smiley

Chri


[chrisu02.wordpress.com] Quadmax Intel Delid Tools
Re: DIY Tiny OLED I2C full graphics controller
April 23, 2015 08:00AM
I have now replaced the prototype board of my tinyOLED by an etched PCB, which also allows for an optional piggyback micro-SD module. The whole thing is now smaller than a matchbox:


Compared to the initial prototype board version, the design has essentially remained the same, but 4 extra pins have been added to the pin header to allow for the optional micro-SD card module to be mounted directly on the back of the display. In addition, I have added a protection diode (I use a 5.1V zener) across the piezo buzzer. So here is an updated schematic drawing:


The size of the single sided PCB is 2"x1.5" and a PDF with the layout is attached to this message.


And finally here some more photos with details of the tinyOLED and the way it is connected to RAMPS and Sanguinololu:



Attachments:
open | download - tinyoled-pcb-layout-11.pdf (12.9 KB)
Re: DIY Tiny OLED I2C full graphics controller
April 23, 2015 08:11AM
Thats excellent. Just nedds a nice 3d printed case now.

I can imagine half a dozen far east companies copying this as we read your post.
Whatch out it will be on ebay as a complete board soon.

Gordon
Re: DIY Tiny OLED I2C full graphics controller
April 23, 2015 08:24AM
thumbs upthumbs upthumbs upthumbs upthumbs upthumbs upthumbs upthumbs up!!!!!!!
Re: DIY Tiny OLED I2C full graphics controller
April 23, 2015 09:25AM
Awesome! I definately have some future projects that this will work great on.
Re: DIY Tiny OLED I2C full graphics controller
April 24, 2015 05:49AM
Great work enif thumbs up
Re: DIY Tiny OLED I2C full graphics controller
April 24, 2015 12:04PM
This is great!
Re: DIY Tiny OLED I2C full graphics controller
April 25, 2015 06:16AM
Since there was still some unused space on the PCB and I am also using the tinyOLED with my "eeprom-less" Arduino Due (using Andrew's RAMPS modifications), I thought why not add to the PCB the option to include an I2C EEPROM.




The problem which remains to be solved is how to access the EEPROM from within Marlin. While this is no problem without the display controller configured, using an U8glib I2C display obviously creates some conflict with simultaneously using the Wire.h I2C interface for the EEPROM. So it's probably best (but not trivial!) trying to access the EEPROM using U8glib's I2C routines instead of Wire.h ...
Attachments:
open | download - tinyoled-pcb-layout-12.pdf (14.2 KB)
Re: DIY Tiny OLED I2C full graphics controller
April 25, 2015 07:47AM
Amazing work there, enif! thumbs up thumbs up thumbs up thumbs up thumbs up thumbs up thumbs up thumbs up

Since you are adding extra options to your already great OLED display design, why not add a small four pin header to connect an $3 ESP8266 Wi-Fi module to one of the unused UART ports on the Due?



Edited 1 time(s). Last edit at 04/25/2015 07:49AM by AndrewBCN.
Re: DIY Tiny OLED I2C full graphics controller
April 25, 2015 08:16AM
Thanks, Andrew!

As for adding a header for the Wifi module, the RX0/TX0 signals would require 2 extra wires to the tinyOLED (whereas the I2C signals are already there for the display). Also there is already a 4-pin header with exactly the 4 needed signals (VCC, GND, TX0, RX0) on the inner part of standard RAMPS AUX-1 connector.
Re: DIY Tiny OLED I2C full graphics controller
April 25, 2015 08:46AM
Quote
enif
Thanks, Andrew!

As for adding a header for the Wifi module, the RX0/TX0 signals would require 2 extra wires to the tinyOLED (whereas the I2C signals are already there for the display). Also there is already a 4-pin header with exactly the 4 needed signals (VCC, GND, TX0, RX0) on the inner part of standard RAMPS AUX-1 connector.

OK, I understand!

I guess we are all set for a cheap WiFi add-on interface for our Due/RAMPS4Due setup! The next step is obviously how to integrate the ESP8266 module with Marlin4Due and test it!
Re: DIY Tiny OLED I2C full graphics controller
April 26, 2015 02:45PM
As for the I2C problem on the Arduino Due that caused some conflict when activating simultaneously the I2C OLED (using the U8glib I2C routines) and the I2C EEPROM (using Arduino's Wire.h), I have made some progress:

I removed the '//' from the (3 each) commented out statements "//u8g->pin_list[U8G_PI_SET_A0] = 1;" and "// u8g_i2c_stop();" in file U8glib/utility/u8g_com_arduino_ssd_i2c.c :

$diff u8g_com_arduino_ssd_i2c.c.ori u8g_com_arduino_ssd_i2c.c
125c125
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
130c130
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();
134c134
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
146c146
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();
150c150
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
163c163
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();

After recompiling Marlin4Due with this change the Arduino Due the conflict seems resolved and it can now access the I2C EEPROM (after having it activated in Configuration.h of course) while using the I2C OLED display - so far without any problem smiling smiley
Re: DIY Tiny OLED I2C full graphics controller
April 28, 2015 04:08PM
Today arrived the ordered 1.3" OLED. Even though it is bigger, it still fits onto the same PCB as the 0.96" OLED. Here is a photo so that you can compare the sizes of the two versions:



Of course, the bigger 1.3" display is somewhat easier on the eyes.

As for the current requirements, displaying Marlin's info screen the 1.3" display draws about 12mA, compared to 8mA for the 0.96" display.

It is possible to use the larger OLED with the same firmware configuration as the smaller one, but then the display is slightly shifted to the left (I'd guess about 4 pixels), which leaves an ugly random stripe on the far right of the display. This can be resolved by using for the 1.3" version the U8glib device SH1106 instead of SSD1306. Thus, I have made further small changes to Marlin to allow defining the macro SSD1306_OLED_I2C_CONTROLLER for the 0.96" version and SH1106_OLED_I2C_CONTROLLER for the 1.3" version. The corresponding patch is attached to this message.
Attachments:
open | download - Marlin103-tinyoled.patch (3.6 KB)
Re: DIY Tiny OLED I2C full graphics controller
April 28, 2015 07:16PM
As usual, an excellent post! thumbs up

Thank you enif! smileys with beer
Re: DIY Tiny OLED I2C full graphics controller
April 29, 2015 07:51AM
Love It!
Re: DIY Tiny OLED I2C full graphics controller
May 01, 2015 03:28PM
I have now made a slightly larger version of the PCB which leaves even with the 1.3" display some gap towards the rotary encoder, which is needed for building a nice frame around the tinyOLED controller:


And also I have now created frames for both sizes of the tinyOLED, based on the above PCB version, which I have put on thingiverse:


Attachments:
open | download - tinyoled-pcb-13.pdf (13.7 KB)
Re: DIY Tiny OLED I2C full graphics controller
May 01, 2015 06:58PM
wow thats really tiny compaired to a normal LCD thumbs up i love it, i would have one for my small Beiwagerl and Pluto printer, they would fit perfect grinning smiley

I was thinking since some time of turning the encoder 90° to the right side, with this the scrolling would be more intutitive and the case would be even more compact ^^
But i don`t know if such a encoder is available that will fit that style.

I attached a quick sketch of it, i hope it show`s what i mean.

Chri

Edited 3 time(s). Last edit at 05/02/2015 03:28AM by Chri.


[chrisu02.wordpress.com] Quadmax Intel Delid Tools
Attachments:
open | download - tinycase.JPG (43.6 KB)
Re: DIY Tiny OLED I2C full graphics controller
May 02, 2015 01:19AM
Good idea, Chri! Indeed this would be much more intutitive. Don't know how to implement this easily, but I'll keep it in mind... smiling smiley
Re: DIY Tiny OLED I2C full graphics controller
May 02, 2015 01:31PM
enif, do you any idea how to use regular buttons insted encoder? I am going for I2C OLED screen but would like to use buttons like Ultimaker 2.
Re: DIY Tiny OLED I2C full graphics controller
May 02, 2015 10:57PM
Quote
Chri
wow thats really tiny compaired to a normal LCD thumbs up i love it, i would have one for my small Beiwagerl and Pluto printer, they would fit perfect grinning smiley

I was thinking since some time of turning the encoder 90° to the right side, with this the scrolling would be more intutitive and the case would be even more compact ^^
But i don`t know if such a encoder is available that will fit that style.

I attached a quick sketch of it, i hope it show`s what i mean.
Chri

The remote control transmitter brands "JR" & "Spektrum" use a roller style click encoder on many of their models which are a nice "thumb" size and could be mounted horizontally next to the screen.


Edited 1 time(s). Last edit at 05/02/2015 10:58PM by bigfilsing.
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 02:33AM
Quote
3dMistery
enif, do you any idea how to use regular buttons insted encoder? I am going for I2C OLED screen but would like to use buttons like Ultimaker 2.

I don't really know exactly what kind of buttons the Ultimaker 2 uses. But indeed I was also first thinking about using 3 simple buttons (up, down, select) for the tinyOLED instead of the rotary encoder. However, when I looked into the source code, it looked so much easier to just use the "standard" rotary encoder. If I get some time, maybe I'll replace the encoder in one of my early prototypes with 3 buttons, so that I can experiment...

While I was really not very fond of using a rotary encoder instead of simple buttons at the beginning, Chri's idea to put the encoder on the side makes it really much more attractive - more intuitive to use, and it would also allow for even smaller PCB and frame. So I'll probably look at this first...
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 03:43AM
First of all, nice project! smiling smiley I was looking for a small LCD to attach to my FoldaRap, but I don't know about this kind of tiny OLED screens. Beautiful!

Quote
enif
Quote
3dMistery
enif, do you any idea how to use regular buttons insted encoder? I am going for I2C OLED screen but would like to use buttons like Ultimaker 2.

I don't really know exactly what kind of buttons the Ultimaker 2 uses. But indeed I was also first thinking about using 3 simple buttons (up, down, select) for the tinyOLED instead of the rotary encoder. However, when I looked into the source code, it looked so much easier to just use the "standard" rotary encoder. If I get some time, maybe I'll replace the encoder in one of my early prototypes with 3 buttons, so that I can experiment...

I was also looking for a simple way to replace the encoder with buttons, but the code inside Marlin and the encoder implementation is very hardcoded.

Quote
enif
While I was really not very fond of using a rotary encoder instead of simple buttons at the beginning, Chri's idea to put the encoder on the side makes it really much more attractive - more intuitive to use, and it would also allow for even smaller PCB and frame. So I'll probably look at this first...

There are some THT rotary encoders with horizontal PCB mounting: [es.rs-online.com]
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 05:04AM
Quote
xoan
There are some THT rotary encoders with horizontal PCB mounting: [es.rs-online.com]

Thanks for the link! I was looking for this kind of horizontally mounted encoder. However, I am not sure if I really like the built in LEDs...

My first try will be to use use a standard vertical encoder and somehow mount it horizontally - that shouldn't be too difficult either.
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 05:51AM
Quote
enif
Quote
xoan
There are some THT rotary encoders with horizontal PCB mounting: [es.rs-online.com]

Thanks for the link! I was looking for this kind of horizontally mounted encoder. However, I am not sure if I really like the built in LEDs...

A better link: [www.digikey.com]
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 05:57AM
Quote
xoan
A better link: [www.digikey.com]

Wow - what a selection! smiling smiley
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 07:52AM
Quote
enif
Quote
3dMistery
enif, do you any idea how to use regular buttons insted encoder? I am going for I2C OLED screen but would like to use buttons like Ultimaker 2.

I don't really know exactly what kind of buttons the Ultimaker 2 uses. But indeed I was also first thinking about using 3 simple buttons (up, down, select) for the tinyOLED instead of the rotary encoder. However, when I looked into the source code, it looked so much easier to just use the "standard" rotary encoder. If I get some time, maybe I'll replace the encoder in one of my early prototypes with 3 buttons, so that I can experiment...

While I was really not very fond of using a rotary encoder instead of simple buttons at the beginning, Chri's idea to put the encoder on the side makes it really much more attractive - more intuitive to use, and it would also allow for even smaller PCB and frame. So I'll probably look at this first...

Could it be possible to use 3 buttons connected in same way as encoder?

Center button is same connection as press function on encoder, so that will work, but what with up/down buttons? Would a press of a button be registered the same as encoder rotation? Can you try that?
Re: DIY Tiny OLED I2C full graphics controller
May 03, 2015 08:55AM
Quote
3dMistery
Could it be possible to use 3 buttons connected in same way as encoder?

Center button is same connection as press function on encoder, so that will work, but what with up/down buttons? Would a press of a button be registered the same as encoder rotation? Can you try that?

No, I am sure that won't work that easily. The rotary encoder does not react on individual on-off clicks of the encoder signals, but the software detects a kind of phase shift between them to determine the rotation direction. See [en.wikipedia.org] .
Sorry, only registered users may post in this forum.

Click here to login