My I2C LCD is not displaying correct text

Aplogies if I have put this in the wrong forum or board, and wasn’t sure where to put it as it is hardware, and maybe software.

I have a Humidity and Temperature project which worked for a few months using a DHT22 sensor, then the LCD screen stopped displayed the correct text, and only squares.

I have re uploaded the sketch I used, again , but now the LCD screen is showing this: Temp: nan C, and Humi: nan %

I have tried another DHT22 sensor, and it is still the same.

I have uploaded the I2CexpDiag ino sketch and the LCD screen displays what is in the actual code, so it seems to work ok.

nan is the result of incorrect readings from the DHT.

Possible causes:
Bad contacts, shorts and the likes.
Incorrect pins used (on 328P based boards, A4 and A5 function as I2C as well).

Which library are you using for the DHT?

Post Your Code!
I was doing the exact same project!

sterretje:
nan is the result of incorrect readings from the DHT.

Possible causes:
Bad contacts, shorts and the likes.
Incorrect pins used (on 328P based boards, A4 and A5 function as I2C as well).

Which library are you using for the DHT?

The same sketch used to work ok, but I'm not sure which library it was at that time.Because the sketch stopped working, ie no readings, I thought to re upload it, but possible with a different DHT library.

I swapped to another DHT22, but with 3 pins, but both are AM2302, and it was just the same with nan readings.

I am using this DHT library:
Used: /home/rob/sketchbook/libraries/DHT

Written by Mark Ruys, mark@paracas.nl.

Should I use a different DHT library.

leognahsi:
Post Your Code!
I was doing the exact same project!

Code as requested:

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

#include "DHT.h"                        //include the DHT library   
#define DHTPin 2

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
DHT dht;

const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{
   dht.setup(DHTPin);
   lcd.begin(LCD_COLS, LCD_ROWS);
}
void loop()
{
   float temp = dht.getTemperature();
   float humi = dht.getHumidity();
   lcd.setCursor(0, 0);
   lcd.print("Temp: ");
   lcd.print(temp);
   lcd.print(" C");
   lcd.setCursor(0, 1);
   lcd.print("Humi: ");
   lcd.print(humi);
   lcd.print(" %");
   delay(2000);
}

I found the problem, as it was a negative/black wire not connected to ground on the Arduino, Doh!