I tried floating numbers with
lcd.print(2*t,6);
and I get all digits
When i try int with 6 numberds
lcd.print(t)
all i get is the first number.
somehow, I am losing the digits from the first digit to the decimal point
I tried floating numbers with
lcd.print(2*t,6);
and I get all digits
When i try int with 6 numberds
lcd.print(t)
all i get is the first number.
somehow, I am losing the digits from the first digit to the decimal point
I looked online where I purchased the LCD and found a library that worked.
#include <LiquidCrystal_I2C_PCF8574.h>
I have my doubts. Stop struggling with this.
Go back and read reply #2. Use the had hd44780.h library from the library manager as suggested. It is plug and play for all the various pin configurations of the 8574 chip to the display.
Here is the last code you tried using that library.
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // include i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config display for hd44780 chip
void setup() {
lcd.begin(16, 2);
float t = 123.456;
lcd.setCursor(0, 0);
lcd.print("1t = ");
lcd.print(t, 3);
lcd.setCursor(0, 1);
lcd.print("2t = ");
lcd.print(2 * t, 3);
}
void loop() {}
OK try this code:
#include <Wire.h>
#include <LiquidCrystal_I2C_PCF8574.h>
LiquidCrystal_I2C_PCF8574 lcd(0x27, 16, 2);
void setup() {
float t = 123.456;
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("1t = "); // or try with lcd.writeStr()
lcd.setCursor(5,0);
lcd.print(t,3);
lcd.setCursor(0,1);
lcd.print("2t = "); // or try with lcd.writeStr()
lcd.setCursor(5,1);
lcd.print(2*t,3);
}
void loop() {}
what do you see this time?
But I would say the library you chose is a piece of sh*t
- I would remove it from my hard drive dump it and try The hd44780 library (available from the IDE library manager) pointed by groundFungus in post #2 for example or other I2C library
(ie try the code provided by cattledog after installing the library)
So thanks to everyone who responded to my question. A special thanks to cattledog and J-M-L who got me pointed in the right direction. (Once I got the sensor and code working, I used my DHT22 instead of the DHT11 for the final product.)
This is the final code:
#include <dht.h>
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // include i/o class header
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config display for hd44780 chip
void setup() {
DHT.read22(dht_apin);
Serial.begin(9600);
delay(1000 );//Delay to let system boot
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor
lcd.begin(16, 2);
}//end "setup()"
void loop() {
//Start of Program
DHT.read22(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("Temperature = ");
// Serial.print(DHT.temperature);
Serial.print((int)round(1.8 * DHT.temperature + 32));
Serial.println(" F ");
delay(500);//Wait .5 seconds before accessing sensor again.
int chk = DHT.read22(dht_apin);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(1.8 * DHT.temperature + 32,1);
lcd.print((char)223);
lcd.print("F");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity,1);
lcd.print("%");
delay(1000);
//Fastest should be once every two seconds.
}// end loop()
Thanks again!


That’s good news !