Aquaponics automation

Hi and thanks for taking the time to read my post. I've been scratching my head a while now, pouring through articles and testing different stuff. I've got a fairly mature aquaponics setup in my greenhouse, 1000 litre fish tank with some carp and then 2 grow beds, one high level that fills and empties using a pump on a timer with a syphon and the low level that I was using a pump with a timer to fill and a sump pump with float switch. I had lots of issues last year with pumps jamming and tanks emptying including the fish tank. I have some experience with software engineering, work in IT for a living and have started training in electrical. I've been 'playing' with the Arduino and starter kits and have come across them as part of the day job so wanted to do something smart. Prior to starting with Arduino I purchased a GZF-12 water level sensor board, very simple high/low sensor with relay to turn on either a fill pump or empty pump. This would do half the job for what I need but I need to fill and empty the lower grow bed on a schedule and also stop if there is a problem. For future improvements I would also like to build in some additional sensors for temp, humidity, light and perform various actions depending on values.

I've been looking at water level sensors for the Arduino but I've not got anything to make one with the bits I have a side from an ultrasonic sensor and with the shape of the tank and the levels of humidity etc this would not be great. I could probably do something really nice with an Adafruit 12" Standard eTape Liquid Level but its £50 when I know I can do something with what I have. I've tested the GZF-12 board and it works, what I've been trying to do is use the Arduino to send a 5v to the common on the board relay and then send an output from the other fill/empty outputs to analogue inputs on the Arduino to attempt to monitor which pump is active. I assumed it would show a 5v from one of the outputs which I could then do some conditional operations on.

The issue I'm having is that my analogue inputs never show 0v even with nothing connected, if I connect the 5v on the board to the analogue it registers 5v most of the time but this isn't constant. If I then try this through the relay I get a similar read when its open of 5v most of time but when its closed I get anything from 0 up to 5v randomly. With these fluctuating values it makes writing code very difficult, I was considering using some averaging of values that I think would work but wanted to float the idea/problem and see if anybody had any better advice. Thanks again for reading.

If I then try this through the relay I get a similar read when its open of 5v most of time but when its closed I get anything from 0 up to 5v randomly

It sounds like you have a floating input. An input that has nothing connected to it will pick up noise from the environment. You may be able to fix that by putting a pulldown resistor between the input and ground. The resistor could be 10K to 1M.

but wanted to float the idea/problem

Well you've hit on the problem right here, when a pin is not connected it is considered a "floating pin"
it is basically a little antenna and will pick up random signals. Just waving your hand over it can change it's state. If you want to see 0 just connect it to ground.

For a digital pin a pullup or pulldown resistor is needed. This ties the pin to ground(pulldown) or 5v(pullup) when there is no signal present. there is a built in pullup resistor that can be activated in code.


If your signal is either 5v or 0v that is a digital signal and you should use a digital pin.
Analog pins sense a signal that can be anywhere between 0-5v. An analog pin should never be floating and is typically used in a voltage divider set up. Analog pins can also be used as digital pins.

Any arduino can work with simple and cheap float switches.
You can even use a few in series with resistors on one analog pin.

The ultrasonic makes it easy to watch the levels.installing on a pipe can allow you to put it external to the tank.

BME280 makes quick work of AIR temperature.
DS18B20 can be had in a waterproof version for submerged use.

Hi and thanks very much for the replies, switched to digital inputs and get a definite 1/0 the high/low water marks. Going to write out my code to activate the pumps now...