Thursday, February 4, 2016

Fish tank and Raspberry Pi

First of all, sorry if lately my posts are published less often than before, but I'm quite busy with several other things and my time for hobbies is quite limited...

Today I will show you a project made for request.

One friend have a small fish tank and he wished to make a really small system, just to check the temperature, pilot lights and few other things .

One Raspberry Pi model A+ was perfect to manage the fish tank with those features, so I decided to start this project and I finished it in few days.

Now this system has been named Aquarius and it's working as it was requested, with some small addition made by myself.

These are the features of the system:
  • Water proof temperature probe
  • TFT display to show water temperature (and date/time)
  • TFT backlight driven by RPi (brightness can be changed)
  • RGB led strip for tank lighting
  • Programmable light color (4 time zones with different settings)
  • Temperature settings for turning on and off a 12V fan
  • Possibile future implementation for automatic fish feeding
  • Web interface to change settings
  • Wi-fi connection to lan

As you can see it has several nice features, but it can be easily upgraded (or downgraded).

Let's see the schematic (click on the image to see at full size):


Actually, the finished system is a bit different, as for Raspberry Pi power I did not use a 7805, but this one as I had it available.
For the mosfets I used 4 IRLB-8721 (the fifth, for food dispensing has not been installed for now, but it would be the same one).

Note that the mosfets are a bit critical. The activation voltage should be low enough to be driven directly by RPi GPIOs, otherwise you need to add a transistor for every mosfet.
Here you can see the RPi connected to the board with all the components and the TFT display:


and the external devices (led strip and temperature probe):


Of course the case has been 3D printed at home...


Finally everything is fitted together:


It's time for a bit of testing...


You can clearly see the intense light from the strip and the temperature shown on the display. I also checked the fan output, but took no photos, sorry...
After some software fix I installed on the fish tank to see it working for real:


For the web interface I installed Apache and PHP. Every change in the settings is written in a text file that is read by a Python script launched at boot.

The script reads the text file, eventually updating the script internal settings, then it reads the temperature and shows it on the display with date and time.
After reading the temperature it checks if the fan should be turned on or off and checking the time of the day it sets the color of the leds strip.
After a pause (1 minute) it starts these tasks again.

To act on the GPIOs I used the new GPIO Zero library that can also manage pwm output (mandatory to drive the rgb leds).

You can download my script and the display library at http:///www.mascal.it/public/aquarius.zip but note that it could still have some issue. You can download and use it as you wish, but I will not give too much support for these files because as I wrote above, I really have few spare time.
Anyway you can try to ask and I promise that I will try to answer!

Below you can see the web interface from a smartphone (but it's almost the same on every device). Note that this interface cannot be downloaded for now, so you will not found in the above archive.


The language for the interface is in italian, but you should understand without too much trouble.

You can set two temperatures for the fan (one for start and one for stop). There is no check, so you can actually set the start below the stop, but this will just set the fan to off.

Then you can set the time and color for the four zones (again no check for the time congruence). For color setting I used the JSColor library.

In the last update (not showned here) there is also a restart button, just in case there is some trouble within the scripts...

I really like this project. Surely it could have been programmed a bit differently, but it does what requested and a bit more.
Probably in the future the feeding system and a PiCamera will be added, but that's a different story.

Anyway the fishes seem to like it too!


3 comments:

  1. Hi, I'm relatively new to the RPi and love the GPIOZero library, as it makes GPIO handling simple and I'm trying to use a PHP webpage as a frontend and a Python script using GPIOZero to control the GPIOs. It seems you have done this, but I couldn't see your script (http:///www.mascal.it/public/aquarius.zip) to see how you did it, can you help? Thanks, Steve.

    ReplyDelete
    Replies
    1. Ehm...sorry, just my fault. Now the archive should be downloadable from that link.

      Delete
  2. Great post, thanks for sharing it

    ReplyDelete

Note: Only a member of this blog may post a comment.