Need help-Arduino UNO IDE

Discussion in 'The Projects Forum' started by neo1111, Apr 9, 2015.

  1. neo1111

    Thread Starter New Member

    Jan 11, 2014
    28
    1
    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 (Text):
    1. #include "DHT.h"                        
    2. #define DHTPIN 9                        
    3. #define DHTTYPE DHT22                    
    4. DHT dht22(DHTPIN, DHTTYPE);              
    5. #include "Wire.h"                          
    6. #include "LiquidCrystal_I2C.h"
    7. LiquidCrystal_I2C lcd(0x27,16,2);          
    8. void setup()
    9. {
    10.   Serial.begin(9600);                      
    11.   Serial.println("DHT22 serial");
    12. dht22.begin();                            
    13. lcd.init();                                                                    
    14. lcd.backlight();                          
    15. lcd.print("  OK ");
    16. lcd.setCursor (0, 1);
    17. lcd.print(F("Reading data"));
    18.     delay(5550);
    19.  
    20. }
    21.  
    22. void loop()
    23. {
    24.   lcd.setCursor(0,0);
    25.   float t = dht22.readTemperature() ;      
    26.   float h = dht22.readHumidity() ;          
    27.   Serial.print("Temperature is: ");        
    28.   Serial.print(t);                      
    29.   Serial.print(" C\t");                    
    30.   Serial.print("Humidity is: ");          
    31.   Serial.print(h);                      
    32.   Serial.print(" %");                    
    33. lcd.setCursor(0, 0);                      
    34. lcd.print("Temp.  : ");                    
    35. lcd.setCursor(9, 0);                    
    36. lcd.print(t);                          
    37. lcd.setCursor(15, 0);                
    38. lcd.print("C");                        
    39. lcd.setCursor(0, 1);                      
    40. lcd.print("Umidit.:       ");                  
    41. lcd.setCursor(9, 1);                    
    42. lcd.print(h);                            
    43. lcd.setCursor(15, 1);                    
    44. lcd.print("%");                          
    45. }
    ------------------------------------------END OF CODE----------------------------------------------

    [​IMG]
     
  2. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    neo1111 likes this.
  3. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,328
    890
    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.
     
    neo1111 likes this.
  4. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    A 20K to 50K pot with one end to Pin 1, the other end to Pin 2 and the wiper to Pin 3 will give you what you need.
     
    neo1111 likes this.
  5. neo1111

    Thread Starter New Member

    Jan 11, 2014
    28
    1
    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. :)
     
Loading...