Introduction: Bluetooth Outlet Controller for Aquariums, Hydroponics & Fermentation

This controller is designed with the saltwater aquarist in mind, although it's also great for controlling heating and pumps for hydroponics, aquaponics, making wine and brewing beer!

If you're new to electronics, micro controllers or Arduino, here are some good links to get you started:

Getting Started with Arduino (Adafruit)

Selecting an Arduino (Adafruit)

Arduino Software IDE (arduino.cc)

Initial development was done on an Arduino Uno R3 board with supporting modules and sensors as noted in the sketch. The sketch is pretty straight forward, and I've added comments to describe what's going on and how you can customize this project to suit your needs.

The initial version of this project has four relays, each controlling an outlet:

  • Relay1
    Turns ON and OFF at user set times of day
  • Relay2
    Turns ON and OFF based on user set temperatures
  • Relay3
    Cycles ON/OFF based on a user set period (for example, 30 minutes ON, 30 minutes OFF)
  • Relay4
    Turns an outlet OFF when a push button is pressed

New for version 1.3beta1: Added Bluetooth and created an Android app so you can set the alarms and temperatures from a phone or tablet.

Each relay in turn controls an outlet in a modified power strip.

Additional details are provided with the sketch: Github Outlet Controller Sketch and Android App

This project uses the following hardware:

  • Arduino Uno R3
  • DS3231 RTC module
  • 16x2 LCD with an I2C serial backpack
  • 4 channel 5V relay module (optically isolated, rated for 10A at 110V)
  • DS18b20 waterproof temperature sensors
  • Momentary push button switch
  • Bluetooth HC-05 module (New!)

Step 1: Connect the DS3231 RTC Module to the Arduino

The DS3231 is an extremely accurate real-time clock (RTC) that communicates with the Arduino via a serial protocol called I2C. The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an active-low AM/PM indicator.

In this project, connect the following pins:

  • GND to Arduino pin GND
  • VCC to Arduino pin 5V
  • SDA to Arduino pin A4
  • SCL to Arduino pin A5

Pins A4 and A5, along with the sketch code, provide the I2C communications. The 32K and SQW pins on the RTC are not used in this project.

Step 2: Connect the LCD With I2C Backpack to the Arduino

A standard 16x2 (two rows of 16 characters) requires six data line connections to the Arduino. Enter the I2C backpack that allows the Arduino to serially communicate with the LCD and uses just two data connections.

Like the RTC, make the following connections:

  • GND
  • VCC
  • SDA to Arduino pin A4
  • SCL to Arduino pin A5

Step 3: Connect the DS18b20 Temperature Sensor to the Arduino

The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with Arduino. It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area.

Make the following connections:

  • GND
  • VCC
  • DQ to pin 2 of the Arduino
  • Place a 47K resistor between VCC and DQ (pull up resistor)

Step 4: Connect the Optically Isolated Relay Module to the Arduino

Each of the relays is assigned to an output pin on the Arduino, so they can be turned ON or OFF individually. At the relay outputs are a Common, NC (normally closed) and NO (normally open) connector.

When an aquarium device will be ON most of the time, I use the NC connection and turn the relay ON when I want the device to turn OFF. This saves power because the relay is only on for shorter periods of time. See the sketch for more details on which devices are coded to operate with this connection.

Make the following connections:

  • GND
  • VCC
  • IN1 to Arduino pin 8
  • IN2 to Arduino pin 9
  • IN3 to Arduino pin 10
  • IN4 to Arduino pin 11

Step 5: Connect a Push Button Switch

When it's time to feed the fish, it's best to have the pumps OFF so that food doesn't get sucked into the sump before the meal is over.

The sketch looks for a LOW pulse at the button to initiate the FeedingTime! event.

Make the following connections:

  • Connect one side of the switch to GND
  • Connect the other side of the switch to Arduino pin 5

Step 6: Upload the Sketch Into the Arduino.cc IDE, Verify and Upload

You should be up and running with the standard sketch. Hopefully you'll find the comments in the code to be sufficient to make any desired modification to time or temperature events. Enjoy!

Step 7: Adding Bluetooth and an Android App

In this next step we'll be adding a Bluetooth HC-05 module to the Arduino so you can set the timers and temperatures from your Android phone or tablet.

You'll need the following additional hardware: HC-05 or HC-06 Bluetooth module, 1k resistor, 2k resistor.

Make the following connections:

  • Connect VCC to Arduino +5V
  • Connect GND to Arduino GND
  • Connect the Bluetooth TXD to Arduino Uno RX pin 3 (yes, TX->RX)
  • Connect the Bluetooth RXD to a resistor voltage divider. This pin should not be directly connected to the Arduino Uno TX pin 4 because the HC-05/06 boards operate at 3.3v. See the image above for an illustration of the wiring

Note: The sketch (v1.4) uses SoftwareSerial to assign pin 3 to RX and pin 4 to TX: this avoids conflicts with USB serial communications.

You can now use the Android app on GitHub page to set alarm times and temperatures.

Step 8: Using the Android App to Set Alarms and Temperature

If you own an Android phone, you're in luck - there's an app for that! In fact, I've taken the pre-defined alarm times and temperatures out of the Arduino sketch starting with v1.3beta1 since Bluetooth is a much more flexible route.

To use the app:

  1. Click Connect to Device, then select the HC-05 or HC-06 from the list. Note: Your Bluetooth module must be in pairing mode, which is the default mode when powered-up. Most modules quickly blink a red LED when in pairing mode, then slow down the blink rate once paired.
  2. The "Not Connected" text changes to "Connected" with a green background.
  3. Enter the ON and OFF times for Relay 1. Enter HH,MM,SS (no spaces, with a comma between your hour, minutes and seconds selection). For example, 6:30 AM would be 6,30,00 and 6:01:30 PM would be 18,01,30 (use military time).
  4. Click Update Relay 1 Alarms Scroll to the bottom of the screen; you'll see a confirmation of your entries displayed in the Status window.
  5. Enter the relay2 set point temperatures in degrees F (rounded to the nearest degree. For example: 81)
  6. Click Update Relay 2 Temperatures. Confirmation of your entries is displayed in the Status window.
  7. Enter the cycle time for relay3 in the format HH,MM,SS. For example, 00,30,00 will turn the relay ON for 30 minutes and OFF for 30 minutes.
  8. Click Update Relay 3 Period. Confirmation of your entry is displayed in the Status window.

Your aquarium controller is now customized with your settings.

Step 9: Packaging the Bluetooth Outlet Controller

Now that the hardware and software are complete, it's time to package the components so that the controller can be put into service.

Additional Material and Tools Required:

  • Enclosure (shown above is the Hammond 1591GSBK ABS Project Box)
  • Power strip or outlets
  • Hookup wire
  • Solder and iron
  • Hot glue gun
  • Drill and bits

Note that I elected not to include the LCD display because it is difficult to mount, adds cost to the project and isn't necessary with the Android Bluetooth App.

The photo above shows a possible layout and assembly of the components, but there are many other ways to complete this project!

Comments

author
DIY Hacks and How Tos (author)2017-02-25

Great idea. With a setup like this, I might actually be able to keep a set of fish alive.

author

Thank you! I created this project to provide DYI-ers (like me) the opportunity to trade some sweat equity for a low cost aquarium controller.