Cannot print temperature on lcd

Hi,

I have 16x2 lcd and I am trying to print temperature on it. The sensor is dht11. I tried everything but it looks like there is some problem with parsing the temeprature. Problem isnt in the sensor it prints on serial the temperature correctly. Here is the code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(0, 1, 8, 9, 10, 11); 
#include "DHT.h"
// nastavení čísla pinu s připojeným DHT senzorem
#define pinDHT 5

// odkomentování správného typu čidla
#define typDHT11 DHT11     
DHT mojeDHT(pinDHT, typDHT11);

void setup() {
  Serial.begin(9600);
  mojeDHT.begin();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
}

void loop() { 
  float tep = mojeDHT.readTemperature();
  float vlh = mojeDHT.readHumidity();

  if (isnan(tep) || isnan(vlh)) {

    Serial.println("Chyba při čtení z DHT senzoru!");
  } else {
    Serial.println(tep);
    lcd.println(int(tep));
  }
  // pauza pro přehlednější výpis
  delay(2000);
}

Thanks for any help,
tom

TomasRoj:
Hi,

I have 16x2 lcd and I am trying to print temperature on it. The sensor is dht11. I tried everything but it looks like there is some problem with parsing the temeprature. Problem isnt in the sensor it prints on serial the temperature correctly. Here is the code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(0, 1, 8, 9, 10, 11);
#include “DHT.h”
// nastavení čísla pinu s připojeným DHT senzorem
#define pinDHT 5

// odkomentování správného typu čidla
#define typDHT11 DHT11   
DHT mojeDHT(pinDHT, typDHT11);

void setup() {
  Serial.begin(9600);
  mojeDHT.begin();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
}

void loop() {
  float tep = mojeDHT.readTemperature();
  float vlh = mojeDHT.readHumidity();

if (isnan(tep) || isnan(vlh)) {

Serial.println(“Chyba při čtení z DHT senzoru!”);
  } else {
    Serial.println(tep);
    lcd.println(int(tep));
  }
  // pauza pro přehlednější výpis
  delay(2000);
}




Thanks for any help,
tom

Do you not need to position the cursor in the display before writing?

Deleted and nothing changed >:(

TomasRoj:
Deleted and nothing changed >:(

Yea, as I stated the extra brackets would not have been a problem, it just looked odd.

Let us take a step back. Have you tried any of the LCD example programs to be sure the LCD is wired and functioning correctly?

Of course, everything works perfectly. Both LCD and dht11. Only problem is printing the temperature on the display.

When you print to the LCD the cursor moves to the end of the prined characters. If you want to always start the print at cursor position (0,0) you need to move the cursor there each time before you print with

lcd.setCursor(0,0);

Fixed, now prints some shits that I cannot read.

Those "shits" might be the non-printing line ends from the lcd.println. Try lcd.print?

Already did it.

LiquidCrystal lcd(0, 1, 8, 9, 10, 11);

Which board do you have? Pins 0 and 1 are used by Serial on many boards.

oqibidipo:
Which board do you have? Pins 0 and 1 are used by Serial on many boards.

True and I was going to ask about that before OP said the lcd was working perfectly except for the temperature.

I have arduino uno and I am using lcd without potenciometer. Again, I dont have any problem with lcd or dht11 itself only with printing the temperature

Yes but you are now also using serial to print. Move the lcd off pins 0 and 1.

Changed theese pins and everything works just fine. Thank you all for you help! Thanks!