però è facile da implementare
- Codice: Seleziona tutto
temp = rtc.getTemperature();
temp = temp - 1,3;

temp = rtc.getTemperature();
temp = temp - 1,3;

dtostrf(rtc.getTemperature(),5,1,temp);dtostrf(rtc.getTemperature() - 1.3,5,1,temp);apollo17 ha scritto:Uscita 1 Hz su sqw
Wire.write(0x07); // indirizza il registro
Wire.write(B00010000); // scrive il valore
apollo17 ha scritto:sulla temperatura segna sempre +1,3 gradi in più, basterebbe togliere un grado


void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}#include <Wire.h> // for I2C communication
#include <LiquidCrystal_I2C.h> // for LCD
#include <RTClib.h> // for RTC
LiquidCrystal_I2C lcd(0x27, 20, 4); // create LCD with I2C address 0x27, 16 characters per line, 2 lines
RTC_DS3231 rtc; // create rtc for the DS3231 RTC module, address is fixed at 0x68
/*
function to update RTC time using user input
*/
void updateRTC()
{
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("Edit Mode...");
// ask user to enter new date and time
const char txt[6][15] = { "year [4-digit]", "month [1~12]", "day [1~31]",
"hours [0~23]", "minutes [0~59]", "seconds [0~59]"};
String str = "";
long newDate[6];
while (Serial.available()) {
Serial.read(); // clear serial buffer
}
for (int i = 0; i < 6; i++) {
Serial.print("Enter ");
Serial.print(txt[i]);
Serial.print(": ");
while (!Serial.available()) {
; // wait for user input
}
str = Serial.readString(); // read user input
newDate[i] = str.toInt(); // convert user input to number and save to array
Serial.println(newDate[i]); // show user input
}
// update RTC
rtc.adjust(DateTime(newDate[0], newDate[1], newDate[2], newDate[3], newDate[4], newDate[5]));
Serial.println("RTC Updated!");
}
/*
function to update LCD text
*/
void updateLCD()
{
pinMode(13, OUTPUT);
/*
create array to convert digit days to words:
0 = Sunday | 4 = Thursday
1 = Monday | 5 = Friday
2 = Tuesday | 6 = Saturday
3 = Wednesday |
*/
const char dayInWords[7][9] = {"domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato"};
/*
create array to convert digit months to words:
0 = [no use] |
1 = January | 6 = June
2 = February | 7 = July
3 = March | 8 = August
4 = April | 9 = September
5 = May | 10 = October
6 = June | 11 = November
7 = July | 12 = December
*/
const char monthInWords[13][4] = {" ", "gen", "Feb", "Mar", "Apr", "Mag", "Giu",
"Lug", "Ago", "Set", "Ott", "Nov", "Dic"};
// LEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
// get time and date from RTC and save in variables
DateTime rtcTime = rtc.now();
int hh = rtcTime.hour(); // nuova riga per 24 ore
int ss = rtcTime.second();
int mm = rtcTime.minute();
int DD = rtcTime.dayOfTheWeek();
int dd = rtcTime.day();
int MM = rtcTime.month();
int yyyy = rtcTime.year();
// move LCD cursor to upper-left position
lcd.setCursor(0, 0); // cursore no
lcd.print("Data:");
// print date in dd-MMM-yyyy format and day of week
lcd.setCursor(7, 0); // date sette spazi sx riga =0
if (dd < 10) lcd.print("0"); // add preceeding '0' if number is less than 10
lcd.print(dd);
lcd.print("-");
lcd.print(monthInWords[MM]);
lcd.print("-");
lcd.print(yyyy);
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.print(dayInWords[DD]);
// move LCD cursor to lower-left position
lcd.setCursor(0, 3);
lcd.print ("Ora :");
lcd.setCursor(7, 3); // test ok // print orario :primo valore sposta da sx a dx primo carattere sulla stessa riga /secondo valore sposta intera riga partendo da 0
//int hh = rtcTime.hour();
// print time in 12H format
if (hh < 10) lcd.print("0");
lcd.print(hh);
lcd.print(':');
if (mm < 10) lcd.print("0");
lcd.print(mm);
lcd.print(':');
if (ss < 10) lcd.print("0");
lcd.print(ss);
// if (rtcTime.isPM()) lcd.print(" PM"); // print AM/PM indication
// else lcd.print(" AM");
}
void setup()
{
Serial.begin(9600); // initialize serial
lcd.init(); // initialize lcd
lcd.backlight(); // switch-on lcd backlight
rtc.begin(); // initialize rtc
}
void loop()
{
updateLCD(); // update LCD text
lcd.setCursor(0,2); // TEMPERATURA TEMPERATURA
lcd.print(F("Temp: "));
char temp[6];
// dtostrf(rtc.getTemperature(),5,1,temp);
dtostrf(rtc.getTemperature() - 1.3,5,1,temp);
lcd.print(temp);
lcd.setCursor(12,2);
lcd.print(F("'C"));
if (Serial.available()) {
char input = Serial.read();
if (input == 'u') updateRTC(); // update RTC time
}
}Considera che l'RTC e' un componente che funzionando si scalda...
//void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
Visitano il forum: Nessuno e 15 ospiti