Arduino Powered Aquarium Controller – Part 2

Welcome to part 2 in building an Arduino powered aquarium and aquaponics controller. In this post I will look at putting together and testing the hardware we discussed in part 1. Speaking of part 1, if you have not read it yet, I suggest you check it out.

The Equipment

Through this blog I will be using the following equipment:

  • Arduino Uno with USB cable
  • Adafruit CC3000 and Data Logging Shields
  • Waterproof DS18B20 temperature sensor x 2
  • 4.7k ohm resistor x 2
  • HC-SR04 Ultrasonic Ping sensor
  • 4 core cable
  • Soldering Iron and Solder
  • 3 and 4 segment plugs (Optional)
  • Pins for the end of the cables into the shields.

The Hardware

The hardest part by far for this whole build was waiting for the parts to arrive. Here in Australia it is not uncommon to have to wait a couple of weeks for parts to arrive. Finally the parts from Adafruit arrived and here they are in all their glory. Not shown in the image are the DS18B20 waterproof temperature probes and ping sensors that I ordered from eBay.

Lets start with the soldering the most exciting parts, the Arduino Shields. The best part is that this is also the easiest soldering to do, so if you have never soldered before then you can get your hands dirty on the easy stuff. Soldering irons can be picked up cheaply from most electronics or hardware stores, so there is not a massive investment here if you don’t have one already. You want the pins of the stacking header poking through the bottom of your shield. Then it is just a matter of soldering them in.

Here is the CC3000 shield all soldered up and ready for testing. The data logging shield is exactly the same to solder up.

Next I soldered the ultrasonic ping sensor to the 4 core cable I had lying around. I also installed a plug into the cable so that I can easily remove the sensor in the future without having to disturb the Arduino. On the end of the cable I soldered on pins so that it is easy to plug into the shield stacking headers.

The same process was followed for the DS18B20 temperature sensors. The only difference being that I soldered the pull up resistor into the cable, rather than having to solder onto my shield. The only reason that I did it this way is so that I can reuse the shields at a later date without having to desolder them. Below you can see the two probes in their stainless steel housing and the resistor soldered into the cable before I insulated it all. Make sure you note which colour wire you solder to which pin, so you can correctly connect it to your Arduino board. Below is a link to the datasheet, so you can see which pin does what. I soldered the Vdd and Gnd pin for each sensor together so that I can power them both easily from the Arduino board. If you want to, you can solder the DQ lines together as well, however I wanted to leave them separate.

The hardware for our setup is now ready to test! So to summarize, you should now have your Arduino with the wireless and data logging shields ready to be stacked on top, 2 temperature probes with the required amount of cable for your application and an ultrasonic ping sensor with cable.


To keep things simple, we will just use existing libraries to test our equipment. To save space, I have linked to a great tutorial on Adafruit on how to install the libraries as well as the links to each required library below. It’s ok, you can read it. I will wait for you to come back.

Now you are back and have the linked libraries installed lets start our testing with the CC3000 wireless module. To test it I used the ntpTest sketch provided by Adafruit. You will need to change the following lines to suit your wireless setup. In my case I used my Android wireless hotspot, so my SSID was AndroidAP12345 and my password is a secret!

#define WLAN_SSID            "myNetwork"
#define WLAN_PASS            "myPassword"

Then attach your Arduino with your USB cable and press the Upload button at the top left. This will then compile the sketch and upload it to your Arduino board. Once the sketch has uploaded click Tools -> Serial Monitor or press Ctrl+Shift+M to bring up the serial monitor. Change the baud to 115200 to match the sketch and you should get an output similar to below.

Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes

Initialising the CC3000 ...
Firmware V. : 1.24
MAC Address : 0x08 0x00 0x28 0x59 0x89 0x1D

Deleting old connection profiles

Attempting to connect to AndroidAP12345
Request DHCP

IP Addr:
Locating time server...
Attempting connection...
Issuing request...
Awaiting response...OK
Current UNIX time: 1408118916 (seconds since 1/1/1970 UTC)

Testing the RTC on the data logging shield is even easier. Load up the ds1307 sketch from the RTClib examples, upload the sketch to the Arduino and bring up your serial monitor again. This time your baud needs to be set to 57600. You should get an output similar to below.

2014/8/16 0:14:23
 since midnight 1/1/1970 = 1408148063s = 16298d
 now + 7d + 30s: 2014/8/23 0:14:53

The temperature sensors are just as easy as the RTC. Load up the DS18x20_Temperature sketch from the OneWire library. Connect the Vdd pin to 3v, the Gnd pin to GND and the DQ to pin 10 on your Arduino. You can connect both of the temperature sensors at the same time to test them. The sketch is smart enough to work out if there are more than one sensor on the pin at once. You should get an output similar to below.

ROM = 28 6C F4 14 5 0 0 1A
  Chip = DS18B20
  Data = 1 90 1 4B 46 7F FF 10 10 92  CRC=92
  Temperature = 25.00 Celsius, 77.00 Fahrenheit
ROM = 28 B1 40 15 5 0 0 4B
  Chip = DS18B20
  Data = 1 97 1 4B 46 7F FF 9 10 1C  CRC=1C
  Temperature = 25.44 Celsius, 77.79 Fahrenheit
No more addresses.

Last but not least we need to test our ultrasonic sensor. Load up the NewPingExample sketch from the NewPing library. Connect Vcc to 5v, Gnd to Gnd, Trig to pin 12 and Echo to pin 11. Upload the sketch and start your serial monitor. You want your baud at 115200 again for this sketch. You should get an output similar to below.

Ping: 11cm
Ping: 14cm
Ping: 15cm
Ping: 19cm
Ping: 21cm
Ping: 25cm
Ping: 27cm
Ping: 30cm
Ping: 33cm
Ping: 35cm
Ping: 39cm
Ping: 41cm


Today we took the time to set up the hardware for our aquarium controller and test it all. For me, the most boring part of an electronics project is the hardware. I prefer the software side of things, so its all down hill now for me. Hopefully the process was not too tedious for you and that all your testing was easily completed. The next step in the process is to tie all the sensors together to get a cohesive system. We will look at getting each of the sensors data into the Arduino, with each result being updated at a consistent interval. Stay tuned! To see the next article in this series check out Part 3.


Arduino Libraries

Adafruit_CC3000 Library

Adafruit RTClib Library

OneWire Library

NewPing Library

DS18B20 Datasheet


Leave a Reply