.csv reading to define veriables

ok i have added a .csv file to my arduino sketch,i did this with [sketch->add file…] in it it has a set up of [month,day,sun rise time, sun set time] for an entire year. how do i parse through it in order to compare it with a RTC time and determine whether my snake enclosure should be day or night
added i have my complete source code for my enclosure now, and a .txt version of the .csv

where (month(//from RTC) = column 1 value //from .csv and day(//from RTC) = column 2 value// from .csv){
if (time >column 3 value){
if (time <column 4 value){
night = false;
}else{
night = true;
}}else{
night = true;
}

Sunrise_set.txt (6.79 KB)

harold_and_kumar_enclosure.ino (6.75 KB)

I don't think you can just tag on a CSV file like that. The Arduino compiler will just ignore it. You could add it as a .ino file or a .h file but the data would need to be in a regular C/C++ item such as an array.

HOWEVER there are over 6,000 characters in your CSV file and that will not fit in an Uno with 2K of RAM. You can probably put it in PROGMEM but I'm not sure how you do that. Someone else will probably advise.

There is a parse example in serial input basics.

...R

ya i am hoping it would work some how i just wish i could have figured it out eventually, right now i am just using the avg times for sunrise/set what if i break it down into 12 files with each having one months of data, that way it will be less stress on the ram

You'd have to use PROGMEM to store the file contents in FLASH, and then parse it. That will require converting the whole file to one or more initialized character arrays. strok() would make parsing the lines trivial.

Regards, Ray L.

hagakure: ok i have added a .csv file to my arduino sketch,i did this with [sketch->add file...] in it it has a set up of [month,day,sun rise time, sun set time] for an entire year. how do i parse through it in order to compare it with a RTC time and determine whether my snake enclosure should be day or night added i have my complete source code for my enclosure now, and a .txt version of the .csv

Hm, you know that you also could calculate sunrise and sunset times for any given date and location?

Such a function would be a simple one if the required accuracy is just +/-20 minutes, or may be a bit more complex if the required accuracy is less than a minute. But it would be just a simple function call to calculate sunrise and sunset, finished within a few milliseconds or so.

Retrieving values stored in text from a pre-calculated table in a .csv file sound more complicated to me.

that equation is going to be the way to go, anybody have a snip-it that might have work?

I think you'll have to use something like an SD card to read the file.

hagakure: that equation is going to be the way to go, anybody have a snip-it that might have work?

Not ready.

But I think Google will be able to find some algorithm and/or C-Source and I could work it out for Arduino.

What do you need: Just to calculate the sunrise/sunset times for a given time zone?

Or do you need the times in "local time", considering "summer time" or "no summer time"?

If you need to consider summertime for a given date to get sunset/sunrise in local time: - EU summertime settings? - Or summertime ("Daylight Saving Time") for another country outside Europe?

Perhaps you can to it like that: Your RTC keeps on the same timezone though the whole year. Lets say "UTC+1hour" or what else. No fiddling with summertime. Then you'd just need a routine to calculate sunrise/sunset for "UTC+1hour". OK?