Hilfe Bekomme die real time clock nicht ans laufen.

Hallo leute ich bekomme meine RTC nicht ans laufen ich habe verschidene programmierungen versucht.
ich habe mir das RTC bord selbergebaut. DS1307 mit Qwarz und Knopfzelle.
Wie kann ich sie starten und einstellen.
habe immer nur 165/165/165 usw stehen.
ausgabe an ein Lcd display 16x2 seriel.

danke euch schonmal

Ein bisschen Programmcode oder eine Schaltung wäre toll... dann müssten wir nicht im trüben fischen.

Mal ehrlich Jungs und Mädels - wie stellt ihr euch das vor?
Q: "hilfe!!! xyz funktioniert nicht!!!! wieso?" A: "kein Problem - liegt 100% an abc..."

Falls wir alle Gedankenleser wären könnte es so funktionieren...

Hallo,

ich würd mal darauf tippen, daß mit der I2C-Verbindung etwas nicht funktioniert.
Vielleicht ist nur ein Kabel locker. Oder es gibt eine kalte Lötstelle.
Probier mal mit einem I2C-Scanner-Sketch, ob die Uhr erreichbar ist.

Gruß
Reinhard

Ich bekomme den scaner auch nicht ans laufen

/**

*/

#include "Wire.h"
#include <avr/io.h>
extern "C" {
#include "utility/twi.h" // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr,
void(*callback)(byte address, byte result) )
{
byte rc;
byte data = 0; // not used, just an address to feed to twi_writeTo()
for( byte addr = from_addr; addr <= to_addr; addr++ ) {
rc = twi_writeTo(addr, &data, 0, 1); da schreibt das prog immer "at this point in file"
if(rc==0) callback( addr, rc );
}
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
Serial.print("addr: ");
Serial.print(addr,DEC);
Serial.println( (result==0) ? " found!":" ");
// Serial.print( (addr%4) ? "\t":"\n");
}

byte start_address = 1;
byte end_address = 127;

// standard Arduino setup()
void setup()
{
DDRC|=_BV(2) |_BV(3);
PORTC |=_BV(3);
Wire.begin();

Serial.begin(19200);
Serial.println("\nI2CScanner ready!");

Serial.print("starting scanning of I2C bus from ");
Serial.print(start_address,DEC);
Serial.print(" to ");
Serial.print(end_address,DEC);
Serial.println("...");

// start the scan, will call "scanFunc()" on result from each address
scanI2CBus( start_address, end_address, scanFunc );

Serial.println("\ndone");

}

// standard Arduino loop()
void loop()
{
// Nothing to do here, so we'll just blink the built-in LED
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);
}

Laut Bild hast Du den Minus-Pol der Batterie an die +5V des Arduino gehängt.....

Warum nimmst du A4 und A5 , wenn dein MEGA extra PIns mit SDA und SCL beschriftet hat (20, 21)

Oder warum nimmst du keinen UNO :wink:

Achso es ist ein mega 2560

So hier das prog:

// DS1307_LCD (C)2010 Henning Karlsen
// web: Electronics - Henning Karlsen
//
// A quick demo of how to use my DS1307-library to make a quick
// clock using a DS1307 and a 16x2 LCD.
//
// I assume you know how to connect the DS1307 and LCD.
// DS1302: SDA pin -> Arduino Digital 4
// SCL pin -> Arduino Digital 5
// LCD: DB7 -> Arduino Digital 6
// DB6 -> Arduino Digital 7
// DB5 -> Arduino Digital 8
// DB4 -> Arduino Digital 9
// E -> Arduino Digital 10
// RS -> Arduino Digital 11

#include <LiquidCrystal.h>
#include <DS1307.h>

// Init the DS1307
DS1307 rtc(4, 5);

DS1307_LCD:21: error: 'DS1307' does not name a type
DS1307_LCD.pde: In function 'void setup()':
DS1307_LCD:29: error: 'rtc' was not declared in this scope
DS1307_LCD:35: error: 'SUNDAY' was not declared in this scope
DS1307_LCD:40: error: 'SQW_RATE_1' was not declared in this scope
DS1307_LCD.pde: In function 'void loop()':
DS1307_LCD:48: error: 'rtc' was not declared in this scope
DS1307_LCD:52: error: 'FORMAT_SHORT' was not declared in this scope

// Init the LCD
LiquidCrystal lcd(11, 10, 9, 8, 7, 6);

void setup()
{
// Set the clock to run-mode
rtc.halt(false);

// Setup LCD to 16x2 characters
lcd.begin(16, 2);

// The following lines can be commented out to use the values already stored in the DS1307
rtc.setDOW(SUNDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(3, 10, 2010); // Set the date to October 3th, 2010

// Set SQW/Out rate to 1Hz, and enable SQW
rtc.setSQWRate(SQW_RATE_1);
rtc.enableSQW(true);
}

void loop()
{
// Display time centered on the upper line
lcd.setCursor(4, 0);
lcd.print(rtc.getTimeStr());

// Display abbreviated Day-of-Week in the lower left corner
lcd.setCursor(0, 1);
lcd.print(rtc.getDOWStr(FORMAT_SHORT));

// Display date in the lower right corner
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());

// Wait one second before repeating :slight_smile:
delay (1000);
}

oh war ein fehler in der zeichnung
habe jetzt 4 5 auf 20 21 gelegt muss ich was im prog ändern??

habe nur ein mega.

probier mal das";" bei " DS1307 rtc(4, 5); " wegzulassen
Wahrscheinlich mußt Du auch das (4,5) in (20,21) umändern.
Normalerweise werden die jeweiligen I2C-Pins automatisch je nach Modell verwendet, aber hier wohl nicht.....

Hast Du den I2C-Scanner schon ausprobiert?

den scanner den ich habe bekomme ich nicht ans laufen.

ok versuche ich mal

ne weglassen geht nicht dakommt auch sofort ne neue fehler meldung

und ändern auch nicht

http://playground.arduino.cc/Main/I2cScanner

PS.: vielleicht sollte es auch nur "DS1307 rtc" heissen

Hat die Bibiothek die Du verwendest keine Beispiele?
Es ist nicht notwendig die Pins anzugeben weil diese automatisch erkannt werden (in Funktion des ausgesuchten Boards in IDE).
Grüße Uwe.

Ich verwende die DS1307new/ ZIP mit dem Mega. Die Pins sind 20 und 21, nur zum anschließen, im Code gehts automatisch!

Damit gehts:

#include <DS1307new.h>
#include "Wire.h"

DS1307new rtc();     

  RTC.getTime();
  Serial.print("RTC date: ");
  mon_print_date(RTC.year, RTC.month, RTC.day);
  Serial.print(" ");
  Serial.print(wd[RTC.dow]);
  Serial.print("  time: ");
  mon_print_time(RTC.hour, RTC.minute, RTC.second);
  Serial.println(""); 
  Serial.print(RTC.cdn, DEC);
  Serial.print(" days or ");
  Serial.print(RTC.time2000, DEC);
  Serial.println(" seconds since 2000-01-01 00:00:00");

Doch uwe aber die haben alle den gleichen fehler

Das von mde110 geht leider auch nicht da kommt

sketch_jan14a:1: error: function definition does not declare parameters
In file included from sketch_jan14a.ino:4:
C:\Users\Dominic\Documents\Arduino\arduino-1.0.3\libraries\Wire/Wire.h:76: error: 'TwoWire' does not name a type
sketch_jan14a:6: error: 'DS1307new' does not name a type
sketch_jan14a:8: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:9: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:10: error: expected constructor, destructor, or type conversion before '(' token
sketch_jan14a:11: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:12: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:13: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:14: error: expected constructor, destructor, or type conversion before '(' token
sketch_jan14a:15: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:16: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:17: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:18: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan14a:19: error: expected constructor, destructor, or type conversion before '.' token

So der scanner hat was gefunden

Schau mal hier nach:
https://github.com/watterott/mSD-Shield/downloads

Im Packet ist eine DS1307-Library und ein Beispiel.
Eventuell mußt Du noch die Baud-Rate (für serial) anpassen.

Mit dem weißt Du mal, obs an der Hard- oder an der Software liegt...

Gruß
Reinhard

PS.: Zum Testen einfach alle gelieferten Libraries reinhauen

schilli84:
So der scanner hat was gefunden

Welche Adressen?

ok das geht dan kommt:

Init Display...
Init RTC...

Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85
Date: 165.165.2165
Time: 165:165:85

im serial monitor