Ok, Time = 13:18:08, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:09, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:10, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:11, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:12, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:13, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:14, Date (D/M/Y) = 19/7/2017:0
Ok, Time = 13:18:15, Date (D/M/Y) = 19/7/2017:0
The DS1307 library reads the storage register (0x03) in the rtc chip to get the weekday. What is the setting in that register? Here's some test code to read and write the dow register.
// DS1307 I2C NVRAM test
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
#define startRegister 0x00
#define endRegister 0x07
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.print("Register");
Serial.print("\t");
Serial.println("Bit Values");
Serial.println();
//write dow register use value 0-6
// writeNVRAM(0x03,B00000100);//day4
for (int a = startRegister; a <= endRegister; a++)
{
byte b=readNVRAM(a);
Serial.print("0X");
if(a<16)
Serial.print("0");
Serial.print(a, HEX);
Serial.print("\t");
Serial.print("\t");
for (int i = 7; i >= 0; i-- )
{
Serial.print((b >> i) & 0X01);//shift and select first bit, no speed advantage
}
Serial.println();
}
}
void writeNVRAM(byte location, byte data)
// writes data to DS1307 NVRAM location
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(location);
Wire.write(data);
Wire.endTransmission();
}
byte readNVRAM(byte location)//// reads data from DS1307 NVRAM location
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(location);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 1);//only 1 byte, does not need wire.available
return Wire.read();
}
void loop(){
}