Welcome to the long overdue part 3 of my Arduino powered aquarium and aquaponics controller. In this post I am going to outline some major design challenges I faced, the resulting changes I had to make and detail getting some simple data logging running. Before we continue, if you have not seen the earlier posts in this series be sure to check them out so you can follow along. Here are the links for Part 1 and Part 2.Continue reading

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.

Continue reading

Arduino Powered Aquarium Controller

I thought I would write a few blog posts on an Arduino powered aquarium and aquaponics controller that I have been planning for some time. I have tried to start this project a few times now with various micro controllers, but each time I reach a point where I had some sensors logging to a SD Card and then the project falls over. With my recent desire to learn more about the Arduino community, I figured why not try again but this time document my success (or failure) for the world to see.

To start off, I will take a look at the hardware options, the ones I have chosen and why. Bear in mind, especially if you are new to electronics, that there is no right or wrong way to do things. If you see merit in another way then do it. Make it your own project. You will learn far more than just copying me. If you do go another way, then let me know. I would love to hear why you went a different route and how successful you have been.

Initially I will just be looking at a simple system, looking at water and air temperature as well as the water level in the aquarium. I plan to add more to the system over time, but I wanted to start simple and actually get something working. With that in mind lets dive into the hardware.Continue reading

The Arduino is one of those micro-controllers I have been holding off using because I was worried about learning C/C++. Yet another programming language to learn was not a task I wanted to undertake, no matter how common it was. I don’t recall what the catalyst was to finally get me to purchase an Arduino clone board, but i have one now and so I am learning how to program it.

The clone board I purchased was a Freetronics Ethermega 2560 along with a Freetronics 16×2 LCD shield and a Freetronics 128×128 OLED module. I figured that a good place to start would be to get the age old ‘Hello, World’ displaying on the 16×2 LCD shield. By following along with the Freetronics documentation I successfully loaded up their demo sketch and had ‘Hello, World’ showing. Great! Although a little boring.

Progressing to the next demo got the buttons under the screen working. All 5 buttons go to the same analog input pin, so it is a simple matter of using the pins ADC feature to determine which button is being pressed. Not that much more exciting, but it does require the use of a little logic.  One thing that became very apparent to me early on was that there was no code collapsing in the Arduino IDE. I could see programs becoming massively long and rather difficult to read.

It was here that I learnt about the Arduino IDE tabs feature. It is a very handy feature that will append the tabs to the bottom of the main program in alphabetical order, allowing you to break it up into manageable chunks. Unfortunately for me, I wanted to move the defines into another tab. This would break the program though because the defines need to be at the start of the program, not in the middle somewhere. The solution is to add a ‘.h’ to the end of the file name, making it a header file. Then at the start of your main program, you simply include the file. See my attached code to see what I mean.

#include <Wire.h>
#include <LiquidCrystal.h>
#include "defines.h"

LiquidCrystal lcd(8,9,4,5,6,7);

void setup()
{
  lcd.begin(16,2);
  pinMode(BUTTON_ADC_PIN, INPUT);
  digitalWrite(BUTTON_ADC_PIN, LOW);
  lcd.setCursor(0,0);
  lcd.print("OMGWTFBBQSAUCE!!");
  lcd.setCursor(0,1);
  lcd.print("Button:");
}

void loop()
{
  byte output = 0;

  output = readButton();

  lcd.setCursor(8,1);
  switch(output)
  {
    case 0:
    {
      lcd.print("        ");
    }
    case 1:
    {
      lcd.print("Right");
      break;
    }
    case 2:
    {
      lcd.print("Up");
      break;
    }
    case 3:
    {
      lcd.print("Down");
      break;
    }
    case 4:
    {
      lcd.print("Left");
      break;
    }
    case 5:
    {
      lcd.print("Select");
      break;
    }
  }
}

 

byte readButton()
{
  unsigned int buttonVoltage;
  byte button = 0;

  buttonVoltage = analogRead(BUTTON_ADC_PIN);

  if (buttonVoltage < (RIGHT_10BIT_ADC + BUTTON_HYSTERESIS))
  {
    button = 1;
  }

  else if (buttonVoltage >= (UP_10BIT_ADC - BUTTON_HYSTERESIS) && buttonVoltage <= (UP_10BIT_ADC + BUTTON_HYSTERESIS))
  {
    button = 2;
  }

  else if (buttonVoltage >= (DOWN_10BIT_ADC - BUTTON_HYSTERESIS) && buttonVoltage <= (DOWN_10BIT_ADC + BUTTON_HYSTERESIS))
  {
    button = 3;
  }

  else if (buttonVoltage >= (LEFT_10BIT_ADC - BUTTON_HYSTERESIS) && buttonVoltage <= (LEFT_10BIT_ADC + BUTTON_HYSTERESIS))
  {
    button = 4;
  }

  else if (buttonVoltage >= (SELECT_10BIT_ADC - BUTTON_HYSTERESIS) && buttonVoltage <= (SELECT_10BIT_ADC + BUTTON_HYSTERESIS))
  {
    button = 5;
  }

  return(button);
}

 

#define BUTTON_ADC_PIN              A0

#define RIGHT_10BIT_ADC             0
#define UP_10BIT_ADC                145
#define DOWN_10BIT_ADC              329
#define LEFT_10BIT_ADC              505
#define SELECT_10BIT_ADC            741
#define BUTTON_HYSTERESIS           10

An important thing to note here is that “” is used for the defines.h include unlike <> for the other includes. This is because defines.h is in the same folder as LCD_Playaround, where as the other two files are in the Arduino Library.

Here is the final result. Nothing spectacular by any stretch, but a nice easy introduction to working with the Arduino micro-controllers. One thing that I did find that i should mention, there is a well documented error within the Arduino 1.0.5 IDE that prevents you from uploading a sketch if you have three exclamation marks in a row. For example if you had the following you could not upload your sketch.

lcd.print("!!!");
lcd.print("OMG!!!");