Aloa,
Ja ich weis es gibt genug Topics zu diesem Thema aber (jetzt bitte weiterlesen)
Vorneweg:
Ich bin kein Programmierer oder hab sonst irgendwie groß Ahnung davon.
Ich habe es geschafft ein Programm zu schreiben das mir die Uhrzeit auf einem Display anzeigt
Sketch:
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 3
#define DHTTYPE DHT11
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <DS3231.h>
#include <LiquidCrystal.h>
DHT dht(DHTPIN, DHTTYPE);
int checkDHT11(void);
DS3231 rtc(SDA, SCL);
LiquidCrystal lcd(1, 2, 5, 6, 7, 8); //Aktiviert die Kanäle für das Display. Parameter: (rs, enable, d4, d5, d6, d7)
void setup() {
lcd.begin(16,2); //Aktiviert das Display und legt die Größe des LC´s fest
rtc.begin(); //Aktiviert das Uhrmodul
}
void loop() {
lcd.setCursor(5,0); //Plaziert Cursor auf Feld 5 Reihe 0 ( 1 )
//lcd.print("Zeit:"); //Ausgabe "Zeit:" - Derzeit ausgeblendet!
lcd.print(rtc.getTimeStr()); //Anzeige Uhrzeit
lcd.setCursor(10,0); //Plaziert Cursor auf Feld 10 Reihe 0 ( 1 )
lcd.print(" "); //Ausgabe von Leerzeichen zum Überschreiben von Kommastellen der Uhr - Sekunden werden ausgeblendet
delay(1000); //Aktualisierungsintervall 1 Sek. (1000 = 1 Sek.)
int h = dht.readHumidity();
lcd.setCursor(3,1); //Plaziert Cursor auf Feld 3 Reihe 1 ( 2 )
lcd.print(h); //Anzeige für Luftfeuchtigkeit
lcd.print("%"); //Ausgabe %
lcd.setCursor(9,1); //Plaziert Cursor auf Feld 9 Reihe 1 ( 2 )
lcd.print(rtc.getTemp()); //Anzeige Temperatur
lcd.setCursor(11,1); //Plaziert Cursor auf Feld 11 Reihe 1 ( 2 )
lcd.print("\xDF"); //Zeigt ° an (Grad Celsius)
lcd.print("C "); //Zeigt "C" mit Leerzeichen an, zum Überschreiben der Kommastellen der Temperatur
delay(10000); //Aktualisierungsintervall 10 Sek. (1000 = 1 Sek.)
}
Allerdings bekomme ich es nicht hin da eine Sommerzeit rein zu prügeln... Schon zig Themen gelesen wo es um das DS3231 Modul geht oder auch um andere.
Ich verstehe einfach nicht wo ich den Code rein kopieren muss damit er mir im Sommer +1 bei den Stunden rechnet.
Meine Librarie ist die DS32331 von Arduino. Inhalt meiner DS3231.h
/*
DS3231.cpp - Arduino/chipKit library support for the DS3231 I2C Real-Time Clock
Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
This library has been made to easily interface and use the DS3231 RTC with
an Arduino or chipKit.
You can find the latest version of the library at
http://www.RinkyDinkElectronics.com/
This library is free software; you can redistribute it and/or
modify it under the terms of the CC BY-NC-SA 3.0 license.
Please see the included documents for further information.
Commercial use of this library requires you to buy a license that
will allow commercial use. This includes using the library,
modified or not, as a tool to sell products.
The license applies to all part of the library including the
examples and tools supplied with the library.
*/
#ifndef DS3231_h
#define DS3231_h
#if defined(__AVR__)
#include "Arduino.h"
#include "hardware/avr/HW_AVR_defines.h"
#elif defined(__PIC32MX__)
#include "WProgram.h"
#include "hardware/pic32/HW_PIC32_defines.h"
#elif defined(__arm__)
#include "Arduino.h"
#include "hardware/arm/HW_ARM_defines.h"
#endif
#define DS3231_ADDR_R 0xD1
#define DS3231_ADDR_W 0xD0
#define DS3231_ADDR 0x68
#define FORMAT_SHORT 1
#define FORMAT_LONG 2
#define FORMAT_LITTLEENDIAN 1
#define FORMAT_BIGENDIAN 2
#define FORMAT_MIDDLEENDIAN 3
#define MONDAY 1
#define TUESDAY 2
#define WEDNESDAY 3
#define THURSDAY 4
#define FRIDAY 5
#define SATURDAY 6
#define SUNDAY 7
#define SQW_RATE_1 0
#define SQW_RATE_1K 1
#define SQW_RATE_4K 2
#define SQW_RATE_8K 3
#define OUTPUT_SQW 0
#define OUTPUT_INT 1
class Time
{
public:
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t date;
uint8_t mon;
uint16_t year;
uint8_t dow;
Time();
};
class DS3231
{
public:
DS3231(uint8_t data_pin, uint8_t sclk_pin);
void begin();
Time getTime();
void setTime(uint8_t hour, uint8_t min, uint8_t sec);
void setDate(uint8_t date, uint8_t mon, uint16_t year);
void setDOW();
void setDOW(uint8_t dow);
char *getTimeStr(uint8_t format=FORMAT_LONG);
char *getDateStr(uint8_t slformat=FORMAT_LONG, uint8_t eformat=FORMAT_LITTLEENDIAN, char divider='.');
char *getDOWStr(uint8_t format=FORMAT_LONG);
char *getMonthStr(uint8_t format=FORMAT_LONG);
long getUnixTime(Time t);
void enable32KHz(bool enable);
void setOutput(byte enable);
void setSQWRate(int rate);
float getTemp();
private:
uint8_t _scl_pin;
uint8_t _sda_pin;
uint8_t _burstArray[7];
boolean _use_hw;
void _sendStart(byte addr);
void _sendStop();
void _sendAck();
void _sendNack();
void _waitForAck();
uint8_t _readByte();
void _writeByte(uint8_t value);
void _burstRead();
uint8_t _readRegister(uint8_t reg);
void _writeRegister(uint8_t reg, uint8_t value);
uint8_t _decode(uint8_t value);
uint8_t _decodeH(uint8_t value);
uint8_t _decodeY(uint8_t value);
uint8_t _encode(uint8_t vaule);
#if defined(__arm__)
Twi *twi;
#endif
};
#endif
Vorab schonmal Danke für eure Unterstützung.
Gelesen habe ich u.a:
https://forum.arduino.cc/index.php?topic=228063.15
http://forum.arduino.cc/index.php?topic=154768.msg1163549#msg1163549
LG
Ramset