You have the number stored using data type int, yes?
No I used Byte which was what the example showed. It seemed right should I change it?
I will post the trimmed down example I am working with.
/* Q(1-2) - (Q1) Memory initialization (Q2) RTC - Memory Dump
*/
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 // This is the I2C address
#define I2C_WRITE Wire.write
#define I2C_READ Wire.read
// Global Variables
int command = 0; // This is the command char, in ascii form, sent from the serial port
int i;
long previousMillis = 0; // will store last time Temp was updated
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte test;
byte zero;
byte highbyte;
byte lowbyte;
byte state;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
void setup() {
Wire.begin();
Serial.begin(57600);
zero=0x00;
}
void loop() {
if (Serial.available()) { // Look for char in serial que and process if found
command = Serial.read();
if (command == 81 || command == 113) { //If command = "Qq" RTC1307 Memory Functions
delay(100);
if (Serial.available()) {
command = Serial.read();
if (command == 49) { //If command = "1" RTC1307 Initialize Memory - All Data will be set to
// 255 (0xff). Therefore 255 or 0 will be an invalid value.
Wire.beginTransmission(DS1307_I2C_ADDRESS); // 255 will be the init value and 0 will be considered
// an error that occurs when the RTC is in Battery mode.
Wire.endTransmission();
Wire.beginTransmission(DS1307_I2C_ADDRESS);
// load dummy values to read back
I2C_WRITE(0X08); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed.
I2C_WRITE(24);
I2C_WRITE(0X09); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed.
I2C_WRITE(52);
I2C_WRITE(0X0A); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed.
I2C_WRITE(200);
Wire.endTransmission();
Serial.println(": RTC1307 Initialized Memory");
}
else if (command == 50) { //If command = "2" RTC1307 Memory Dump
Serial.println(": RTC 1307 Dump Begin");
Wire.beginTransmission(DS1307_I2C_ADDRESS);
I2C_WRITE(0x08); // Set the register pointer to (0x08) to read first memory byte
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 1); // In this case only read one byte
state = Wire.read();
//Serial.println(": RTC 1307 Dump Begin");
Wire.beginTransmission(DS1307_I2C_ADDRESS);
I2C_WRITE(0x09); // Set the register pointer to (0x08) to read first memory byte
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 3); // In this case only read one by
highbyte
= Wire.read();
Wire.beginTransmission(DS1307_I2C_ADDRESS);
I2C_WRITE(0x20);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 32);
for (i = 32; i <= 63; i++) { //Register 32-63 - only 32 registers allowed per I2C connection
test = I2C_READ();
Serial.print(i);
Serial.print(": ");
Serial.print(test, DEC);
Serial.print(" : ");
Serial.println(test, HEX);
}
Serial.println(" RTC1307 Dump end");
}
}
}
Serial.print("Command: ");
Serial.println(command); // Echo command CHAR in ascii that was sent
}
command = 0; // reset command
delay(100);
}
//*****************************************************The End***********************