DHT11 + 16x2 LCD I2C programming question

Hello!

How I can remove dot and two zero-/s (.00). I want use only whole values. Maybe I need to use other DHT library?

My code what I wrote;

#include <dht.h>
#define dht_apin A0

dht DHT;

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd

// Print a message to the LCD.
lcd.backlight();
//lcd.print("Hello, world!");
}

void loop()
{
DHT.read11(dht_apin);

lcd.print("T=");
lcd.print(DHT.temperature);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("H=");
lcd.print(DHT.humidity);
lcd.print("%");
delay(5000);
lcd.clear();
}

Used libraries in attachments.

Thank you!

Used libraries http://s000.tinyupload.com/index.php?file_id=35808777512676372137

I suspect there are many options here.

  1. Not sure on your library functionality, can you print numbers as integers?
  2. Round the float and Convert it to an integer. Print the integer.
  3. Arduino Reference - Arduino Reference

There are others with years & years more experience than I, but that's how I'd tackle it.

R
Jon

 lcd.print(DHT.temperature, 0);

Assuming temperature is a float.

Thanks man. It's was so easy ! :slight_smile: