Aquarium Automatic Top Off System

I have been searching and not finding anyone having done what I want to do. Not sure if this is a better suited project for Arduino or Pi so seeking a little guidance. The dumb version is simple and I have it worked out already. It is 4 switches, a dual relay board, a dual output power supply and a 12v dc pump.

Two switches in series for the aquarium itself. One for water level which is normal open, closes when the water level drops. The second is normally closed and slightly above the first...it opens with water touches it to prevent over fill should the primary switch fail to open again at normal water level.

In the top off reservoir there will be two more switches at the same level. One normal closed and in series with the two above and the 4th switch is solo and closed. Reservoir empty opens the 1 of 3 to prevent the pump from running dry. The 4th closes and sets off a flashing LED and chirping alarm.

All of that is simple enough, done, tested and functioning.

Where the "smarts" come in is notification and data gathering. This is also where I have ZERO idea how to do or what to do that which I would like done.

  • In addition to the basic alarm described above I would like the 4th switch to trigger a text alert to my phone and/or an email. Either device could simply be on my WiFi network or I could easily drop a network cable. I could really stop here and be happy but why stop right?

  • it would be nice to set up a time to run limit on the pump as a secondary safety to the upper switch.

  • monitor how often the pump runs and for how long.

  • If the timer or upper switch kills the pump send alert and maybe keep it offline till its manually.

  • What is the water temp and ambient air temp when the pump runs...and maybe measure the humidity as well.

So, any thoughts?

A font

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Great project.. An Arduino is ideal for this basic logic control project.

The time time monitor is a good idea incase of level switch failure.
Your LOW and HIGH level switches do not need to be connected in series, they need to use there own separate contoller inputs.

Is there a part of the aquarium that is normally dry, that would become wet, if you had an overflow?
You could put a simple moisture detector there to be your last line of defence.
Most of the cheap detectors will corrode up and fail, but because in your case it is in a dry environment the would not necessarily happen.

A third level switch would be good to detect over filling and remove power directly from the pump.
This is independent of the controller, incase of controller or motor switching device failure.

Can you tell us your electronics, programming, Arduino, hardware experience?

Tom... :slight_smile:

For logging or monitoring/controlling:

Can you plug the Arduino into the USB port of a desktop or laptop computer and send serial messages?

The Arduino side is really easy, and a Python script or application written in just about any language on the desktop can monitor the data for logging or control.

Hi,
If you have a working proof of concept, can you post copy of your code please and what model Arduino are you using.
The forum instructions I linked you to, will show you how to post your code.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

For clarification, the "switches" in this case are simple float switches at this point. If I get past this then I may move to optical but that is phase three at best.

Remember, even without logic this is an already functional system. The main purpose of adding some intelligence is primary to alert me that I need to refill the top off reservoir.

TomGeorge:
Great project.. An Arduino is ideal for this basic logic control project.

The time time monitor is a good idea incase of level switch failure.
Your LOW and HIGH level switches do not need to be connected in series, they need to use there own separate contoller inputs.

In series the second is in a state of closed normally and only open if the primary switch has failed to open again when normal level has been achieved. Without the smarts this is just switches to interrupt the flow of power to the pump. With intelligence taking these two(three really) is just less wiring or "simpler". To me, less is more in this regard. In series only ONE thing can go wrong, wired separate two can. Now, separately there is a benefit of sorts. Seems easier for that to be another message alert. I am fairly sure I would prefer the 1 vs 2 failure points over the alert. If the tank level is higher than normal I would potentially see it in two ways were I home. If I am away there is nothing I can do about it anyway. Overflowing in any case is catastrophic to the tank and if I am home and aware of the situation I can perhaps at least minimize the clean up/floor damage.

TomGeorge:
Is there a part of the aquarium that is normally dry, that would become wet, if you had an overflow?
You could put a simple moisture detector there to be your last line of defence.
Most of the cheap detectors will corrode up and fail, but because in your case it is in a dry environment the would not necessarily happen.

No, and the over flow is but one of two problems. The other is this is a marine aquarium and over flow means salinity crashes and nukes the tank.

TomGeorge:
A third level switch would be good to detect over filling and remove power directly from the pump.
This is independent of the controller, incase of controller or motor switching device failure.

The second switch covers this and a simpler third option might be a manual float valve...though a third switch is not out of the question. That would be a total of 5 though and that gets into the I dont know territory. Can I have that many?

TomGeorge:
Can you tell us your electronics, programming, Arduino, hardware experience?

[/quote]

Electronics of this are solved. Programming, zilch. Ardunio...heard of it. Pi, baby PC on a chip. From what I can tell Arduino might be cheaper for JUST the alerting of an empty reservoir but if I add in all the rest of that it might be better on Pi. Seems like a Pi Zero would be about the cheapest route in any event. In either case I would have to learn the coding language (or get my 12yr old to take it on as a project)

Just exploring the feasibility of this all.

Hi,

Arduino might be cheaper for JUST the alerting of an empty reservoir but if I add in all the rest of that it might be better on Pi.

Get a UNO and play.. even your 12yo.

You now need to draw a diagram showing your component setup and basic line connections, not a schematic, but a diagram showing your concept.
You can post an image of it as an attachment.

Thanks.. Tom.. :slight_smile:

something like this ?

Hi,
The image didn't take.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

It will tell you how to attach your image.

Thanks.. Tom.. :slight_smile:

How do you mean? I see it fine. Checked from a different PC without being logged in and I still see it ???

Hi,
Where is the image, on you PC harddrive?

Did you use the attachment facility at the bottom of the REPLY not the QUICK REPLY to attach the file first?

Tom... :slight_smile:

Does this work? I cant seem to get a decent link from google photos so I am trying imgur.

I drew up what I think it would look like connected to an UNO. If this looks right I am going to start trying to figure out the sketch.

Been playing around with the project again. The sketch complies with no errors but I cannot get it to work wired up and maybe its how I am doing that wiring.

From the 5v and ground on the uno I go to the +/- rail on a bread board.

Relay gnd to - rail & VOC to +
Uno pin 2 to in1 on relay
Uno pin 3 to in2 on relay

Three simple float switches from + rail to pins 5, 6 & 7 on the Uno

when the floats trigger the relay it just buzzes vs just clicking over once as expected...this is my problem

Sketch...

#define RELAY1 2 /pump relay/
#define RELAY2 3 /alarm relay_NC passes common to relay1_NO passes signal to alarm/

#define FS1 5 /primary float switch. Normally floating & open, hanging its closed to signal pump to run/
#define FS2 6 /fail safe float switch. Normally hangs closed. If floating this indicates FS1 has failed to open on refill and FS2 opens to kill pump/
#define FS3 7 /* Float switch in refill tank. Reversed so when floating its open indicating refill tank has water. When water drops it closes and trips relay2 sending signal to alarm and removes relay1's power.*/

void setup()
{
pinMode (RELAY1, OUTPUT);
pinMode (RELAY2, OUTPUT);
pinMode (FS1, INPUT);
pinMode (FS2, INPUT);
pinMode (FS3, INPUT);
}

void loop()
{
if ( ( digitalRead(FS1) == HIGH) && (digitalRead(FS2) == HIGH) && (digitalRead(FS3) == LOW) )

/*
When FS1 is HIGH its calling for water to be added.
FS2 should always be HIGH as it sits above FS1 and
should always be hanging/closed. If its open(LOW)
then FS1 has failed, kill pump with "else"
FS3 is in the refill tank...normal is closed(low) indicating tank has water
if it closes it means tank is empty, kill pump with "else"
*/

{ digitalWrite(RELAY1, HIGH); }
else
{ digitalWrite(RELAY1, LOW); }
}

Hi,

Try this for your inputs.
From this;

 pinMode (FS1, INPUT);
 pinMode (FS2, INPUT);
 pinMode (FS3, INPUT);

To this;

pinMode (FS1, INPUT_PULLUP);
 pinMode (FS2, INPUT_PULLUP);
 pinMode (FS3, INPUT_PULLUP);

The UNO inputs are floating, so you have to pull them HIGH or LOW.
The UNO has internal pull up resistors, so your pull down switch will work with this edit.
Currently your switch would pull the pin low, but after opening the digital input can float, usually staying at the level it was last set at.
Tom… :slight_smile:

The UNO inputs are floating, so you have to pull them HIGH or LOW.

Floating in this case is not the same as float switches in your aquarium, or floating switches that float on top of the water in your aquarium.

Just sayin'.

Hi,
Some more suggestions, they would make your code perform any different but make it easy to follow as it develops.

Pin Names.

#define PrimaryFloatPin      5  /*primary float switch. Normally floating & open, hanging its closed to signal pump to run*/[color=#222222][/color]
#define FailsafeFloatPin      6  /*fail safe float switch. Normally hangs closed. If floating this indicates FS1 has failed to open on refill and FS2 opens to kill pump*/[color=#222222][/color]
#define RefillFloatPin     7  /* Float switch in refill tank. Reversed so when floating its open indicating refill tank has water. When water drops it closes and trips relay2 sending signal to alarm and removes relay1's power.*/
#define PumpRelay1Pin   2  /*pump relay*/
#define AlarmRelayPin   3  /*alarm relay_NC passes common to relay1_NO passes signal to alarm*/

This makes any input or output statement just about self explanatory.
You will need to edit your pinMode statements too.

Input variables and reading inputs.

 if ( ( digitalRead(FS1) == HIGH) && (digitalRead(FS2) == HIGH) && (digitalRead(FS3) == LOW) )

This is fine but it is easier if you read ALL your input together at the top of the loop, then use the variable values.

So first define your input values before void setup().

bool PrimaryFloatStatus;
bool FailsafeFloatStatus;
bool RefillFloatStatus;

Then read them at the beginning of the loop;

PrimaryFloatStatus=digitalRead(PrimaryFloatPin);
FailsafeFloatStatus=digitalRead(FailsafeFloatPin);
RefillFloatStatus=digitalRead(RefillFloatPin);

Then this if statement ;

 if ( ( digitalRead(FS1) == HIGH) && (digitalRead(FS2) == HIGH) && (digitalRead(FS3) == LOW) )

Becomes;

 if ( PrimaryFloatStatus == HIGH && FailsafeFloatStatus == HIGH && RefillFloatStatus == LOW )

I hope this helps, you are on the right path with your logic.
The names I have suggested are not etched in stone, programmers have different naming structures to mine.

Tom... :slight_smile:

TomGeorge:
Hi,

Try this for your inputs.
From this;

 pinMode (FS1, INPUT);

pinMode (FS2, INPUT);
pinMode (FS3, INPUT);




To this;


pinMode (FS1, INPUT_PULLUP);
pinMode (FS2, INPUT_PULLUP);
pinMode (FS3, INPUT_PULLUP);



The UNO inputs are floating, so you have to pull them HIGH or LOW.
The UNO has internal pull up resistors, so your pull down switch will work with this edit.
Currently your switch would pull the pin low, but after opening the digital input can float, usually staying at the level it was last set at.
Tom... :)

Made those changes and the relay just turns on and stays on no matter the position of the float switches...so a plus in that the relay is not switching on and off to make that buzzing noise but not also turning off at all.

Hi,
Okay,
Post you new code using code tags?
Have you got a DMM to check your input pin voltages changing?

We may have to start using Serial Monitoring to debug and see what your code is doing.

Thanks.. Tom... :slight_smile: