Displaying temp and humidity on LCD


#1

I have a DHT22, a DS18B20 and a 16x2 lcd connected. Set it up through circuito and downloaded code. Tests run fine but I would like to display the temps and humidity on the screen. Do I need to add another tab to the code? Any help would be appreciated.


#2

Hey,

After you got circuito.io test code and tested that everything works, you need to modify the code in order to print real-time data on the LCD.
To do so you can:

locate the DHT22 and DS18B20 test codes.
replace ‘Serial.print’ with ‘lcdI2c.print’ - it needs to be in the same format as the LCD test code structure.
after doing so, run the DHT22/DS18B20 test code - you should see the data printed on the LCD.
play around and modify the code some more to match your needs. you can use the LCD test code as a good reference.

Good luck :slight_smile:


#3

I want to learn this project


#4

Hi TH1RTE3N,
This link will help you https://chrisruppel.com/blog/arduino-humdity-temperature-lcd/ :sunglasses: . I have also added some code don below for you, this code is directly from the website link above, Enjoy! :grinning:
#include <SimpleDHT.h>
#include <LiquidCrystal.h>

// Initialize humidity sensor.
const int pinDHT11 = 6;
SimpleDHT11 dht11;

// Initialize LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Setup LCD and display startup message
void setup() {
// Display is two 16-char rows
lcd.begin(16, 2);

// Print a startup message
lcd.print(“Startup OK!”);
delay(1000);

// Clear display so we can show data
lcd.clear();
}

// Display temp/humidity data until power-down
void loop() {
// Create variables for DHT sensor output.
byte temperature = 0;
byte humidity = 0;

// Read sensor data and store results
// in temperature/humidity variables
dht11.read(pinDHT11, &temperature, &humidity, NULL);

// Print first line to LCD
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(round(temperature));
lcd.print("C / ");
lcd.print(round(temperature * 1.8 + 32));
lcd.print("F "); // two extra spaces in case temps drop to single digits

// Print second line to LCD
lcd.setCursor(0,1);
lcd.print("Humidity: “);
lcd.print(humidity);
lcd.print(”% "); // extra space in case humidity drops to single digit

// Delay 1 second because DHT11 sampling rate is 1HZ.
delay(1000);
}


#5

Anat
after all testing were good
but then the data to lcd
you give this advice
replace 'Serial.print’with ‘lcdi2c’
Shoul that not be ‘lcdI2C’
thanks
Dick