Display dht22 temperature, humidity and hc-sr04 separately on 16,2 i2c lcd

How to display dht22 temperature, humidity and hc-sr04 data separately on 16,2 i2c lcd.

#include <dht.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <NewPing.h>
LiquidCrystal_I2C lcd(0x3f,16,2);


#define ECHO_PIN 46 //Defining pins
#define TRIG_PIN 47
#define MAX_DIST 300
#define DHTPIN 3
int contrast = 100; //Defining contrast
dht DHT;
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DIST);

void setup() { //Setup
  lcd.begin();
  Serial.begin(115200);
  Serial.println("dht22");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)");
}

void loop() {


  unsigned int uS2 = sonar.ping_cm();
  lcd.setCursor(0,0); 
  lcd.print("Vodostaj: "); 
  lcd.print(uS2);
  lcd.print("cm ");
  delay(1000);

  }

Tnx for help

How to display dht22 temperature, humidity and hc-sr04 data separately on 16,2 i2c lcd.

Set the cursor. Print some text. Set the cursor. Print some text. Set the cursor. Print some text. Job done.

Detailed explanation please? i'm a noob :slight_smile: tnx

Feriboxmm:
Detailed explanation please? i'm a noob :slight_smile: tnx

Even a noob can figure out the command to set the cursor. Your code even used the command, so, worst case, you have a 1 in 24 chance of guessing correctly, since your code only uses 24 unique commands.

Even a noob can figure out how to print text on the lcd. Your code did it three times.

Before you try too hard to get the desired text printed, just print "One", "Two", and "Clueless" on the LCD in three different places.

#include <dht.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <NewPing.h>
LiquidCrystal_I2C lcd(0x3f,16,2);


#define ECHO_PIN 46 //Defining pins
#define TRIG_PIN 47
#define MAX_DIST 300
#define DHT22_PIN 7
int contrast = 100; //Defining contrast
dht DHT;
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DIST);

void setup() { //Setup
  lcd.begin();
  Serial.begin(115200);
  Serial.println("dht22");
  Serial.print("Test: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}

void loop() {

  Serial.print("DHT22, \t");

  uint32_t start = micros();
  int chk = DHT.read22(DHT22_PIN);
  uint32_t stop = micros();
  
  unsigned int uS2 = sonar.ping_cm();
  lcd.setCursor(0,0); 
  lcd.print("Vodostaj: "); 
  lcd.print(uS2);
  lcd.print("cm ");
  delay(1000);

  
  lcd.setCursor(0,1 );
  lcd.print(DHT.humidity);
  lcd.print("%");   
  lcd.print(DHT.temperature); 
  lcd.println("C ");  
  lcd.setCursor(0, 1 );

  } [code]


Ok,  now I see temp and humidity on lcd. It's not perfect.... But it works...  Now I must figure out why i don't see any measurements on serial port

Now I must figure out why i don't see any measurements on serial port

Maybe because you don't actually print the measured values.