#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
int val;
int tempPin = 0;
RTC_DS1307 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the address if necessary
void setup() {
Serial.begin(9600);
lcd.init(); // Initialize the LCD display
lcd.backlight(); // Turn on the backlight
//lcd.noBacklight();//Turn off the backlight
Wire.begin(); // Initialize I2C bus
if (!rtc.begin()) {
Serial.println("RTC is not running!");
while (1);
}
if (!rtc.isrunning()) {
Serial.println("RTC is not initialized, setting time...");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
char date[11];
char time[9];
int sec = now.second();
if (sec == 0 || sec == 1 || sec == 2 || sec == 3 ){
tone(12,5000,100);
delay(100);
}
sprintf(date, "%02d-%02d-%04d", now.month(), now.day(), now.year());
sprintf(time, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
Serial.print(date);
Serial.print(" ");
Serial.print(time);
Serial.println();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(date);
lcd.setCursor(0, 1);
lcd.print(time);
//const float BETA = 3950;
//int analogValue = analogRead(A0);
//float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
val = analogRead(tempPin);
float mv = (val/1023.0)*5000;
float cel = mv/10;
lcd.setCursor(12, 0);
lcd.print("TEMP");
lcd.setCursor(12, 1);
lcd.print(cel);
lcd.setCursor(14, 1);
lcd.print("*C");
delay(1000);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
rtc1:GND
rtc1:5V
rtc1:SDA
rtc1:SCL
rtc1:SQW
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL
ntc1:GND
ntc1:VCC
ntc1:OUT
r1:1
r1:2