Gecko Tide Clock
I seem addicted to building a variety of tide clocks over the last couple of years. My friend Oliver has a house in Mexico near Porto Vallarta and he asked me to build him a tide clock that would work in his area. His house is on a peninsula that juts out over the Pacific and is connected to the local surf beach by a tidal river that goes into an extensive estuary. This connection is tide dependent and his neighbors inquire when the tide will be low enough to cross to the beach. (Definite first world problem...) This can be easily looked up on some iPhone App but when is that as fun as discovering the location of a gecko on a bamboo pole. The gecko crawls to his high tide position turns around and slowly descends to his low tide position. His movements are minute by minute controlled to the corresponding tide level. The gecko is quite smart--he knows the Wifi passwords to his masters house and his latitude and longitude as well as Google does. He is able to conjure up the tide tables from a paid API of anywhere on earth and figure when the master can safely walk to the beach. With the right tools anyone can build this very reasonable tide keeper. The heart of it is a simple stepper motor and lead screw...so the dimensions can be a big or small as you like. A microcontroller makes periodic inquiries for tide tables and time and spins the contraption to animate the lizard on a servo which controls its direction. Most of the parts are a blending of natural bamboo and borg like 3D printed body adaptations that were designed in Fusion360 to bend to the curve of the wood. The bird at the top is from Portlandia suggestion to "Put a bird on it!"
Supplies
The hardest part of this project is getting the bamboo! It's quite fun to find a quiet spot where the stuff grows wild and wack off a healthy hunk. The inner tube which supports the stepper motor and the end bearing (pillow block) is 3 inches in diameter and the outer front cover is a full 5 inches in diameter. These are the dimensions I used but other sizes may be accommodated with modifying your 3D design files in Fusion360. The rest of the inorganic parts are as follows:
- Stepper Motor Usongshine Nema 17 Stepper Motor 42 Motor 1.5A $4
- Limit Switch ( 2)Cylewet 25Pcs AC 1A 125V 3Pin SPDT Limit Micro Switch Long Hinge Lever $0.05
- Lead Screw with coupling and bearings Amazon 500 mm 8 mm$30
- Pololu DRV8825 High Current Stepper Motor Driver Carrier (Item: 2133) $20
- Adafruit MPM3610 5V Buck convertor 21V in 5V out at 1.2 Amp $6
- 12 volt power supply 2 AMP $6
- 1M Drag Chain Cable Carrier R15 7x7mm(Inn HxW) Plastic Black Towline Wire Cable Chain Carrier $10
- TTGO ESP32 with TFT screen $15
- American Robotic Supply Authentic Tower Pro SG90 Digital Servo - 2 Pack $8
3D Print Your Parts
All of these parts are printed in PLA on a Creality Ender 3 machine without support. They were all designed in Fusion360 and if you want the design files I would be glad to supply them. In many cases the surrounding pieces of bamboo were photographed and the photo placed as a canvas into the design to enable to match curves of plastic to organic. The size of the canvas was carefully calibrated. The two housings at the ends were most important in terms of the design characteristics to enable a constant distance between the lead screw and the bar that the bearings rode on.
Build It
Building the clock consists of finding a piece of bamboo which will accommodate the track run of the lead screw and one 500 mm shaft guide on a single bearing (see alternative method at bottom...). The bearing and the servo are mounted to the 3D printed holder(Body 10) that rides up and down the bamboo tube between the securing 3D printed mounts (Body30) at the top and bottom of the bamboo tube. To allow the servo connected Gecko to move a large opening is cut from top to bottom of the bamboo--forming a large 'C' shape.
The 3D printed housing at the bottom of the run (Body 30) passively holds the shaft guide and the stepper motor which is connected to the lead screw with a flexible shaft coupler. The upper housing (Body 30) holds the lead screw in a pillow block and passively holds the other end of the shaft guide. The stepper motor is held in position with pre-placed holes in the mount. The servo sled has a bearing screwed to its base where it accommodates the guide shaft and the T8 brass nut that is screwed to its face with heat sink nuts (4 mm). The hobby servo is screwed into position into its holder on the top. The sled has one passive hole for the shaft guide and the other hole that uses the T8 brass nut to ride on. The sled is slid onto its respective shafts. The bamboo tube is cut with a wide C opening that allows for the movement of the sled. It also has to allow for the movement of the drag chain cable handler that permits the wiring for the servo to move up and down the shaft without destroying the wire connections. I ordered the smallest one on Amazon but it still took up a large area of the design. One end of this chain is screwed to a 3D plastic attachment to the sled (Body32) with heat sink nuts ( 4 mm) and the other to a 3D printed holder(Body41) that hangs on the side of the bamboo tube (E6000). The wires from the chain are glued into the side of the bamboo housing.
The other structures in this tube are the end stops for the stepper motor. These are 3D printed towers(Body33) with limit switch holes to accommodate the limit switches which are screwed on with heat sink nuts (3 mm). These respective towers, one for the upper limit and one for the lower limit were glued (superglue) onto the top and bottom 3D printed mounts in positions which limited the range of the sled movement before it crashes into the end pieces--this can only be done with observation.
When everything feels right you can glue the end pieces to the bamboo inner tube with E6000 glue. Hopefully you will have good free movement of the sled! The 3D printed holder(Body46) of the microcontroller is held into position with heat sink nuts and screws (4 mm).
The bird shaft(Body34) mounts on the end of the lead screw and is held with 2 heat sink nuts and 4 mm screws on the shaft. The end cap(Body54) is held with heat sink nuts. Mounting plates for the back(Body49) of the unit and for the front(Body51) that hold the unit (to hold the bamboo front plate) are superglued to the wavy end pieces. They all have holes for heat sink nuts of appropriate size-- 3 mm to for mounting holders in back and 5 mm in front for the large, long screws to hold the front plate.
The Geckos( Geckos are two sizes and their STL files are adjusted in Cura slicer) are artfully painted and two are attached to the mounting screws that hold the bamboo face on. The largest Gecko is glued (superglue) to its mounting holder(GeckoConnector) which has a screw mount(Fusion360) to the attachment 3D printed for the servo head(Body4,Body9). The bird(eames-house-bird) is nicely painted and glued to the top of the bird shaft(Body34)
The alternative is to just use a 500 mm length of PVC plastic 3" and add the 3D parts to it--but where's the fun in that?
Wire It
The wiring is for an ESP32 board with the built in screen which makes it so easy for debugging. There are six main components that must be wired up--including the microcontroller. Power from the 12v plug is split (1) power goes to Pololu DRV8825 High Current Stepper Motor Driver and (2) Adafruit MPM3610 5V Buck convertor. The Buck convertor supplies power to the 5v on the microcontroller and to the servo. The stepper motor is wired to the Pololu. Please look up this particular motor driver on the Pololu web site:https://www.pololu.com/product/2133 It is a great board and one that must be carefully set up to limit the amount of current going to your particular stepper motor. This is slightly involved and the web site has great YouTube videos on how to do it. Reduce the stepping to around 1/16 to reduce the noise and the sound vibration from the stepper motor. This is done on the Motor Driver by changing presets with low or high voltage to the pins...follow the detailed instructions. The ESP32 has pins 33 for Step and 25 for Dir. The two end point switches are connected to ground and to pins 26 for high limit and 32 for low limit. The Servo is wired to Pin 17 and its other connections are to the Buck Convertor for power and ground. The enable pin from the Pololu Driver is connected to Pin 22.
Program It
The basic outline of the program involves downloading tidal information from https://www.worldtides.info web site and parsing it out using Arduino JSON. Every minute after you query the NTP server to get the correct time and move the gecko accordingly to make it move to the high position when it reaches high tide and turn around to reach the low position for low tide. Before you begin programming go to the world tides web site and get an API key and a sign on to get access to the information. It is cheap and seems to work well.
The first part of the program requires that you input your Wifi credentials in an add on file called "notes.h". It contains only two variables: myWifi and myPassword for getting your ESP to log on to the web. The rest of the libraries are pretty self explanatory. I use the ESP_FlexyStepper.h library to control the stepper--it works quite well and has some great functions. The next section are for stepper motor control including the Dir and Step pin designations as well as emergency stop pins. The acceleration and deceleration speeds are also set here. TimerTrue is the interval for looking up the time and I set it for one minute but this is fairly arbitrary.
The void setup() function sets up the pins for emergency stop and setting the Servo pin. Wifi is called and the screen is initialized. It also configures the NTP server for the time. TimeStamp should be the difference between UTC and your current location.
Brian Lough has a YouTube video out https://www.youtube.com/watch?v=NYP_CxdYzLo about using Arduino JSON to obtain information from various API's using ESP32. The information in his video was invaluable in writing the code for this Instructable and Arduino JSON is a remarkable and very easy to use program for me. MakeHTTPRequest() makes the request for tidal hi and low limits for the the next day or so and places the information into epochHiLow (epochTime for next hi or low corrected for location) and hiLow ( bool with 1 for high and 0 for low) that corresponds to the epochTime. Find the line: client.print("/api/v3?today&extremes&lat=20.783&lon=-156.467&localtime&datum=CD&key=PlaceApikeyhere") and replace lat and lon with your current location and add the API key you obtained to get tidal calls for your current location. The loop() function searches in these files to find the next hi/low tide relative to the current epochTime corrected for distance from UTC and uses the function: void. moveToHomeInMillimeters to find the limit switch and confirm where the Gecko is and home its position as well as rotate it based on contents of hiLow. The moving function is then called to dial in the position with the stepper motor. The enable pin is turned on/off to keep the motor cool in between shuffles. When the data has run out in epochHiLow the restarter function is called to GET a new data batch from WorldTides.
Downloads
Using It
Tide clocks vary quite a bit in their design depending on how much information you want. Their algorithms are quite complex and without an actual tide station exactly where you live can give fairly false information based on a variety of complicating factors. The gecko gets his marching orders from an API on the web. To set his location replace the lat and lon with your exact location and your API key from worldTides and the gecko will show you how the tide is doing in Mason City, Iowa or Maui, Hawaii. The small screen on the microcontroller will first announce if it has connected to your Wifi and then proceed to list the data it got from the web including date and hi/low tidal status. It will also indicate what % of the high or low tide has been achieved and what line of tidal data it is working on. The program may also be rewritten to indicate actual tidal height instead of hi/low readings. As a final note on "safety" do not follow advice on crossing potentially dangerous tidal streams that you get from insensate geckos.