Eğerki projenizde ds1302 modül kullanmak isterseniz bazı sıkıntılarla karşılaşabilmeniz olasıdır. Bunun sebepleri elinizde bulunan hazır modüldeki kalitesiz malzeme kullanımından olabilir. Örneğin kullanılan kristal vb.
Eğerki kodunuzu yazıp çalıştırdığınızda VCC=5V bağlı iken, saçma sapan değerler okuyorsanız ve VCC girişini söküp pil üzerinden(3.3V) çalıştırdığınızda sorun yaşamıyorsanız çözüm basit.
Çözüm : I/O veya diğer adıyla DAT ucuna 1K’lık direnç bağlamanız yeterli olacaktır.
Aşağıda örnek kod yer almaktadır.
———————————————————————————————————————————————————————
If you want to use DS1302 module in your project, you will get some errors like reading absurd values. Some things can cause this. For example;
You connected VCC pin to the 5V and started project. But you are reading foolish values. And then you removed Vcc pin from 5V. Start project. Now you are getting right values.
Solution is : Connect 1K resistor to the I/O(Dat) pin.
Here is the sample code.
DS1302 kütüphanesini indirmek için adres: http://www.rinkydinkelectronics.com/download.php?f=DS1302.zip veya buraya tıklayıp indirebilirsiniz.
You can download DS1302 library from this address: http://www.rinkydinkelectronics.com/download.php?f=DS1302.zip or clicking to here.
// DS1302_Serial_Easy
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS1302-library to
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1302.
// DS1302: CE pin -> Arduino Digital 3
// I/O pin -> Arduino Digital 4
// SCLK pin -> Arduino Digital 5#include <DS1302.h>
// Init the DS1302
DS1302 rtc(3,4, 5);// Init a Time-data structure
Time t;void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);// Setup Serial connection
Serial.begin(9600);// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(27,11, 2016); // Set the date to August 6th, 2010
rtc.setDOW(7);
}void loop()
{
// Get data from the DS1302
t = rtc.getTime();// Send date over serial connection
Serial.print(“Today is the “);
Serial.print(t.date, DEC);
Serial.print(“. day of “);
Serial.print(rtc.getMonthStr());
Serial.print(” in the year “);
Serial.print(t.year, DEC);
Serial.println(“.”);// Send Day-of-Week and time
Serial.print(“It is the “);
Serial.print(t.dow, DEC);
Serial.print(“. day of the week (counting monday as the 1th), and it has passed “);
Serial.print(t.hour, DEC);
Serial.print(” hour(s), “);
Serial.print(t.min, DEC);
Serial.print(” minute(s) and “);
Serial.print(t.sec, DEC);
Serial.println(” second(s) since midnight.”);// Send a divider for readability
Serial.println(” – – – – – – – – – – – – – – – – – – – – -“);// Wait one second before repeating 🙂
delay (2000);
}
Kaynak : http://forum.arduino.cc/index.php?topic=168361.0
Source : http://forum.arduino.cc/index.php?topic=168361.0
Thanks to Snejq.