RTC - Hello from Greece

hello guys!! I am new arduino geek 8) and I have a problem…
I bought arduino uno r3 + ds1307 +dht22 _ lcd 20x4 i2c
well I want to make a weather station
my code is

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include “RTClib.h”
#include <DHT22.h>

#define BACKLIGHT_PIN 3

#define DHT22_PIN 2

LiquidCrystal_I2C lcd(0x27, 2,1,0,4,5,6,7);

RTC_DS1307 RTC;

DHT22 myDHT22(DHT22_PIN);

byte thermometro[8] = //icon for termometer
{
B00100,
B01010,
B01010,
B01110,
B01110,
B11111,
B11111,
B01110
};

byte igrasia[8] = //icon for water droplet
{
B00100,
B00100,
B01010,
B01010,
B10001,
B10001,
B10001,
B01110,
};

void setup(void)
{
Wire.begin();
lcd.backlight();
lcd.begin(20,4);
lcd.createChar(1,thermometro);
lcd.createChar(2,igrasia);
lcd.home();
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
RTC.begin();
RTC.adjust(DateTime(DATE, TIME));
delay (3000);
}

void loop(void)
{
DateTime now = RTC.now();

DHT22_ERROR_t errorCode;
errorCode = myDHT22.readData();
switch(errorCode)
case DHT_ERROR_NONE:

lcd.setCursor(0,0);
lcd.print(“Weather Station”);
lcd.setCursor(0,1);
printDigits(now.hour());
lcd.print(":");
printDigits(now.minute());
lcd.print(":");
printDigits(now.second());
delay(1000);
lcd.setCursor(0,2);
int dayOfWeek = now.dayOfWeek();
switch(dayOfWeek){
case 1:
lcd.print(“Monday”);
break;
case 2:
lcd.print(“Tuesday”);
break;
case 3:
lcd.print(“Wednesday”);
break;
case 4:
lcd.print(“Thursday”);
break;
case 5:
lcd.print(“Friday”);
break;
case 6:
lcd.print(“Saturday”);
break;
case 7:
lcd.print(“Sunday”);
break;
delay(1000);
}
lcd.setCursor(10,2);
lcd.print(now.day(), DEC);
lcd.print(’/’);
lcd.print(now.month(), DEC);
lcd.print(’/’);
lcd.print(now.year(), DEC);
lcd.setCursor(0,3);
lcd.write(1);
lcd.setCursor(2,3);
lcd.print(myDHT22.getTemperatureC());
lcd.print((char)223);
lcd.print(“C”);
lcd.setCursor(12,3);
lcd.write(2);
lcd.setCursor(14,3);
lcd.print(myDHT22.getHumidity());
lcd.print("%");

}
void printDigits(int digits){
if(digits < 10)
lcd.print(‘0’);
lcd.print(digits);
}

but the ds1307 (it has battery 3V… ) it does not keep time I mean just I remove usb cable it losses the real time… :frowning: what happens? my code is wrong? Sorry for my English… :slight_smile:


Yes, is your code. Remove the line:

RTC.adjust(DateTime(__DATE__, __TIME__));

and you are ready.

I think I don't need to explain what you are doing wrong.

ok thank you!! :slight_smile:

yes it works!! thank you again!! Now, because in Greece the time changes two times in year I need extra buttons for it? or it changes automatic? for example 29 March 2015 in Greece the time changes forward an hour...

I think it don't changes autocratically, but you can program it easily.

luisilva:
I think it don't changes autocratically, but you can program it easily.

No changes each time the same day... each time is different... and it easily? Where can I find examples for it?

As for setting the time, please see my post:

By the way, I've read that some of these displays can handle Greek characters. What model is your display?
Also, don't the Greeks use a comma instead of a decimal point?

odometer:
As for setting the time, please see my post:
http://forum.arduino.cc/index.php?topic=53422.msg2031756#msg2031756

By the way, I've read that some of these displays can handle Greek characters. What model is your display?
Also, don't the Greeks use a comma instead of a decimal point?

you dont think good... just the time in Greece +1 now... but in summer is +2... because each March the time forward an hour and each October the time is go back an hour... :slight_smile:

It always changes the same day. The last Sunday of March and the last Sunday of October. That is called day saving light, check it:

luisilva:
It always changes the same day. The last Sunday of March and the last Sunday of October. That is called day saving light, check it:
http://en.wikipedia.org/wiki/Daylight_saving_time

Yes you are right!! but the last Sunday of March maybe is 27 or 28 or 29 or 30 or 31... There is code for it?

As for Daylight Saving Time (you call it Θερινή ώρα): I have written code for the American version of this.

I suppose I could modify it for the European version. But it would take some time for me to do. And at the moment, I don't have a free Arduino for testing.

odometer:
As for Daylight Saving Time (you call it Θερινή ώρα): I have written code for the American version of this.

I suppose I could modify it for the European version. But it would take some time for me to do. And at the moment, I don't have a free Arduino for testing.

ok thank you!! I try to find if there are libraries for Daylight Saving Time!!

Here is a link to a clock program I have written:

Part of the program takes care of (American) Daylight Saving Time automatically.
This program is way too complicated for your project, but you might find parts of it useful.

odometer:
Here is a link to a clock program I have written:
http://forum.arduino.cc/index.php?topic=180302.msg1336410#msg1336410

Part of the program takes care of (American) Daylight Saving Time automatically.
This program is way too complicated for your project, but you might find parts of it useful.

Yes, thank you but it is complicated… :slight_smile:

First of all I downloaded timezone-master... and now I see...

And I find this…

#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnesson
byte DOW,MTH,DATE,DST,HR;
void setup()
{
Serial.begin(9600);

byte dows,mnths,dts,DST,hrs;
RTC.stop();
RTC.set(DS1307_SEC,20); //set the seconds
RTC.set(DS1307_MIN,59); //set the minutes
RTC.set(DS1307_HR,2); //set the hours
RTC.set(DS1307_DOW,1); //set the day of the week
RTC.set(DS1307_DATE,1); //set the date
RTC.set(DS1307_MTH,4); //set the month
RTC.set(DS1307_YR,12); //set the year
RTC.start();

}

void loop()

{

// Daylight savings until 2020 for New Zealand
// Daylight savings changes forward from 2:00to 3:00on the last Sunday in September,
// and changes back from 3:00to 2:00 on the first Sunday of April
// so days between 25 and 31 in September and 1 to 6 in April is covered by this code
if (DOW == 1 && MTH == 4 || MTH == 9 && HR <1 && HR >4) // DST schedule for next ten years to october 2019 condition start in march or october
{
** DST = digitalRead(1060); // read Previous DST status,**
** if (DOW == 1 && MTH == 4 && DATE >= 1 && DATE <=6 && HR == 2 && DST==0) // time forward from 02:00 to 03:00 in march if DSt status ==0 else don’t change time!**
** {**
** RTC.set(DS1307_HR,3); //set the hours to 02:00 // when status was ZERO (0) then change time from 02:00 to 03:00 hr**
** digitalWrite(1060, 1); // daylight saving flag // Write DST statusflag to ONE(1) to prevent multiple changes in hours, only for once in March**
** }**
** if (DOW == 1 && MTH == 9 && DATE >= 25 && DATE <=31 && HR == 3 && DST==1) // time backwards from 3:00 to 02:00 in october if DSt status ==1 else don’t change time!**
** {**
** RTC.set(DS1307_HR,2); //set the hours to 03:00
_
digitalWrite(1060, 0); // daylight saving flag // Write DST statusflag to ZERO to prevent multiple changes in hours, only for once in October**_
** }**
}

{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" “); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print(”/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();

delay(1000);

}
}

I think that this code is useful… what you say?

Yes. It seem that is what you are looking for. You only need to change the days for your country.

luisilva:
Yes. It seem that is what you are looking for. You only need to change the days for your country.

ok I try to fix for my code! :slight_smile: and #include <WProgram.h> now is #include <Arduino.h> for version 1.0+ right? :slight_smile:

Guys help again because when changes the day for example is wednesday to thursday then thursdayy... why???

I don't have time to help much, but I'll try:

You need to fill in the space after the word "Thursday". Make it "Thursday " (with a space after the word).