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!

Tuesday, 7 October 2025

Quick and dirty coil winder

In a recent episode of Doz' Television workshop, I diagnosed line output transformer (flyback) transformer failure in pye TV. 

So, a means of repairing the transformer was required. 


First things first was to get the old transformer apart, which was a messy and long-winded job. I'll spare you the details here...

Then what was needed was a means of counting the number of turns on the existing transformer. I didn't fancy the job of doing this by hand, so a plan was hatched.

You'll need:

A PCB vice.. I used this type, which you can obtain via the internet in all the usual places.







A length of 5mm diameter rod or bar. I started with a short (100mm) length of aluminium, but changed it to a  longer length (250mm) of stainless later on.

Some 3D printed parts: These are available for download on my git for this project here.


Two "pizza slice" shaped parts (quadrants)








One spindle 


















a handle
 








and a sensor holder 









Also needed are some slotted photo interruptors. I got these from amazon. You'll need two.









and finally a 16X2 I2C LCD display and an arduino or equivalent. I chose a Sparkfun pro-micro.

 

After assembling and fitting the 3D printed parts together, I found out that the PLA I'd printed the quadrants from passed infra-red, so I stuck some aluminium tape on the relevant areas to obscure the infra-red. I also moved the quadrants for they were 180 deg apart.









During the winding process, I made a spool-holder in a similar manner, using some of these couplers to clamp the wire, and a spring retrieved from the original PCB vice to keep some tension on the reel of wire.






You can see how it all went here :








Friday, 24 January 2025

Improving the AliExpress AM tramnsmitter

Been a while, eh? Well, this is an accompanying write up on my latest YouTube sensation...


I purchased a cheap AM micro power transmitter from AliExpress... 



It has issues...











It's a straight forward, series-modulated affair. It's output filtering isn't utter rubbish either. My first issue is with the modulation transistor, which is that 2SD882 on the heatsink, top right of the PCB...






This one ... 


This is how I received the transmitter. Note how the transistor's metal back is not facing the heatsink! Why in god's name did they choose to fit it "upside down"? Board layout cock-up? Who knows, but we need to sort this, because as it stands, that transistor is running too hot.










The simple task of unbolting the heatsink, adding a smear of thermal compound, and putting the heatsink on the correct face of the transistor, and re-fitting the transistor results in a much cooler running modulator ... good.








The next issue is the frequency stability of the oscillator. It's touchy. You just need to stare at it for a few seconds, and it'll start hopping up or down the band by a number of kilohertz! It's also not very good thermally. We need something better.


I's previously purchased some of these AD-9833 modules very cheaply (about £3) from AliExpress. It's a DDS - direct digital synthesiser, and can create, square, triangle or sine waves upto about 12.5MHz. It has a small 125MHz crystal oscillator on board. Ideal. 












Lashing it together on a breadboard, along with an Arduino Nano, soon had a functioning sine wave oscillator.














... nice 

I was somewhat concerned about the amplitude from the oscillator, as the original (touchy) oscillator managed to swing about 7 volts into the RF driver transistor (measured at C20), and this outputs only 600mV pk-pk. 
I designed a simple 2N2222 amplifierer before my head cleared.... The output from the AD9833 is actually at 50 ohms, so it has quite some current drive, and it's feeding the base of Q2, so would it have enough drive just as-is?


Yes, yes it has :) 









Here's the output of the transmitter into a 50 ohm load, and we're managing to swing 7.5V. 













Having proved that works, the DDS was refined a bit, and made up on a piece of perfboard.

Notice the addition of the DIP switches to allow the channel to be changed, and the 7805 voltage regulator.





The code is available on my github https://github.com/andydoswell/MW-Nano

The DIP switch channel selection needs a mention, as it not only caters for us Europeans using 9 KHz channel spacing, but for those living across the pond that use 10 KHz channels. 

With bit 8 off, the binary defines which channel in 9 KHz spacing from 531 KHz to 1611 KHz. With bit 8 on, the lower bits define the 10 KHz channel from 630 to 1710 KHz. 

There's a section in the YouTube video which shows an easy way to calibrate the output from the DDS.

I've made a handy spreadsheet to look up the channels MW Channels

So now we have a cool-running, frequency stable transmitter. What about a bit of audio processing?

Enter the Teensy 4.1, and it's audio shield.
The audio shield is simply soldered onto the bottom (or top) of the teensy 4.1, and provides us with a high quality DAC and ADC, which receives and sends I2S Audio.
There's a tutorial here, which shows how to use the provided audio library.. 
After a bit of tinkering, I've come up with this audio chain, which when used in conjuction with a bit of code, provides a bit of multiband compression and filtering.

I'll come back to the code in a minute...



Now, I often get people to give my videos a bit of a test before they go live. My mate Nigel messaged ... 
Yeah... a Teensy 4.1 is about £28, and the audio board is about £13. If you just want the audio processor, the code will happily sit on a teensy 4.0, which is a bit cheaper, if you can find one. If there's someone out there who can make this all work on something cheap, like a blue/black pill or an ESP32, please do! ... and let us all know!

Just audio processing ? Well, yes... I added the synthesiser code to the teensy, so I don't have to bother with two microcontrollers...

So the teensy code can be found here.

As you can see, there's 4 variants.
Teensy AM Processor is a quite aggressive compressor. Teensy Multiband is my attempt at a multiband compressor, as shown above. There's also a variant of each, with the synthesiser control built-in.
Please feel free to hack that code about and make it your own, and share the journey with us!

Now Nigel.... he had a point ...

Yeah, OK.

Let's try a similar thing the old fashioned way....


Audio arrives at CN 1, and is passed through the first two stages of U1, forming a high-pass 4 pole butterworth sallen-key filter. Stages 3 & 4 form a high-pass 4 pole butterworth sallen-key filter. This provides adequate cut off at around 90Hz and 5.5KHz.

Audio is then passed to U3.1, which is a small amplifier, and provides enough drive for the compressor stage, U3.2. H2 connects to a GL5528 LDR which is in the negative feedback loop for the amplifier. When it's dark , the amplifier has maximum gain. As the output increases, the output is rectified, via R14 and D1 & D2 (dual package schottky, note different suffixes, this is important!) forming a bridge rectifier. This rectified output is fed to a yellow LED which is placed inside a light-proof tube, along with the LDR). As the LED's brightness increases, the gain of the amplifier is reduced. It's an age-old design. Audio is sent out via CN3. (Note, fit an attenuator here or a pot, as the output is hot at about 3V pk-pk)

The thing's lashed up on a piece of breadboard, and it's a bit "in-your-face" compression-wise, but it works well enough. The only issue is, as the output becomes quieter, the gain of the compressor tends to induce a bit of noise. This just doesn't happen with the software compressor.





A PCB is created if you fancy building one for yourself... files are on my git here.










On with the build...

First up was to tidy up the transmitter PCB by removing now unnecessary components from the board. There are five to remove, the polyvaricon, a small ceramic cap, the coil, the pot and the oscillator transistor, as indicated by the white arrows below. Add some pin headers where indicated with the blue arrows. 


The two pins where the pot used to connect are the audio input, and the two pins where the coil was are where the frequency synthesiser now connects. Connect two wires to the underside of the PCB where the power jack is. The ring (nearest the outer edge of the PCB) is the negative. 

The (now removed) pot also had a switch, on the outer two large contacts. You need to short these out with a small wire link.

I purchased a nice enclosure from eBay. Sadly, I'm unable to recommend the seller, as they promised "3 to 5 day courier delivery", which would have been fine, but it took the seller 3 weeks to dispatch.








I decided to 3D print a front panel. This is to include an LED for power indication, a power switch, a VU meter, a level control and a switch to select or bypass the compressor/filter.



I'm not going to describe the VU meter circuit here, as the one I put to use is, quite frankly awful. Take a look here for better inspiration. I just wanted some sort of level indicator.

The rear panel is drilled and two binding posts fitted, one for the aerial wire (insulated from the chassis
with a bushing), and one for ground (connected to the chassis, scratch some paint off first).







I added an eBay buck converter set to 9V, and mounted to the rear panel to provide power.








The PCBs are fitted, and wired up, and after a bit of debugging of software, the unit works really well...


A quick note about power supplies and antennas. 
The unit is better powered by a linear power supply, doesn't need to be regulated. Aim for anywhere between 12-20V at about 300mA. Switching power supplies tend to cause noise as they have a safety capacitor between the primary and secondary, which can cause a ground loop, and induce hum. Same goes for the audio source. Works great from a mobile phone or MP3 player, until you plug in a charger. You could fit a ground loop isolation transformer (see eBay car audio pages for such things) to avoid the issue with the audio. 
For an antenna I use a few feet of wire. It gives reasonable coverage of my house, but rapidly disappears into the noise a few feet outside, which is ideal. Don't go connecting this to some huge length of wire in your garden, along with a decent ground. Yes, you'll get some range out of it, but you're also likely to get into trouble with the local authorities. If you're in the USA, there's part 15 regulations which let you do this sort of thing, but this transmitter is capable of exceeding those regulations. Backing the buck converter down to a minimum of 7V will also reduce range. 

If you want to see a couple of videos about this, they can be found on my youTube channel. The video also shows you how you can easily calibrate your frequency. Do me the favour of a like & subscribe ;)



Monday, 20 January 2025

Linearising a classic Mini Fuel Gauge when fitting an ETB gauge.

 Julian rang....

"Can you tell me whether this fuel gauge I've got will work in my Mini"

I thought to myself "This is going to be horrible" ... it was.

Connecting the gauge to the tank sender, a 12V supply and hooking the tank float about with a bit of wire gave empty and full, and garbage in between.

I took some measurements of the resistance of the tank sender at Empty, 25%,50% and 100% full

TankR sender
1007.5
7530
5065
25125
0200

R sender is in ohms...

Having got home with the gauge, I wired it up to a pot and took the same values

I lots these when I did this, but it was quite clear that bodging this up with some analogue electronics wasn't going to be easy.

What about a microcontroller? Hmmmm.

I tried connecting the tank connection of the gauge to a 2N7000 fet, via a 4.7 ohm resistor to round, and PWMing it.... yep, that works. I took note of the PWM values vs indications on the gauge.

TankPWM %
100244
75222
50174
25144
0123

Now to mash the two together.....

Get an arduino nano to measure the voltage developed across the sender in series with a 200 ohm resistor. Calculate the resistance of the sender, calculate the required PWM.

Except for neither graph was a straight line ...

A bit of messing about inn google sheets later had two equations I could implement in my code to flatten it all out a bit. https://docs.google.com/spreadsheets/d/1W5jGL7obq-l499up6gbHa-PL1yinc2bq0epixeFbGJ8/edit?usp=sharing

A circuit was quickly conjured up...


... and built up on a piece of perfboard.

To make it a bit smaller I chose a Pro-mini clone, and changed the 7805 for a Traco TSR-1-2405 switching regulator, to keep the heat down.





Next up was to make a case in tinkercad, and get it printed.













... and once that was done ...












It's put in it's box, sealed with a little RTV, and connected up for test.







All works great!