Arduino Fish Tank Cooler

About: Web-designer.

Hey everyone, this is Alex here! Today I want to share with you mine cooling system for small 10 liters fish tank. I am from Ukraine an this year summer is getting very got sometimes. So at small fish tank temp goes up very fast. I have another project, based on Pelletier elements, but until power supply will be finished I decide to make this simple cooler for my fish.

Step 1: Tools and Parts

If you already have some arduino this means that you have some stuff for soldering.

So in our case you will need:
1. everything for soldering
2. Some wires
3. Power supply (I am using 12v 1000mA dc from old adsl router) 3-5 bucks
4. Arduino (obvious) I am using pro mini, bought on eBay for 5 bucks
5. Relay module for arduino 5 bucks
6. Ds18b20 temperature sensor (grab one on eBay in waterproof housing) 2-3 bucks
7. 4,7k resistor for ds18b20 sensor
8. Pc fan (120mm - is the best choice, because of less sound and more efficiency) 3-5 bucks
9. Plastic case (I used one for electrical commutation)
10. 2 Sushi sticks (fast placement for fan)
11. 4 plastic fasteners Total cost is about $20-25

Step 2: Connection

So everything very simple here:
1. Connect relay module to arduino digital pin, ground and vcc(+5v)
2. Connect fan's one wire to relay module screw part and another to power supply wire (please note, fan will not work from digital pin 5v power if you will try to run it as led). Make same with another wire of power supply and fan wire, so when relay will be turned on you will get power on your fan. (If not clear - let me know)
3. Connect power to your arduino from same power supply that was used for fan power. ( in my case with arduino mini it was connected to raw and gnd pins, because voltage was more than regulated 5v)
4. Connect ds18b20 sensor. To get this thing working you must attach 4,7k resistor between vcc and signal pins of sensor. I was using 3 wires connection without parasite power mode. You must get 5v from your arduino to power up this sensor.

DO NOT PUT 12v on sensor you will burn it!

Please notice that you can get sensor where wires can be different by color. Mine was with red, green and yellow wire colors and instead of sellers explanations - red was vcc, green was signal and yellow was ground. So you must experiment here if your sensor will show something not real.

Step 3: Programming

I was testing few different ways how it can work and decide to stay with one that I will post here.

So how it works?
When your water temp goes higher than 25 degrees by Celsius fan start running until water will drop to 24, after that it will turn off. Pay attention to your water level, due cooling your water will go to air and water level will drop pretty quick. I will not explain how to connect arduino pro mini thru USBtoTTL adapter to upload your sketch, there a lot info about that in google.

Here is the code, you can modify it, depending from temperature needed:

#include <OneWire.h>

int DS18S20_Pin = 9; //DS18S20 Signal pin on digital 2
int relay = 12; // Fan relay on pin 12

//Temp settings in celsius you must keep it with dot and value after dot
float high_temp = 25.00;
float norm_temp = 24.00;

//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // ds18b20 on digital pin 2 or change to your ditial pin number

void setup(void) {
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH); // Make relay off be default to prevent clicking at startup

void loop(void) {
  float temperature = getTemp();
  Serial.println(temperature); //Print in serial current temp
  Serial.println(high_temp); //Print in serial predefined high temp when fan will turn on
  Serial.println(norm_temp); //Print in serial predefined normal temp when fan will turn off
  delay (800); // Make some delay to see values in serial monitor
  if (getTemp() >= high_temp) // FAN goes ON  when water reach high temp
          digitalWrite(relay, LOW); 
  if (getTemp() <= norm_temp) // Fan goes OFF when temp become normal
          digitalWrite(relay, HIGH);

//////////////////////////////////////////////////////////////////////////////////////////////////////// Working with DS18B20
float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( ! {
      //no more sensors on chain, reset search
      return -1000;

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;

  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();;   
  ds.write(0xBE); // Read Scratchpad

  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] =;
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  return TemperatureSum;

For example - my room temperature is about 26-28 degrees by celsius, fish tank is small enough - 10liters, to make water drop down from 25 to 24 degrees it takes about 7-10 minutes. You can make less temperature difference, but then your fan will work more often but with shorter time periods. Hope this device will help you to get down your fish tank temperature if there no Air conditioner in your house.

Sorry for my English, it's not my native language, but I hope you will get the idea how it must work :)

Comments and critics are welcome.

P.s. probably will make custom pcb for this project in near future. Stay tuned, in-apartment aquaponics setup are almost done to be shown here.

Cheers, Alex.



    • Epilog X Contest

      Epilog X Contest
    • Comfort Food Challenge

      Comfort Food Challenge
    • Cardboard Challenge

      Cardboard Challenge

    9 Discussions


    3 years ago on Introduction

    I would rather take a 555-Monoflop for such a simple task.


    4 years ago

    Cool...would you please give the complete video, picture of this project or diagram? Thanks :)

    2 replies

    Reply 4 years ago on Introduction

    Hi, iI am sorry, but it was long time ago and there not too much photos from this period of time. :(


    Reply 4 years ago

    Ohh please help me, I really need the diagram at least :(


    5 years ago

    78-80 is too much I guess for betta, right now temp is 75,2-77. Thx for comments!

    1 reply

    It looks like you have a betta, they don't like cold water. They are a tropical fish, and will do best at around 78-80 degrees Fahrenheit. You probably should be making a heater. :P


    5 years ago

    Im sure your fish are much cooler. I need one for my pool!


    5 years ago

    Im sure your fish are much cooler. I need one for my pool!