Wednesday, 6 November 2013

Another update to the OLED 1602 Library

I've made a change to the 1602 OLED library and also added a new function.

I've modified the sendString() function to now include the cursor position data and added a new function called sendFloat(), this allows you to send float data values, such as temperature, to the LCD ant it gets converted to a string before being sent to the display.

The sendFloat function takes the following parameters: float value, minimum length inc. decimal point, number of positions after the decimal point, the start column position, the start row position.

I've updated the library in my GitHub repository here

Please note that older sketches using the sendString() function will not work with the new library and will need to be altered.

Demo sketch to display Strings and float values on the OLED
1602 display  from Wide.HK. This uses a Lbrary that I've
put together containing some basic functions.
 The I2C Address is set to 0x3C in OLedI2C.cpp
 Phil Grant 2013

#include "Wire.h"
#include "OLedI2C.h"
float digit;

void setup()
  digit = 21.6;//This would normally be the float value returned from a temp sensor or other sensor
void loop()
  LCD.sendString("Temp",0,0);// now includes the cursor position data (col, row)
  LCD.sendFloat(digit,5,2,7,0);//Send the string to the display


Mortimer Neuss said...

Great Great Great!
This ight here is an excelent example of why I love the Arduino-Scene so much. I received my OLED-Display today and tried the Code WIDE-HK delivered on the auction site, but it was full of problems ( sendCommand(0xC0) -> So such command and eine } was even missing... ugh)

Have many thanks that you took the time and made a amazing lib for this Display. I'm fairly new to this field of technology and can only thank you so much. Thank you!

Gadjet said...

Thanks for the kind feedback, I'm glad someone is finding my efforts useful.

I had much the same experience with the display when I first bought it, I am used to always finding an existing library to use, but not this time so I thought I would try writing my own.

dnbblah said...

Hey there, thanks for the Library, works great for me, i even used a multiplexer to chain 4 dispays on one single I2C port and everything runs smoothly.

Well despite one tiny thing..:

I tried to get the display to actually using ROM A.

It looks like the command given seems not to change to ROM A.
I looked into the command table of the spec of the SSD131x_1.0 IC Spec.pdf and the command seems to be O.K. but my LEDs are actually running on ROM C.

To verify this i used the binary B10111110 which should be a sharp S - umlaut but instead its a Chinese character representing ROM C in the spec.

Any clues?


Gadjet said...

Sorry but I've not looked into using special characters at all so I'm not able to give you any answers I'm afraid.

dnbblah said...

thanks for your help and your response.
I guess i have to contact the seller and ask.
It definitely looks like that the ROM isn't been changed.



peterpeter said...

Great work! I just bought this display and I am very happy to see useable library. The one provided by manufacturer is really just to write hello world :) Thank you!

Q said...

Your library works great.

Is there a way to hook up 2 of these displays to 1 Arduino without adding more hardware.

Gadjet said...

On the face of it it looks like there are no jumpers to set the address, I don't know if it can be programaticaly changed.

I would use the Jeenode ports library ( to create a soft I2C port(s) and then you should be send data to more than one LCD even with the same address.

Carneiro said...


I received a OLED 2002 from but it doesn't show any characters and it gets crazy hot... Maybe this unit is broken?



Gadjet said...

I have to ask, have you got the supply connections the right way around?
What is the voltage your using?

Carneiro said...

No problem, logical question :-). I got it right, and I'm using 5V. The VCC pin is the most right, like the pictures from them.

If it were just not working I would imagime some software issue, but it gets crazy hot... I wrote them today.



Gadjet said...

Yes it does sound like it's faulty.

Hope you get a replacement OK

Carneiro said...

Thanks for the help. I've tried to power the Arduino with a wall supply, 9V, and Arduino goes off and even the power supply goes OFF! Very weird.

Does their shipping get quickly to US? Here it takes sooo long, but more then half to blame is our customs... :-(

Gadjet said...

What is the current rating of your wall adapter, it may be shutting down because there is too much current being drawn by the circuit or it is a faulty supply.

I don't know about the US I'm in the UK.

Carneiro said...

The supply is 1000 mA.

Gadjet said...

Should be fine, have you measured the supply voltage with a multimeter, sometimes the voltage from a wall wart can be a bit higher than stated when supplying low currents.

Carneiro said...

9.3V :-)

Gadjet said...

OK, last try, I assume it's an UNO, does it work when supplied from the PC USB port?

Carneiro said...

Yes, it works, but the OLED gets hot (and the Arduino LED is a little bit dimmed down). It really seems something is off with this OLED display.

Gadjet said...

Yes I would guess that the display is drawing too much current.

Get a replacement :-)