Is this a good solution: long loop, using eprom, counting up to 14 days?

Hi,
maybe there is somebody, who can verify my solution or give some advice.
I don't want to have a perfect solution nor want to add more hardware.
Unconfortably but safe way is okay.

My first arduino uno is running and that is very pleasing .. ;-)
But did I chose a good way?
What would I like to have?

A sum of minutes the sun is shining each day up to 14 days.
A table of 10 minute readouts/stores for one day
Sensor is analog , that is read periodically.
Connecting terminal / serial line and read the data stored in between.
manually reset at Monday 00:00 o'clock to hold the counters synchronously

what have I done?

Pseudo code for quick readers:
(fi means end if)

do
if sensorvalue > threshold sum++;
if (loopcounter=10)
eeprom.write (ecounter%144,sensorvalue/4);
if (ecounter%144=0) // turn to next day
datlog[day]=sum //RAM as 16 Bit
eeprom.write (offset+day, sum/4) // ROM, as backup , powerfailure, etc.
day++
clear_eeprom // only lower range, for daily readout
fi
ecounter++
loopcounter=0
write_all:to terminal()
fi

delay (301000 -runtime)
delay (30
1000) // because a single delay (60*1000) does not work
loopcount++
loop

My questions:
1.) writing every 10 Minutes to serial line, bute reading only once a day or mayvbe only once a week
2.) Begin is normally Monday 00:00 o'clock, then all counters are corresponding e.g. day=1 is monday, eeprom-address 1 is 00:10 o'clock ..... How to make any interaction to change counters in between?
3.) Backup Using the eeprom, because RAM is too few. Only get 8 Bit sums.
4.) Would love to get higher resolution : 14 days with 144 values each.
5.) EEprom is writeable for 100.000 times. Thats many years for my project?

/*
 Created by Carsten Moos
 based on:
 By David Cuartielles
 By Tom Igoe
 
 VERSION 0.63
 DATE: 25.04.2011
 READS one probe per Minute, counts 10 Minutes and stores to eeprom/SRAM
 
 Threshold = 12 (8Bit) ADU  ??
 */
#include <EEPROM.h>

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;        // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor, 10 Bit
int toggle=HIGH;      // to toggle LedPin on off

int count10=0;        // counts probes per loop
int sum=0;             // adds sensorvalue above threshold per loop
byte day=1;           // 1=Mo, 2=Tu, ... 7=Su, 8=Mo, 9=Tu, 14=Su

//2 byte datlog to SRAM;
int datlog[16];        // holds hourly solar counter
byte maxdat=16;     // max data to store, do not increase TTY will stop, holds 16 values
int countlog=0;        // counter for logged array-data, 0-15 , 

//main loop counter
int ecountlog=1;      // counter for eeprom log, 1 - 14*144  


void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
  clear_eeprom();
  Serial.begin(9600);
  
}
void clear_eeprom()
{
 int i;
 for ( i=1;i<=144;i++)
 {
   EEPROM.write(i,255);
 }
  
}

void write_status()
{
  Serial.print("Solarcounter by C.Moos, Version 0.63, 2011");
  Serial.println() ;
  Serial.println("Status:") ;
  Serial.print("count10: ") ;
  Serial.print(count10,DEC);
  Serial.println() ;
  Serial.print("ecountlog: ") ;
  Serial.print(ecountlog,DEC);
  Serial.println() ;
  Serial.print("sum: ") ;
  Serial.print(sum,DEC);
  Serial.println() ;
  Serial.print("day: ") ;
  Serial.print(day,DEC);
  Serial.println() ;
  Serial.println("----") ;
  Serial.println() ;
}
void write_eepromlog()
{
 int i;
 byte evalue;
 //Serial.begin(9600);
 //if (Serial.available())
 //{
  Serial.print("EEPROM 8 Bit data: Sensorvalues in ADU per 10 minutes");
  Serial.println() ; 
 for ( i=1;i<=144;i++)
 {
   Serial.print(i, DEC);
   Serial.print(";");   
   evalue=EEPROM.read(i);  
   Serial.print(evalue, DEC);
   Serial.println() ; 
     
 }
  Serial.print("EEPROM 8 Bit data: SSD in 1/10 hours per day");
  Serial.println() ; 
 for ( i=151;i<=164;i++)
 {
   Serial.print(i-150, DEC);
   Serial.print(";");   
   evalue=EEPROM.read(i);  
   Serial.print(evalue, DEC);
   Serial.println() ; 
     
 }
 //}
 //Serial.end();
}
void write_datlog()
{
 int i;
   Serial.print("SRAM logged 16 Bit data");
   Serial.println() ; 
 //Serial.begin(9600);
 //if (Serial.available())
 //{
 for ( i=0;i<maxdat;i++)
 {
   Serial.print(i, DEC);
   Serial.print(";");   
   //datlog=EEPROM.read(i);  
   Serial.print(datlog[i], DEC);
   Serial.println() ; 
     
 }
 //}
 //Serial.end();
}

// Reset the ARDUINO at 00:00 o clock
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);     
  // turn the ledPin on
  digitalWrite(ledPin, toggle);  
       if (toggle==HIGH)
          toggle=LOW;
       else
          toggle=HIGH;
               
  if (sensorValue>(14*4)) sum++;   // Counter for SSD in Minutes
  if (count10>=10)      // if max =10x(30s+30s)=10 Minuten, store to EEPROM
  {
     // Write in ROM  for daily readout
     EEPROM.write(ecountlog%144,sensorValue/4 ); // Byte into lower EEPROM every 10 Minutes
     datlog[day-1]=sum;          // Debug only
     if ((ecountlog%144)==0) {   // day break
          datlog[day-1]=sum;     // Int into RAM 0-16, dayly sum in minutes
          EEPROM.write(day+150,sum/6.0 );  // SSD in 1/10-hours , Byte into ROM   151 bis 164  for 14 days
          sum=0;                 // reset SSD counter for next day
          day++;
          clear_eeprom();   // 1-144 auf 255 setzen
     }
     ecountlog++;      // next ROM address, cycles up to 14x144
     count10=0;        // reset counter10
     
     
     write_eepromlog();
     write_datlog();  // periodicly writes logged Data, should be depending on an User interaction like Terminalinput "A" or
                      // digital Input, not yet ready
     write_status();

  }
  delay(30*1000-115-136);   // 30 sec -2.29/20 -80/540
  delay(30*1000);        // +30s  ( 60 doesn't work ??)
  count10++;
//  if (countlog>maxdat) countlog=0;  // Reset SRAM index counter after 16 days
  if (day>=14){
       day=1;
       ecountlog=1;
       sum=0;
       count10=0;
       toggle=HIGH;
  }
}

3.) Backup Using the eeprom, because RAM is too few. Only get 8 Bit sums.

EEPROM is exactly the same width as RAM - what's the question?

5.) EEprom is writeable for 100.000 times. Thats many years for my project?

100 000 times ten minutes is 1 000 000 minutes, or about 694 days.
Define "many".

100,000 times per address, dependent on factors such as how often it written.
Cycle thru a range of 100 addresses, will last 100 times longer.
Could always add external 8-line serial EEPROM, read/write via SPI, gives you all the storage room you could dream of.

Hi AWOL,
you're so quick, fantastic.

EEPROM is exactly the same width as RAM - what's the question?

That's true. But I could not increase the datlog array above 16, then the serial-line is dead. I understand,
that the free memory (SRAM) is too few. There are used parts of the RAM.Therefore I'm not able to store a whole day into ram.

5.) EEprom is writeable for 100.000 times. Thats many years for my project?
100 000 times ten minutes is 1 000 000 minutes, or about 694 days.
Define "many".

Ah, I calculated only for once a day per addresss. But I should check, if there is still a problem.

CrossRoads:
100,000 times per address, dependent on factors such as how often it written.
Cycle thru a range of 100 addresses, will last 100 times longer.
Could always add external 8-line serial EEPROM, read/write via SPI, gives you all the storage room you could dream of.

I cycle through 144 adresses for a day and through 14 for 2 weeks. That should be okay.
External ROM is a great reserve. in 100.000 times I will ask you for that :wink: Thanks for your reply.

Okay, I won't hold my breath waiting then :wink: