Hello,
I'm trying to write a program that stores a timestamp (in unixtime format) on the arduino EEPROM when a wicking event happens. I used EEPROM.put and EEPROM.get to write and read the timestamp from the EEPROM and so far the serial monitor displays the correct value. However, when I try to read the EEPROM with avrdude through cmd, I get gibberish and an obviously wrong Hexadecimal values. What am I missing here?
Here is my entire code:
#include <Wire.h>
#include "RTClib.h"
#include <EEPROM.h>
RTC_DS3231 rtc;
int probeValue;
int address = 0;
void setup() {
Serial.begin(9600);
delay (3000); // 3 sec delay for console opening
Wire.begin();
if (! rtc.begin())
{
Serial.println("RTC not connected. Double check connection.");
while (1);
}
if(rtc.lostPower())
{
Serial.println ("Adjusting RTC time...");
rtc.adjust(DateTime(F(__DATE__),F(__TIME__))); // Adjusts the RTC time to the time and date the sketch was compiled
}
}
void loop() {
DateTime now = rtc.now();
probeValue = analogRead(A0);
float voltage = probeValue*(5.0/1023.0);
Serial.println (voltage);
delay (20);
/*Recording the TimeStamp to the EEPROM - triggered by wicking*/
if (voltage > 0.06)
{
Serial.println ("Timestamp Taken at");
Serial.print (now.unixtime());
Serial.print (" seconds");
Serial.println(" since midnight of 1/1/1970");
Serial.println("which in Human Readable date and time is");
Serial.print(now.year());
Serial.print("/");
Serial.print(now.month());
Serial.print("/");
Serial.print(now.day());
Serial.print(" ");
Serial.print(now.hour());
Serial.print(":");
Serial.print(now.minute());
Serial.print(":");
Serial.println(now.second());
Serial.println(" ");
unsigned long timestamp = {now.unixtime()};
Serial.println("writing TimeStamp (in unixtime) to the EEPROM...");
EEPROM.put(address, timestamp);
delay(2000);
Serial.println(" ");
Serial.println("verifying TimeStamp...");
Serial.println(EEPROM.get(address, timestamp));
while(1);
}
else
{Serial.println ("Waiting for sample to be taken.");
delay(5000);
return;
}
}
and this is what I get from the serial monitor:
vs. what I get from cmd:
Does anyone has any idea what's going on?