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.