Closed theOracle1984 closed 5 years ago
okay i solved it :)
int val ; //LCD add
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
void setup() { Serial.begin(9600); pinMode(7, OUTPUT); //relay1 //LCD add lcd.begin(16,2);
/////////Uncomment both lines below when you want to set the time /////////AFTER SETTING TIME COMMENT the lines. //setTime(16, 50, 00, 13, 01, 2019);//Hours / minutes / second / day of month / month / year //RTC.set(now());
setSyncProvider(RTC.get); // the function to get the time from the RTC if (timeStatus() != timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); }
void loop() { digitalClockDisplay(); AutomaticProgram();
}
void AutomaticProgram() { //we are using hour as a value the rest is ignored. val = (hour()); //Bloei/Night - Bloei/Nacht between 19:00 and 07:00 aan, rest uit if ((19 == val)) { digitalWrite(7, HIGH); } else if (val == 7) { digitalWrite(7, LOW); } else { digitalWrite(7, LOW); } }
void digitalClockDisplay(void) { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(' '); Serial.print(day()); Serial.print(' '); Serial.print(month()); Serial.print(' '); Serial.print(year()); Serial.println(); lcd.backlight(); lcd.setCursor(0, 0); //hour if (hour() < 10) { lcd.print("0"); lcd.print(hour()); lcd.print(":"); } else if (hour() > 9) { lcd.print(hour()); lcd.print(":"); }
//minute
if (minute() < 10)
{
lcd.print("0");
lcd.print(minute());
lcd.print(":");
}
else if (minute() > 9)
{
lcd.print(minute());
lcd.print(":");
}
//second
if (second() < 10)
{
lcd.print("0");
lcd.print(second());
}
else if (second() > 9)
{
lcd.print(second());
}
//lege ruimte LCD
lcd.print(" ");
//temperate add
lcd.print(RTC.temperature());
lcd.print ("C");
//relay LDR add
lcd.setCursor(0, 1);
lcd.print("relay is:");
lcd.setCursor(12, 1);
lcd.print("Off");
}
void printDigits(int digits) { // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(':'); if (digits < 10) Serial.print('0'); Serial.print(digits); }
i just get the fahrenheit reading from th ds3231 RTC.temperature(); how do i convert it to Celsius with the " int t = RTC.temperature(); float celsius = t / 4.0; float fahrenheit = celsius * 9.0 / 5.0 + 32.0; " example?
Example here.
Thanks that’s great. I already saw that yes.. But how does it work? How do I implement it into code?
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
Van: Jack Christensen notifications@github.com Verzonden: Tuesday, January 29, 2019 5:48:52 PM Aan: JChristensen/DS3232RTC CC: theOracle1984; Author Onderwerp: Re: [JChristensen/DS3232RTC] DS3231-Arduino Uno_LCM1602lcd (#63)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/JChristensen/DS3232RTC/issues/63#issuecomment-458615755, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AiqB1FQEpQLwTk85bYdGaKClkoDlgWPHks5vIHt0gaJpZM4aXfCb.
Note that the RTC.temperature() function returns the temperature in degrees Celsius times four. To implement, just copy and paste these three lines into your code:
int t = RTC.temperature();
float celsius = t / 4.0;
float fahrenheit = celsius * 9.0 / 5.0 + 32.0;
This is a great way work with the ds3231 and a Arduino Uno. I connected a lcm1602 lcd to the Arduino (connected to 0x3F) now in my code i need to write time to the lcd..
include
include
include
int val ; //LCD add
include
include
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
void setup() { Serial.begin(9600); pinMode(7, OUTPUT); //relay1 //LCD add lcd.begin(16,2);
/////////Uncomment both lines below when you want to set the time /////////AFTER SETTING TIME COMMENT the lines. //setTime(16, 50, 00, 13, 01, 2019);//Hours / minutes / second / day of month / month / year //RTC.set(now());
setSyncProvider(RTC.get); // the function to get the time from the RTC if (timeStatus() != timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); }
void loop() { digitalClockDisplay(); AutomaticProgram();
}
void AutomaticProgram() { //we are using hour as a value the rest is ignored. val = (hour()); //Bloei/Night - Bloei/Nacht between 19:00 and 07:00 aan, rest uit if ((19 == val)) { digitalWrite(7, HIGH); } else if (val == 7) { digitalWrite(7, LOW); } else { digitalWrite(7, LOW); } }
void digitalClockDisplay(void) { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(' '); Serial.print(day()); Serial.print(' '); Serial.print(month()); Serial.print(' '); Serial.print(year()); Serial.println(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print(RTC.readRTC); lcd.setCursor(0, 1); lcd.print(RTC.temperature()); lcd.setCursor(12, 1); lcd.print(""); }
void printDigits(int digits) { // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(':'); if (digits < 10) Serial.print('0'); Serial.print(digits); }
i use this code to get the lcd to work.. the lcd.print(RTC.readRTC); and lcd.print(RTC.temperature()); dont really work. What should i put in the lcd.print( ) to print the time date year (and maybe temperature?)