Hello everyone, We badly need our help. How to display temperature and humidity readings to LCD I2C display? The first DHT22 is ok but the second DHT22 only reads 3 on temperature and humidity. Here's my code thank you!
#define DHTPin1 4
#define DHTPin2 7
#define DHTTYPE1 DHT22
#define DHTTYPE2 DHT22
DHT dht1(DHTPin1, DHTTYPE1);
DHT dht2(DHTPin2, DHTTYPE2);
const int LCD_COLS = 16;
const int LCD_ROWS = 4;
// Define variables
float hum = 0.0;
float hum2 = 0.0;
float temp = 0.0;
float temp2 = 0.0;
hum = dht1.readHumidity(); //
temp = dht1.readTemperature();
What happens when you swap the sensors?
Why all the global variables?
Please remember to use code tags when posting code.
We badly need our help.
June 2, 2021, 10:01am
Sorry im new to this forum please bear with me
June 2, 2021, 10:02am
I swapped sensors and tried swapping pins still the same results
I suggest you ditch the LCD and concentrate on just using Serial prints to debug the sensors.
@dave30, your topic has been moved to a more suitable location on the forum.
Can you please read
How to get the best out of this forum (again?) and apply the code tags as described.
Second time I've seen this one today!
(Must've been asleep earlier,sorry)
To add code please click this link;
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us.
The people who try to help with your pro…
Can I suggest you read ALL your sensor values at the start of the loop and store them as variables.
Then use those variables in the rest of your code.
In other words take a snapshot of your inputs and use those.
This will save all the
etc all over your code.
June 2, 2021, 12:39pm
I will if I ever use this forum again. Thanks for correcting
June 3, 2021, 12:51pm
Update: Both 2 sensors are working! It just lacks power because I used 5V supply. Thanks for your help guys.
October 1, 2021, 12:51pm
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.