NOTE: this project works with 240vac, if you are not qualified/experienced do not proceed!
Our fish tank resides in our living next to our tv so we can view the fish and watch them, There is basic control for the light which has a touch switch on top, The aeration has no switch whatsoever so this is needed to be unplugged if we wanted some peace and quiet or wanted to watch the tv at a reasonable volume. This meant the aerator was occasionally left off for days or hours unintentionally and this wasn't ideal for the well being of the fish. At the time I had worked through the arduino starter kit and wanted to build something for the home after discovering the ESP8266 range of devices work with Arduino IDE and had purchased some.
My first idea was to purely turn the aerator on/off remotely alongside a time program. Additionally when I started looking into fish tank control I found some off the shelf light timers but this didn't allow for remote control, whilst reading into the light timers some internet commentary talked about recommended minimum light times for fish tanks so this was ideal inclusion in my project. Lastly I thought I may as well include the filter as well so it could be turned off easily when performing maintenance.
Thus the premise for my first project began.
Project Requisites:
- The controller/switches have to be enclosed and safe from fingers
- Look fairly neat - I don’t have a 3D printer so I had to use what I could get.
- Be remotely controlled.
- Have time program control along with the ability to remotely change the program.
- Give my wife the ability to control it when I am not home.
- automate the aerator so it runs throughout the night at least
Note, the Light and the Filter are supplied with 12vdc which is quite a safe voltage to work with however the aerator had its own pre-formed plugin power supply, So I had to incorporate a mains voltage solid state relay and UK Socket outlet. I considered the aspects and have fuses in place to protect against overcurrent at ratings ensure the supply cable etc is not overloaded.
Software (Arduino IDE) Design/OperationThis program connects to MQTT broker on your network, setting up a broker is not part of the project but is needed for it to work.
The program is written to sync with an internet time provider once an hour then as the program loops it doesn’t proceed until a specified hour and minutes is equalled. For example in the morning at the hour of 7 and minute 0 the aerator will turn off. These can be overridden via a remote MQTT message received on the ’home/fishtank/control’, for simplicity I have used simple numbers that correspond to a action for example number 1 received will turn on the lights. If the controller receives a control number it feeds back the received number on the ’home/fish tank/status’ topic, this was mainly for debugging purposes but I left it in.
To cover off the remote update of times for the switching points I have enabled over the air updates from Arduino IDE, this means relatively easily I can change the times.
BuildUsing the wiring schematic solder the components, I did first prototype and test on a breadboard before soldering permanently.
Once built I prepared the enclosure (box), I noted during testing that my esp generated some heat so I drilled some ventilation holes, additionally I drilled a 20mm hole for a compression gland for cable entry and hole in lid for the socket to recess into. The socket outlet mounts on the lid (top of the enclosure) meaning the aerator plug can be unplugged if needs be and/or just turned off at the socket (the old fashioned way). The light/filter had pre-formed connectors back to original power supply this had to be cut and connected where indicated on the wiring schematic leaving enough lead to reach the Light/Filter.
The original light/filter psu was discarded and replaced with the replacement that was rated higher as it would also be providing power for the ESP12. The incoming 240vac cable and 12vdc input cable along with the light and filter cable go through the compression gland.
To accomplish remote control I came across a Android App called ‘MQTT Dash’ this provided a nice looking but easy to use and setup app to remotely control the fish tank. This app is installed on both my phone and my wifes phone so either of us can control it.
Setup Broker connection
Setup tiles
Setup Control Tile
Setup Status Tile
Test and Enjoy
Comments