Need help-Arduino UNO IDE

Thread Starter

neo1111

Joined Jan 11, 2014
28
Hy there. I have a problem with my project.
I want to show the temp/humidity from a dht22 sensor to a lcd 16x2 via i2c communication.

As you can see : from direct view i don't see anything,just some squares; but from different angle -all is clear.
What i must add in the program in order to see it clear from any angle .
I have to add a new line to clear the screen?
------------------------------------------CODE BELOW------------------------------------------------
Code:
#include "DHT.h"                        
#define DHTPIN 9                         
#define DHTTYPE DHT22                     
DHT dht22(DHTPIN, DHTTYPE);               
#include "Wire.h"                          
#include "LiquidCrystal_I2C.h" 
LiquidCrystal_I2C lcd(0x27,16,2);           
void setup()
{
  Serial.begin(9600);                      
  Serial.println("DHT22 serial");
dht22.begin();                             
lcd.init();                                                                     
lcd.backlight();                           
lcd.print("  OK ");
lcd.setCursor (0, 1);
lcd.print(F("Reading data"));
    delay(5550);

}

void loop()
{
  lcd.setCursor(0,0);
  float t = dht22.readTemperature() ;       
  float h = dht22.readHumidity() ;          
  Serial.print("Temperature is: ");        
  Serial.print(t);                       
  Serial.print(" C\t");                    
  Serial.print("Humidity is: ");           
  Serial.print(h);                       
  Serial.print(" %");                    
lcd.setCursor(0, 0);                      
lcd.print("Temp.  : ");                    
lcd.setCursor(9, 0);                     
lcd.print(t);                          
lcd.setCursor(15, 0);                
lcd.print("C");                        
lcd.setCursor(0, 1);                      
lcd.print("Umidit.:       ");                   
lcd.setCursor(9, 1);                     
lcd.print(h);                             
lcd.setCursor(15, 1);                    
lcd.print("%");                           
}
------------------------------------------END OF CODE----------------------------------------------

 

Attachments

OBW0549

Joined Mar 2, 2015
3,566
There's nothing wrong with your program; the LCD contrast just needs to be tweaked. Pin 3 on the LCD connector, the one labeled Vo, is what controls that.
 

Thread Starter

neo1111

Joined Jan 11, 2014
28
On the back of your display, there should be a variable resistor. That controls the CONTRAST of the display. Try adjusting it to see if things get clear (pun intended) If your display does not have the control, pin 3 provides that through voltage adjustment. Here is a data sheet, of sorts.

http://www.engineersgarage.com/electronic-components/16x2-lcd-module-datasheet
Yes indeed, problem solved! Thx a lot!
The thing is that i have a LCD keypad shield and i connected the i2c module to get rid off some wires . I moved the potentiometer on the shield (silly me ) and nothing happened.I had forgotten that the i2c module has a potentiometer as well.
So, problem solved. :)
 
Top