Benlo Park

IoT Projects


Peter Jennings

August, 2023

Fish Tracking Ultrasonic Tag Reader

Tagged Fish

When I read about the fish tagging project in Ston(e)y Lake this spring, I was immediately curious to know if any of the tagged fish visited our boathouse.

Dr Graham Raby and Dr Jake Brownscombe have an ongoing project to track the movement of fish in Stony Lake using ultrasonic tracking transmitters surgically implanted into a number of captured and released fish. As of June, 2023, 215 fish had been outfitted with transmitters provided by Innovasea.

I learned that the transmitters used were the 69 KHz version. Innovasea provides a detailed data sheet with their specifications. Knowing that the signal is at 69 KHz and that the power is 137-162 dB referenced to 1 ┬ÁPa @ 1m, I was pretty sure that it would be possible to build a simple receiver capable of hearing their signal. Simply put, a direct signal from a transmitter would be stronger than the reflected signal detected by a fish finder.

With the limited resources at the cottage, I would be constrained as to what hardware and test equipment I could use for this project. Some of the hacks I ended up using would not have been necessary at home with a fully equipped development bench.

Initially, my plan was to use the hydrophone from a cheap fish finder and some simple electronics and a microprocessor to detect and process the signals. Or perhaps tap into the PCB inside the unit.

I came across a supposedly waterproof transducer and detector board (JSN-SR04T) that seemed to offer the hardware I needed at an affordable price of $10-15 from Amazon and less than $2 from AliExpress.

Researching the product, I was pleased to find a complete schematic was available. This allowed me to understand the operation of the unit as a range finder and to isolate the detection circuitry designed to process the weak received signal.

The LM324 contains 4 op-amps that perform the receiver function. This is a 20 cent IC I have used in previous projects so it was a bit of a memory test for me to understand the circuit operation. The output from the transducer (after voltage limiting with a pair of diodes - important!) is fed to U1D, which is a preamplifier. The output from the preamp feeds the Infinite Gain Multiple Feedback Active Filter U1C. A few years ago, I would have had my slide rule out to calculate the parameters of the filter. Now Google found me an online calculator to save me a lot of trouble. Plugging in the values in the current circuit indicated that I was looking at a 40 KHz filter with a Q of 4. The frequency of the filter can be changed by modifying R7 to raise it to 69 KHz for isolation of actual signals from the tagged fish.

U1B performs a further amplification and biasing step to present a signal at pin 7 which varies from 0 to 5 volts. Normally this is fed to a comparator used to trigger the on-board microprocessor that calculates the time delay between the transmission and reception to determine the distance to the detected object. We don't care about that. A tap off pin 7 provides a nice analog signal to a separate processor board. A resistor divider drops the voltage to 0 to 3.3V for the ESP32 processor I used.

In normal operation, the power to the LM324 is turned on and off by the controlling microprocessor. Since we are only going to receive signals, we can safely connect pin 4 to the 5 volt supply and disconnect power to the board as we don't need to power anything except the LM324. This also reduces noise on the board from the unnecessary microprocessor. With all that amplification, electrical noise is a problem. It would have been better to power the LM324 with a separate voltage regulator, but I didn't have one at the cottage. The unmarked IC on the board also didn't function at 3.3 volts, which is available from the ESP32 board. The schematic shows an LMV324 but without markings we don't really know which LM324 variant is actually on the board. Probably the cheapest.

My original plan was to repurpose the ESP8266 SBC I am currently using to sense the water temperature. I have built many ESP8266 projects. An ESP32-C3 development board review sample fell into my hands for free, so I decided to use it.

For initial testing to ensure the rangefinder hardware was working, I connected the ESP32 to the JSN-SR04T using the information provided in this Maker Guide. Within minutes, it was all working and giving perfect data. Now I could move on to doing the modifications necessary to disable transmitting and just use the ultrasonic receiver.

A simple program to monitor the analog input on GPIO0 was written. The Arduino 2.1 IDE even includes a plotter that can plot the serial data flow at 500,000 baud. The ADC loop is capable of performing 16,000 analog samples per second. The graph shows a 2.8 mSec sample.

The output of the amplified and filtered transducer sensor board is showing a background signal varying from 2000-2300 (1.6V to 1.85V), the result of background sound and electronic noise from the amplifier components and power supply. Entirely reasonable. I didn't use the built-in conversion to voltage as that would slow down the sample speed due to the calculation involved.

On the bench testing: The transducer was inserted into a bowl of water for its first waterproof test. It appears not to leak. Tapping on the sensor produces a short signal, so something is working. Amazingly, this cheap ultrasonic transducer is a capable hydrophone.

I have two fish finder sonar depth gauges from some ancient experiments to take automatic photos of fish underwater. Actually catching fish is not my thing. The Fish Finder produces a 200 KHz wave train. The iBobber produces a 40 KHz wave train. At close range, both of these should produce detectable signals at close range. The modified filter has a Q of 8, so the 40 KHz signal will be down 18 dB from the design frequency. The 200 KHz signal wil be down 78 dB and perhaps more as the transducer may be optimized for the lower frequency audio.

Success! Both transmitters produced detectable signals. The 40KHz signal "pinned the needle" with the output from the ADC showing 0 to 4096. The 200 KHz signal was still strong when held near the hydrophone. Sampling and plotting even showed the trains of pulses produced for a few milliseconds roughly once per second by the fish detectors. It was interesting to observe the directional sensitivity of both this transducer and the fish finder transmitters. The detection beam will be sensitive to the aiming of the hydrophone. So, we have verified that the setup does detect underwater ultrasonic signals which can be studied.

A simple WiFi interface was coded so that the data could be uploaded to my server once every minute. This allowed for long term monitoring providing data for later analysis.

The breadboarded circuit was "installed" on the floor of the boathouse and provided with USB power. One of the chargers turned out to produce a lot of noise on the power lines which raised the noise level from the amplified signal. For minimum noise, the detector was run off a battery pack which lasted several days without even optimising the code. A later experiment with a 10uF capacitor across the power to the analog board significantly reduced the noise level allowing for the detection of weaker signals and presumably gaining a wider range.

The breadboard design is particularly sensitive to electrical and RF noise. There are long jumpers located adjacent to the WiFi antenna and capable of picking up the RF signals. It was necessary to stop sampling during WiFi transmissions.

The sensor is zip-tied to a carpenter clamp and dangled into the water. Not being sure of the quality of the waterproofing I did not want to let it get very deep at first. In fact after several weeks in the water and sometimes dangling the sensor to 2 meters, I am quite confident the sensor is adequately waterproof for underwater work at minimum depths.

Data recorded by the sensor over a 176 hour period from August 2 at 17h to August 10 at 10h show a lot of background noise and a number of significant events which might be fish swimming near the sensor. The strongest response was on August 4 at 9am when 900 events were recorded during the hour. 400 events per hour were recorded on August 7 and August 9. An event is a received 69KHz signal during a 1 mSec window. Observing the signal reports in real time, it was clear that the background noise level increased significantly when it was raining and when it was windy.

mSec of signals above threshold per hour

How close do the fish have to be to be detected? Without testing that is difficult to determine. I have been promised the loan of a transmitter to test this later. We do know that the absorption loss of sound in water is something like .03 dB per meter, so in theory the signal should carry quite far. In practice, the sound will be attenuated due to thermocline interactions and interference patterns generated by multiple path arrivals, particularly near shore in the shallow bay. The detection range will also be influenced by the direction of aiming the hydrophone as it seems to exhibit different sensitivities in different directions. Read More.

Chasing Fish in the kayak

It seemed it would be interesting to paddle around the lake and see if I could find some tagged fish. The software was revised to include a serial interface to Kai Morich's Serial USB Terminal app on my phone to record the data locally. The WiFi interface was discarded. The USB connector on the phone provided the interface and the power for the detector. Split screen allowed me to log the position and log the detector output simultaneously to the phone.

Although it worked reasonably well, I found that powering the detector from the phone was not ideal. The power supplied varied with how much power the phone was using which varied due to what apps were running and the power they were using. This made for a higher noise floor and a varying DC offset to the signal. Handling the phone also created noise from dodgy connectors and was not convenient with the wires dangling about. Body capacitance with the phone added to the noise when I picked it up.

The solution was to switch to a Bluetooth Low Energy (BLE) interface and power the detector separately off a battery and use the wireless BLE interface to the phone. In addition to adding the 10uF cap on the analog board, this provided a much cleaner noise floor. The physical distance separating the phone from the analog board also decreased RF pickup from the cellphone transmissions. Kai Morich's Serial Bluetooth Terminal app was used to log the data.

The hydrophone was mounted on the bottom of the kayak with high density polyurethane foam (which acoustically isolates the hydrophone from the kayak) and Gorilla Tape, which worked surprisingly well underwater for many hours of paddling.

I improved the logging software with auto tracking of the DC offset and automatic scaling of the trigger voltage according to the noise level, logging a 1 second sample of the number of milliseconds above Vtrig as well as the maximum signal observed over the 1 second interval. The combination of parameters allows some judgement of confidence as to whether the trigger is noise or a real signal. Additionally, observing multiple strong signal events with a consistent time interval between them (as observed east of Brownscombe island) seems like a reasonably confident observation of a swimming fish near the kayak.

A few trips around Lower Stony in the kayak resulted in finding a few tagged fish (red dots).

A cheap tagged fish finder

From the testing, I can see that a super cheap tag detector (BOM < $10) could be built with a combination of an LM324 op amp and an MF10 SCAF IC and a handful of parts. The SCAF can be configured as a very narrow bandpass filter tuned to the actual tag frequency, reducing false positive results to a minimum. An LED or audio output could report the presence within range of a tagged fish. The circuit would be similar to my patented filter design. Unfortunately, as we don't have the list of tags and fish we can't build a musky detector to help fishermen chase their catch.

Identifying individual fish

Innovasea uses three types of ID encoding on their tags. PPM (Pulse postion modulation) encodes information in the time intervals between 8 or 10 successive transmitted pulses or pings. HR (High Residency) encodes the ID as bits within a single millisecond transmission. HTI encodes the ID in the interval between successive pulses.

It is not necessary to actually know the proprietary code in order to distinguish the individual transmitter. If the tag can be read before implantation, it is only necessary to match the recorded code with the received signal in the water.

Ideas for further experimentation

Using an ESP32-S3 with an I2S I/O input, it is possible to sample at up to 5 MHz. Fairly simple DSP techniques can filter the signals at 69 KHz (or any other frequency). Detecting the timing of the pulses would then be quite easily achieved and individual fish could be identified.

Another option would be to feed the transducer signal to an Android app on a phone or tablet. There is plenty of computing power in a phone to handle the digital signal processing. The interface might work through the audio input or a USB interface could be implemented.

With a more sensitive transducer and the addition of weak signal digital signal processing techniques to extract signal from noise, it would be possible to build an extremely sensitive detector capable of monitoring the fish at a considerable distance.

I can't help but wonder if it is possible to measure doppler effect on the signal to get an approximation of the speed of motion of the fish. The tag signal would have to last long enough to detect the change in phase of the successive pulses of a wave train.

Placing 4 or more sensors on the surface and comparing precise arrival times of the signals would provide a 3D measurement of the location and movement of the fish. The GPS coders have done all the math for us already. A fun future project.

The hydrophone can be connected directly to an SDR to monitor all the underwater ultrasonic activity. A KiwiSDR can monitor down to 10 KHz and produce a colourful waterfall plot on a phone display. The receiver could demodulate the tag codes similar to my beacon tracking extension.

It would be interesting to use a heterodyne mixer to tune the ultrasonic frequencies to the audible range in order to listen to the sounds underwater. Bat monitor circuits would work perfectly for this. Spectrum displays on a phone via the microphone input would make this an interesting project both for listening to other ultrasonic sounds and fish tags.

I hope the batteries in the fish transmitters will last long enough for me to try some of these ideas next summer.