Hello guys I need help. I have 2 DHTs and 4 HX711 to be displayed on LCD I2C and somehow LCD doesn't display readings. How can I fix this?
#include <DHT.h>
#include <HX711.h>
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#define DHTPin1 2
#define DHTPin2 3
#define DHTTYPE DHT22
#define LOADCELL_DOUT_PIN 5
#define LOADCELL_SCK_PIN 4
#define LOADCELL_DOUT1_PIN 7
#define LOADCELL_SCK1_PIN 6
#define LOADCELL_DOUT2_PIN 9
#define LOADCELL_SCK2_PIN 8
#define LOADCELL_DOUT3_PIN 11
#define LOADCELL_SCK3_PIN 10
HX711 (scale);
HX711 (scale1);
HX711 (scale2);
HX711 (scale3);
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
DHT dht1(DHTPin1, DHTTYPE); // <-- CORRECT - ADD
DHT dht2(DHTPin2, DHTTYPE);
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
// Define variables
float hum = 0.0;
float hum1 = 0.0;// Stores humidity value
float temp = 0.0; // Stores temperature value
float temp1 = 0.0;
void setup()
{
Serial.begin(9600);
dht1.begin();
dht2.begin();
lcd.begin(LCD_COLS, LCD_ROWS);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.begin(LOADCELL_DOUT1_PIN, LOADCELL_SCK1_PIN);
scale.begin(LOADCELL_DOUT2_PIN, LOADCELL_SCK2_PIN);
scale.begin(LOADCELL_DOUT3_PIN, LOADCELL_SCK3_PIN);
scale.set_scale();
scale.tare();
}
void loop()
{
delay(4000); // Delay so sensor can stabilize
scale.set_scale(-376.0);
scale1.set_scale(-376.0);
scale2.set_scale(-376.0);
scale3.set_scale(-376.0);
hum = dht1.readHumidity();
hum1 = dht2.readHumidity();
delay(2500);
temp = dht1.readTemperature();
temp1 = dht2.readTemperature();
delay(2500);
float grams = scale.get_units(5);
float grams1 = scale1.get_units(5);
float grams2 = scale2.get_units(5);
float grams3 = scale3.get_units(5);
lcd.setCursor(0, 0);
lcd.print("T:");
lcd.print(temp);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("T:");
lcd.print(temp1);
lcd.print("C");
delay(2500);
lcd.setCursor(9, 0);
lcd.print("H:");
lcd.print(hum);
lcd.print("%");
lcd.setCursor(9, 1);
lcd.print("H:");
lcd.print(hum1);
lcd.print("%");
lcd.setCursor(0, 2);
lcd.print("W:");
lcd.print(grams);
lcd.print(" g");
lcd.setCursor(0, 3);
lcd.print("W:");
lcd.print(grams1);
lcd.print(" g");
lcd.setCursor(9, 2);
lcd.print("W:");
lcd.print(grams2);
lcd.print(" g");
lcd.setCursor(9, 3);
lcd.print("W:");
lcd.print(grams3);
lcd.print(" g");
}