KS0108 I2C display

I'm having trouble displaying sensor values on this display. I'm using Nick Gammon's I2C_graphical_LCD_display.h library. His example works fine, and I can print strings ok. But how do I print sensor values..?

Tried other libraries, but none of them seem to work.

I have not worked with Gammon's library, but if you can print strings w/o any problems you can always convert your sensor values into strings. You should be able to do something like:

double sensorValue = 10.8356;
String forPrinting = String(sensorValue,4);

This will create a string called forPrinting with all the data in sensorValue. The number 4 indicates how many decimals of precision to use when converting the double to a String.

As always, be cautious of Strings, as they have a lot of limitations. In this context, though, they should work fine.

Hope this helps!


Change the numbers to strings with the itoa() function (for integers) or dtostrf() function (for floats)?

That library does not use the String class.

If you are using the code from here:

It is all setup to use the Print class.

You can print pretty much anything using the print() methods.


lcd.print("Hello world");


and are not handled so you can’t use println()
— bill

Tried this, but doesn't work

void loop ()

int h = am2320.readHumidity();
int t = am2320.readTemperature();

Serial.print("Temp: "); Serial.println(am2320.readTemperature());
Serial.print("Hum: "); Serial.println(am2320.readHumidity());

lcd.string("Temperature: ");



Please post code properly. (you have been a member for 3 years)

Then you will get a reply.


Post the entire program.

"but doesn't work" does not convey any useful information.

Tried this, but doesn't work

You are missing a setup() function.

--- bill