Clock With Thermometer Using Arduino, I2c 16x2 LCD, DS1307 RTC and DHT11 Sensor. - Instructables
Clock With Thermometer Using Arduino, I2c 16x2 LCD, DS1307 RTC and DHT11 Sensor. - Instructables
As you can see the RTC is homemade because I had a DS1307 chip and a battery extracted from an
old german electronic cash registering device.
So the connections are very simple:
The RTC and the i2c LCD are connected to A4 pin (SDA) and A5(SCL) and DHT11 sensor is connected
to D2 pin. DHT11 has 4 pins, but only 3 are actually used. First pin is Vcc, the second is for data and
the forth pin is for ground. As I said, connect data pin of the sensor to D2 on Arduino.
Now, the hardest part: the code. !!!DOWNLOAD THE ORIGINAL SKETCH FROM HERE!!!
I've tried some sketches I've found on internet, but there were alot of errors caused by incompatible
libraries and so on. I managed to build a code made from parts of other codes and it's working like a
charm now. There is a single problem though. You can find in the sketch a bit of code for displaying
first 3 letters of the week day, but for some reason it doesn't work. Instead of those letters it shows
some unknown characters and it's pretty ugly. I suspect that is a problem caused by i2c
communication because in standard connection (4bits) it works without problems.
________________________________________________________________________________________________
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD I2C address
dht11 DHT11;
setSyncProvider(RTC.get);
lcd.setCursor(9, 1);
lcd.write(2);
lcd.setCursor(11, 1);
lcd.print((float)DHT11.humidity, 0);
lcd.print("%");
delay(2000);
void data_si_ora()
{
tmElements_t tm;
(RTC.read(tm));
lcd.setCursor(0, 0);
afisare2cifre(tm.Hour);
lcd.print(":");
afisare2cifre(tm.Minute);
lcd.setCursor(7,0);
afisare2cifre(tm.Day);
lcd.print(" ");
lcd.print(tm.Month[luni]);
lcd.print(" ");
lcd.print(tmYearToCalendar(tm.Year)-2000);
// lcd.setCursor(12,1); // this code is used for displaying day of the week
// lcd.print(tm.Wday[zile-2]); //it's disabled because for some reason it doesn't work on i2c display
}
void afisare2cifre(int numar) { //this adds a 0 before single digit numbers
if (numar >= 0 && numar < 10) {
lcd.write('0');
}
lcd.print(numar);
}
/* ( THE END ) */
____________________________________________________________________________________________________