When you're by the sea, you probably want to know the tide level to decide if it's time to swim or go fishing. I therefore offer you a tide clock that will help you organize your activities.

The principle is that the period of the tide is fixed by the apparent rotation of the moon around the earth. It is therefore very regular and is precisely 12 hours, 25 minutes and 14 seconds. If you know the current date and time, and the date and time of a previous high tide, you can calculate the current state of the tide.
The Lunar Harmonic Cycle
You cannot use standard millis() for tidal prediction. The ocean does not obey a 24-hour sun; it obeys the Moon. The average time between high tides is exactly 12 hours, 25 minutes, and 14 seconds (the semi-diurnal tidal constituent called M2). The Arduino connects to a real-time clock (RTC) module to get the absolute date and time. The C++ code uses a predetermined "Known High Tide" baseline anchor point (e.g., High tide was precisely at this date and time last month). The mathematical engine then calculates the modulus: secondsSinceAnchor % (12 * 3600 + 25 * 60 + 14). The result of this calculation informs the Arduino exactly where the water level currently sits in the real-world tidal cycle.
Using the tide clock
The clock user interface consists of a graphic display and four push-buttons labeled Mode, Select, + and -.
The Mode push-button is used to display one of five screens.
The first screen displays the current state of the tide on a round clock with a single hand that circles the dial in 12h 25m 14s. Each graduation corresponds to approximately one hour.

The second screen provides another view of the tide: a sinusoidal curve shows the evolution of the tide throughout the day, and a vertical line shows the current time. The intersection of the sine wave and the line shows the current tide level.

These two screens allow you to know not only the level of the tide, but also to know if the sea is rising or falling. The second screen also allows you to know approximately the times of high and low tides.
Graphing the Sine-Wave
Drawing text is boring. A tide requires a visual wave. Utilizing coordinate geometry, the Arduino plots a smooth Sine Wave across the screen. It maps the current mathematical phase to the wave, drawing an indicator exactly on the curve, physically showing if the water is currently rushing in (Flood tide) or rushing out (Ebb tide).
The third screen shows the phase of the moon. Since it has little relation to the tide, it is optional. To remove it, just comment or remove the line #5 of the program (//#define MoonDisplayActive). I added this screen because I had all the necessary elements to do it.

The fourth screen allows you to set the real time clock. The current date and time are displayed and you can adjust the different values (year, month, day, hour, minute) by selecting them with the Select push-button and modifying them with the + and - push-buttons.

The last screen is used to set the date and time of a previous high tide, called reference high tide, in the same way. It may have happened the day before or be much older, it doesn't matter because the tide period is very stable.
However, two rules must be observed:
- The reference high tide must have taken place at the same location as the clock is running because the tide is not synchronous for all the points of the coast.
- The summer time correction must be the same on the current time and on the reference high tide. The easiest way is to apply no correction.

The clock power can be disconnected at any time. When the power is back on, the current tide level is up to date because the high tide reference is saved in the EEPROM and the current time is maintained by the battery in the real time clock.
Accuracy
This tide clock has a very good long-term stability because it is based on the apparent rotation of the moon. But since the moon is not the only cause of the tide, it has a rather poor short-term accuracy. The two main reasons are:
- The sun also participates in the tide, and it disturbs the regularity of the rhythm,
- The moon has an elliptical orbit and therefore its rotation speed is not constant (Kepler's laws).
The short-term error can be up to one hour and a half, but it is usually much lower. Maybe someone can come up with equations to improve the short-term accuracy.
Hardware & Nautical Component Base
The clock is built around an Arduino Nano Every board, but other Arduino boards may be convenient. For more complex calculations, an Arduino Mega or ESP32 could be considered.
The display is a monochrome graphic display controlled by I2C (a 0.96" OLED01) but you can choose a larger one, such as a 1.8" or 2.4" SPI TFT Color LCD Screen to beautifully render the tidal graphs. You can also choose another resolution, the program will adapt automatically. A voltage translator is necessary because the operating voltage of the display is lower (3.3V) than that of the Arduino board (5V). You have to adapt the line #12 of the program to your own display, particularly to the display controller: SH1106, SSD1306...
A real time clock (RTC) is used to know the current date and time. I used a DS1302 driven by a 3-wire serial interface and backed up by a battery. A DS3231 I2C RTC Module is another excellent option for high precision.
Finally, four push-buttons allow you to choose the display and adjust the clock: mode, select, + and -. The system is powered by a reliable 5V Power Bank to run the calculations indefinitely inside an acrylic enclosure.
Software
The program uses three libraries that you can install with the library manager: u8g2 by oliver to control the display, NeiroN's RTClib to control the real time clock. This library provides very useful time calculation functions. I used them particularly to calculate the difference between the current date and the reference high tide date. arduino fsm by Jon Black. This library allows you to install a finite state machine. I used it to cycle through the five screens with the Mode push-button and to refresh the two clock screens every 10 seconds. If you want to know more about finite state machines, you can have a glance at my project "A user friendly interface in a simple timer".
I used a fourth library which is pre-installed: EEPROM to save the reference high tide when the power of the tide clock is down.
If you want to understand how the program works, it is self-documented as the function and variable names are self-explanatory and there are many comments.
Conclusion
I wish you nice sea bathing and fruitful fishing.