Introduction: Tide and Weather Clock
Although you can buy analog tide clocks that have a single hand indicating whether the tide is high or low or somewhere in between, what I wanted was something that would tell me at what time low tide will be. I wanted something I could glance at quickly without having to turn it on, or push any buttons, or wait. And I wanted something with long battery life. So I used a TTGO T5 board, which is an ESP32-based board with a 2.13" e-paper display, connected to a TTL5110 chip. The TPL5110 turns on the T5 every 2.5 hours, and once a day the T5 downloads tide data from NOAA and weather data from OpenWeatherMap, displays the data on the e-paper, then tells the TPL5110 to turn the T5 off.
UPDATE (Feb 25, 2020) The Tide Clock has been running for one year now, and the battery is at 4.00 volts, so the clock could conceivably run for many years.
Step 1: Hardware List
TTGO T5 board $17
Adafruit Perma-Proto Quarter-size board (optional) $0.71 (minimum order $8.50)
Li-Poly battery 1200 mAh $10 (or other appropriate power source)
JST PH 2-Pin Cable – Male Header $0.75
220 uF capacitor
Step 2: Tools
Step 3: Assemble Hardware
Assembling the hardware is pretty simple as the schematic shows. I used an Adafruit Perma-proto board which is like a normal protoboard except it is laid out like a breadboard, with the same electrical connections as a breadboard, which is nice. Since I only needed a few connections, and wanted to fit the whole assembly into a small box, I cut one of the boards into fourths with a Dremel cutoff wheel.
The 220 uF capacitor is very important. Without it, the TPL5110 will never turn on the T5. It's a little unclear why, but other people using the TPL5110 have had the same problem. Maybe the ESP32 draws more current at startup than the TTL5110 can supply?
Don't hardwire the battery. Use the JST-PH cable so you can disconnect the battery to charge it. There may be a way to charge the battery from the T5 back through the TPL5110 if the TPL5110 is "on", but I can't vouch for that technique.
I made a wooden box as an enclosure, but anything with minimum interior dimensions of 1.5" x 2.75" x 1" would work.
Step 4: Tune the Timing
The TPL5110 board has a trim potentiometer that sets the time interval at which the TPL5110 wakes up. Use a tiny screwdriver to turn this all the way counterclockwise. On my board, this set the interval to 145 minutes, which is actually more than the spec'ed maximum of 120 minutes, but it works and was consistent and will save even more power than waking every 120 minutes, so I used it. You don't need to know the interval precisely, since the goal is just to download data roughly once a day roughly around 4am. You can specify the interval (e.g., 145 minutes) and the wakeup time (e.g., 4am) in env_config.h.
(If you want better control of the timing for some other project, the TPL5110 board has a trace on the back you can cut to disable the potentiometer. Then you attach a resistor to the Delay pin, and the resistance determines the interval, according to this chart.)
Step 5: The Software
You will need the Arduino IDE with the ESP32 package. In the IDE, set your board to "ESP32 Dev Module".
The sketch is available at https://github.com/jasonful/Tides and requires 3 libraries:
- "ESP8266 Weather Station", available from the Arduino Library Manager (or here). You will only need these 6 files: ESPHTTPClient.h, ESPWiFi.h, OpenWeatherMapCurrent.cpp, OpenWeatherMapCurrent.h, OpenWeatherMapForecast.cpp, OpenWeatherMapForecast.h and can delete the rest.
- "Json Streaming Parser" available from the Arduino Library Manager (or here)
- https://github.com/LilyGO/TTGO-Epape-T5-V1.8/tree/master/epa2in13-demo Even though the code is not packaged as a true library, you can just copy it under your libraries directory and include it.
Step 6: Configure the Software
There are several parameters you will have to set (and a few you may want to set) in the env_config.h file, including:
- WiFi SSID and password
- NOAA station id (in other words, where are you)
- OpenWeatherMap AppID, which you will need to register for (it's easy and free)
- OpenWeatherMap LocationID (again, where are you)
- CONFIG_USE_TPL5110, which allows you to use a T5 without a TPL5110. Instead, the software will enter deep sleep mode. The T5 board draws about 8 ma in deep sleep, so I'd only expect the battery to last a few days.
Step 7: How the Software Works
(You can skip this part if you don't care.)
The goal is to wake up once a day, but since the maximum interval of the TPL5110 is only 2 hours or so, the T5 has to wake up more often. So after it downloads tide and weather data, it calculates how many of these 2 hour intervals there are between now and 4:00 am tomorrow morning. This is slightly complicated by the fact that the TPL5110 totally cuts power to the T5, which is good for the battery, but it means we lose RAM and the real-time clock. It's like waking up every morning with amnesia. So to figure out what time it is now, it extracts it from NOAA's HTTP header. And to remember how many 2-hour intervals there are remaining, it writes that counter to non-volatile storage (flash). Every time it wakes up, it checks that counter, decrements it, stores it, and if it greater than zero, it immediately sends a signal to the TPL51110 ("Done") telling it to put it to sleep. When the counter hits zero, the code downloads new data, and recalculates and resets the counter.
Step 8: Run It
Make sure the switch on the left side of the T5 is in the up (on) position, upload the sketch to the T5, and within a few seconds the screen should update with tide and weather info.
If you need to debug the software, change the "#define DEBUG 0" at the top of Tides.ino to "#define DEBUG 1". This will turn on serial debug output, and also display at the bottom of the e-paper the number of restarts remaining before it downloads new data, and the time it last downloaded data.
Step 9: Future Directions
- The use of the TPL5110 combined with an e-paper display is a great way to display any data that does not change often, with excellent battery life.
- When I was designing this, I considered using the TrigBoard, which is an ESP8266 board with a TPL5111 on board. It would have required getting a separate e-paper display and e-paper driver board like this or this. Or a driver+board combo like this or this. To port the code to ESP8266, I think the SSL code will have to use fingerprints instead of certificates, and the non-volatile storage code will need to use EEPROM or RTC memory.
- I recently heard that the Lolin32 board is pretty decent in deep sleep mode : about 100uA. Not as good as the TPL51110 board (20uA according to Adafruit) but good enough.
- OpenWeatherMap returns a lot more weather data than I am displaying. Including icon ids, which would require finding monochrome icons somewhere.
27 Comments
Question 2 years ago on Introduction
Bonjour,
Je découvre votre réalisation, et, comme vous me semblez compétent dans ce domaine, pouvez vous m'indiquer s'il existe un site du type de la NOAA en Europe, et plus particulièrement pour les marées en France.
Merci de votre attention, et encore bravo pour votre travail.
Yves
Hello,
I am discovering your realisation, and, as you seem to be competent in this field, can you tell me if there is a NOAA-type site in Europe, and more particularly for tides in France.
Thank you for your attention, and congratulations again for your work.
Yves
Answer 1 year ago
For France, I found Stormglass.io (Sweden) and they offer a free plan with a simple API (10 req per day).
I suspect I'll need to write the parser.
But in my case the tide times had some difference (5 min & 14 min) since StormGlass seems to use a limited list of stations (mine is 27 miles away). But for approximate values it could be enough (or if you are closer to a supported station).
2 years ago
Wow! This is exactly what I wanted, can't believe this isn't commercially sold. Looks like I have a project ahead. Thank you!
2 years ago
Can the blue LED that lights up whenever the T5 is powered be turned off through software or do I have to desolder it?
Reply 2 years ago
I believe it only lights up when the battery charging circuit is on. If you are running off battery (not charging), it won't come on.
I don't think the blue led is controllable via software.
Reply 2 years ago
I made a different investigation:
Blue LED is on when module is running in battary mode without charging.
When connected to USB (automatical charging ???) the blue LED still is on. Additionally the red LED is on.
Both LED (blue and red) are off when module is off.
2 years ago
It appears NOAA changed the URL of their API slightly, breaking old clients. I have updated the software on github to use the new version.
3 years ago
I guess using esp32 hibernation would be even better, 2.5µA according to link :
https://lastminuteengineers.com/esp32-sleep-modes-...
or even deep sleep with memory preservation at 10µA
and you can use larger periods between wakeups...
Question 3 years ago on Step 3
My first electronics and software. Is it possible to show a picture of the backside of the breadboard? The side with the solder?
Thank you.
Live on a river. Have two new dogs. If it's high tide and I let the dogs outside - one will swim over to the neighbors. Difficult to get him back. Can't always tell if the tide is coming or going.
Answer 3 years ago
I don't have a photo of the project itself easily available, but... The way Adafruit's perma-proto-board works is that each numbered column (such as column 9 in the second photo of step 3) is electrically connected on the back.
3 years ago
Hi,
thank you this wonderful project and one of the first project on TTGO E-Paper :-)
I tried to compile on a new windows 7 and clean arduino installation.
Here is error returned after a lot of tests and compilation :
Error: dbg.h: No such file or directory
I think you forgot to add a Library in your tutorial ? May I ask you wich one I must add to fully compil your code ? :-)
And maybe if you could provide a complete list of library installed on your PC ?
Regards
Richard
Reply 3 years ago
dbg.h is not in a library. It is just a source file. You should see it next to all my other source files.
3 years ago
My setup is getting to here and hangs (serial monitor output):
connecting to _Guest1
....
WiFi connected
Getting url: http://api.openweathermap.org/data/2.5/forecast?i... my app id>&units=imperial&lang=en
[HTTP] GET...
[HTTP] GET... code: 200
start document
You show the returned data stream in your code as this:
"Returned text looks like:
Date Time, Prediction, Type
2018-12-25 00:54,-3.304,L
2018-12-25 08:06,16.223,H
2018-12-25 13:54,7.533,L
2018-12-25 18:35,13.596,H"
But I am getting waaaay more information back, information such as wind speeds, directions, humidity, etc.
So it appears the parser chokes at this point. I guess I am missing or not seeing what I am doing wrong to get so much information back.For now I am using your env_config except for these CONFIG_SSID, CONFIG_PASSWORD, CONFIG_USER_AGENT, CONFIG_OPEN_WEATHER_MAP_APP_ID, and CONFIG_USE_TPL5110. I figured once I had the unit showing the information for the area you had setup in the code, then I could change it to my needs.
Love the project but wow am I stumped! Thank you!
Reply 3 years ago
There are two separate data sources: api.openweathermap.org and tidesandcurrents.noaa.gov. It sounds like maybe you are trying to parse the weather data using the tide-parsing code. Is that possible?
Reply 3 years ago
I will look into it. I thought I was using your code as posted but it is entirely possible I have made some mistake.
Thank you!
Question 4 years ago on Step 9
I wonder if this could be modified to display the tides graphically, as in the chart on this page: http://www.dairiki.org/tides/daily.php/san . When trying to know what the tides are at any given time, the graphs are more helpful to me than the charts. Perhaps the graph could simply be downloaded each day. If this is possible, maybe another Instructable would be nice (to help beginners like me). But this is an incredible idea, and good work!
Answer 4 years ago
The NOAA API does support returning that sort of data. For example, https://tidesandcurrents.noaa.gov/api/datagetter?b...
And then you'd use paint.DrawLine() to draw a graph. But I'll have to leave the details as an exercise for the reader.
4 years ago on Introduction
Awesome project! I really like the low energy display.
Question 4 years ago
Hi !
This seems Great ! Do you know if it will work in France, with degrees Celsius, 24h clock, french language, and all and all ?
Your wood case make your device looking really nice
Reply 4 years ago
The tide data comes from NOAA, which is a US government organization, and while it has data for some parts of the Caribbean and Pacific, it does not cover France. A quick Google search showed there are other tide API providers out there that cover Europe, but I haven't looked into them.
The OpenWeatherMap API will work; just change CONFIG_OPEN_WEATHER_MAP_LANGUAGE to "fr" and CONFIG_WEATHER_IS_METRIC to true. You'll also need to change Tides.ino where it prints the date and time to change the formatting, but that should be easy.