Pages: [1]   Go Down
Author Topic: Tide prediction libraries for Arduino  (Read 1162 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working on a library to provide ocean tide height predictions for coastal locations using only the Arduino and a real time clock chip to provide the current time. Example libraries are available at my GitHub repository. Each library contains an example Arduino sketch.



The basic library function is described here:
http://lukemiller.org/index.php/2012/09/tide-height-prediction-with-the-arduino/

I also expand on some potential uses here:
http://lukemiller.org/index.php/2012/09/using-arduino-tide-predictions/

The short story for those that don't want to click through links is that I borrowed the tidal harmonic data compiled in the open source XTide program by David Flater and use those to generate Arduino tide prediction libraries for a NOAA (USA-only) reference tide station. There are roughly 635 such stations scattered around the US, so in theory it should be possible to generate a tide prediction library for any of these locations. 10 years' worth of harmonic constants for a site are loaded into program memory when the tide prediction library is included in a sketch. To get a tide prediction for a certain date and time, you feed a DateTime object (from the various RTClib libraries out there) to the currentTide() function, and it returns the predicted tide height for that station, in units of feet. The library for each site includes an example Tide_calculator.ino sketch that will output the current tide height to the serial monitor as a demonstration. This isn't just using a lookup table of tide heights and times, it actually does the "real" tide height harmonic calculation on the fly for any given date/time within the provided 10 years' worth of harmonic and lunar constants in a library.

The primary caution with the use of these libraries is that you must supply the DateTime object time using the tide site's local standard time zone, not daylight savings time. When using a real time clock chip, it needs to be set to local standard time for the site, regardless of what time of year it is currently. Therefore you will need to adjust your computer's clock to standard time when initializing the real time clock chip. The displayed times in the serial monitor will also be in local standard time.

To generate a library for a different site, I included a R script and dataset that can be used to automatically generate the library for a site. This is explained in the webpages linked above.

For the handful of sites I've tested this on, the predicted tide height is well within the rounding error of NOAA's own tide predictions available on their http://tidesandcurrents.noaa.gov/ website.

The tide prediction library could be used to build something simple like a tide clock that displays the current tide (or even tide heights for several hours if you feed the function multiple time values). I've developed this for my own research needs, and the initial projects I've built with it reflect that. This Youtube video shows a stepper-motor-driven rack I built for a research pilot project, and demonstrates that the tide predictions from the Arduino powering the rack follow quite nicely with NOAA's predicted tides for the same site, which are shown in the graph on the right of the video.

Logged

Saskatchewan
Offline Offline
Sr. Member
****
Karma: 19
Posts: 362
When the going gets weird, the weird turn pro. - Hunter S. Thompson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I live in Saskatchewan, I thought Tide was something I washed clothes with.

I asked Bill O'Reilly what the tide is, he said it goes in and out but he couldn't explain it.

 smiley-grin

Actually, that's pretty cool.

Logged

Pages: [1]   Go Up
Jump to: