Translate

Saturday, 22 November 2025

New and improved astronomical clock (pond pump timer)

Cast your mind back to August 2014... 11 years ... where does the time go?
Anyway, one of the early projects I posted here was my arduino pond pump timer.
It's time to drag that project kicking and screaming into 2025.

Here's the plan:

  • Nice new colour display, with touch screen operation.
  • Get the time from the internet (NTP).
  • Retain the same pump options, manually off, manually on, on at sunrise off at sunset (Auto) or on at sunrise off an hour after sunset (Auto+1Hr).
  • Store the current pump modes in EEPROM so it survives a power outage.
  • Inhibit the pumps in the event of frost.

So I purchased a "Cheap yellow display", about £14 on eBay. It's got a 2.8" TFT display, with touchscreen, has a built in ESP 32 and exposes a couple of GPIO's to the outside world to control my pumps.




With the old controller, it had a dallas one-wire temperature sensor hanging out of a hole in the workshop wall, which I used for frost detection. Unfortunately, that wasn't going to work here, as not all ESP32 GPIO's are created equally, and one of the three exposed GPIO's wasn't much good. One of the draw-backs of the cheap yellow display (CYD), was the amount of in-built hardware; great if you're going to use it all, but the in-built SD card reader, RGB LED absorbed a lot of those valuable GPIO lines. (Quite why the SD card reader and LCD didn't share the same bus, I don't know, that would have freed up 3 pins, but anyway...) 


My first issue was getting the damn thing to do anything. It turns out there are a few variants of the CYD, mine having two USB sockets, and the part number ESP32-2432SO28. Many have an R after the number and require a subtle change to the software to get them to behave.

After about a day of buggering about, I had a display. I'd managed to draw a little sun icon, which moved across an arc during the day, the current time and date, compensated for daylight saving time, and had calculated the sun rise and sunset times, based on my location. Nice. 

The following day, I added in touch screen operation to swap between pump modes, and managed to get these stored. I used the ESP32's "Preferences" memory for this, and it works well.

Getting the temperature in was, well, a little more difficult.

I have a weather station on the roof. It drives a small display inside the house. The weather station transmits it's data using RF at 863MHz. Just over a year ago, I saw a project called WeeWX. It ran on a Raspberry Pi, and uses a cheap SDR dongle to receive the transmissions from the weather station and generates some lovely graphs. I always meant to document my journey in getting WeeWX to work, but even to this day, I'm not quite sure how I got it all to function. It was not a straightforward process! I ended up hacking the driver from a similar model of weather station to make it work. Anyway, now it is working it's been very reliable. 

It generates this webpage, locally served to my network.

The data is also sent to the amateur radio APRS (amateur packet reporting system) network. (You can see this data here). The plan was to get the ESP32 to connect to the aprs network, and pull the data from there. 

There was a couple of issues. 
  • It wasn't reliable.
  • I don't want to go spamming someone else's server with requests.
The reliability issue was probably my own doing. G7GQA-4 also transmits received packets from other stations via RF, and I think this was confusing matters.

So back to WeeWX.
The temperature is displayed on the top right of the webpage, so I planned to get the temperature from this locally served webpage, and use that.
I spent about 3 hours trying to get this to work, with little success. I then buckled and asked ChatGPT if it had any pointers. In 10 mins flat, ChatGPT had made me a helper function that reliably pulled data from the webpage, and refreshed it every 10 mins. Bingo.

After tidying up the code a bit, I had a working controller, which looked pretty enough. 



I then got carried away. Once again with the help of ChatGPT, I added a web interface, which appears on the local network at http://pondpump.local
I also added error trapping, just in case weeWX crashes. I also added backlight dimming, to increase the life of the display, and to dim the display at night.


You'll need to modify your wifi SSID and password, and change your Latitude and longitude.

Now to create some hardware...

I'll use GPIOs 22 & 27 to operate two relays for pump 1 and pump 2 respectively.

I'll need to create 5V from one of the pond pump transformers (which, incidentally are low voltage AC). I'll use a DD4012SA buck converter board for that. A couple of 2N7000 fets should do nicely to drive the relays.

A schematic is conjured up in Kicad


The power supply is straight forward, just a bridge rectifier, followed by a bit of smoothing. I chose to use a switching converter that's pin-compatible with a 7805 to keep the dissipation down a bit, followed by a bit of a reservoir.
The GPIO's of the CYD feed the gates of two 2N7000 fets, which drive the low side of the relays. A free-running diode is connected across the relay coils to stop any back emf spoiling our day.
The pumps are simply connected in series with their respective supplies across the normally open contacts of the relay.

The whole thing is lashed up on a bit of perf-board for testing, and works OK. You can see from the
photo I also created a 3D printed case for it too.

Powering the CYD from the new 5V rail, involved connecting the 5V to the cathode of D1 on the CYD. It's the red wire in this photo.
I used some wago connectors to make connections to the pump & transformer wiring a breeze, and hot glued them in place.
Wired up to the pumps and one transformer, and it works great!

No comments:

Post a Comment