Aquarium/paludarium arduino controller (journal) - The Planted Tank Forum
Reply
 
LinkBack Thread Tools Display Modes
post #1 of 22 (permalink) Old 11-15-2014, 07:52 PM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
Aquarium/paludarium arduino controller (journal)

Hi

I am starting to learn arduino. I am no programmer and electronic genious i am just a good welder So i figured i would start a journal about my build and learning progress and i know i will need help in the building prosses specially code.

I am starting with the aquarium then will upgrade for the paludarium. I am rebuilding my stand next spring that will include the palu and more space for equipment.

So this is what i want to automate.

Fert dosing 3 pump
Ph control with co2
Filter and pump on off with feeding timer
Magnetic door lock (have a 1yearold kid)
Heating control an safety alarm
Water leak alram.

For palu part
Humidity and temp monitor
Rain
Fogger.

And probably more when i ger farther in build if i dont give up befor .

I already started my build so far its easier then i tought but i am still doing basic coding but realy liking it.

Will post some picture real soon and what i did so far. So feel free to comment and help if you see some error. If you see some and pitch in pls let me know and if you can explain what it was and what you did to fix that would be awsome.
Ultimbow is offline  
Sponsored Links
Advertisement
 
post #2 of 22 (permalink) Old 11-15-2014, 11:23 PM
Planted Tank Obsessed
 
PhysicsDude55's Avatar
 
PTrader: (0/0%)
Join Date: Oct 2011
Location: Dallas, TX
Posts: 339
Very Cool!

I bought a DHT22/AM2302 temperature humidity sensor. I tested it out and it works great. They only use 1 wire on an arduino, and communicate digitally (no analog noise) and get ambient temperature and relative humidity. It seemed pretty accurate, and super easy to set up, and only cost a few dollars.

Are you going to have some sort of screen?

What kind of maglock are you planning on using? Coincidentally I work as a controls engineer for a company that installs and maintains security equipment, including maglocks.

Keep us updated

DIY Enthusiast


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
PhysicsDude55 is offline  
post #3 of 22 (permalink) Old 11-16-2014, 01:49 AM
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (10/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,602
I have the same temp/humidity sensor PhysicsDude55 does, and it's very slick, and super easy to use. I got mine off amazon for just http://www.amazon.com/gp/product/B00CDHH3WQ/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1. I'm using it on a different project than my aquarium controller, and I really like it.

I'm not sure how far you are or what board you are using, but if you are starting off with an Uno, I'd get a Mega on order right away. The Uno works great as a dosing pump controller, or a light controller, or a ph controller, or a temp controller, or a combination of some of those, but not all of them. Not enough memory or IO by the time you are done, especially if you use any kind of screen. The strings to display text eat up massive amounts of memory (relatively speaking). I get the cheap brands like Funduino, where a Mega R3 2560 can get had for just $15.

And above all, have fun with it!


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
AnotherHobby is offline  
 
post #4 of 22 (permalink) Old 11-16-2014, 03:06 AM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
I want to go with a touch screen eventully but i am starting with a small 1602lcd for now it seem easyer to program until i get better at it. Will defentivelly look at that temp humidity sensor dint order any yet and just had a quick look so far.

Quote:
Originally Posted by PhysicsDude55 View Post
What kind of maglock are you planning on using? Coincidentally I work as a controls engineer for a company that installs and maintains security equipment, including maglocks.

Keep us updated
That is what i found so far that seem to be good for my need.

http://m.aliexpress.com/item/1021213704.html

Anotherhobby. I have a uno and a mega already i relise quite fast that the uno is realy limited in connection. So right now i am making my built all separate on the uno and then will transfer on mega and try to put every thing together.

I am already having tone of fun but have to be careful not trying to go to fast becaua it can get overwhelming realy fast.

Last edited by Darkblade48; 11-16-2014 at 04:55 AM. Reason: Please use the edit function for back to back posts to keep threads cleaner
Ultimbow is offline  
post #5 of 22 (permalink) Old 11-16-2014, 01:00 PM
Planted Tank Obsessed
 
PhysicsDude55's Avatar
 
PTrader: (0/0%)
Join Date: Oct 2011
Location: Dallas, TX
Posts: 339
Quote:
Originally Posted by Ultimbow View Post
I want to go with a touch screen eventully but i am starting with a small 1602lcd for now it seem easyer to program until i get better at it.
That's actually what I was going to recommend. I first installed a 1602 LCD that I ran for about 18 months before switching to a touch screen. (youtube link to my 1602 setup) Touch screen adds 10X cool factor, but its a pain to program. Unless you use iAqua, it would take 50+ hours worth of work just to make the touch screen interface.

The only ongoing issue I had with my 1602 screen is that I installed it on my hood, with the arduino under my stand, and I had a lot of issues with the I2C connecting dropping bits. Mounting the screen right next to the arduino is the way to go.

Quote:
Originally Posted by Ultimbow View Post
That is what i found so far that seem to be good for my need.
http://m.aliexpress.com/item/1021213704.html
That looks like it will work! Very cheap. Most of the ones we install are ~$100.

DIY Enthusiast


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
PhysicsDude55 is offline  
post #6 of 22 (permalink) Old 11-16-2014, 01:25 PM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
I already have a 3.2" touch screen i was going to make an iaqua but then i started to play with arduino and desided to build my own that will be more adapted for my need. So now my wife is blaming AnotherHobby for my new hobby.
Ultimbow is offline  
post #7 of 22 (permalink) Old 11-16-2014, 03:48 PM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
This is what i have so far for equipment. I have 2 set of 4 channel 12v module that i am waiting for more jumper with second bread board.

My wife got me the books for our anniversary only ask for the getting started one and she got me both.

Click image for larger version

Name:	electronic.jpg
Views:	244
Size:	163.0 KB
ID:	392442

And this is my diy led light i put together already. i had no knowledge of arduino so i got a strom controller for that build.

https://www.plantedtank.net/forums/sh...d.php?t=644642
Ultimbow is offline  
post #8 of 22 (permalink) Old 11-19-2014, 03:00 AM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
So her is my first question pretty basic but i want to know if i am doing something wrong here.

When i connect my relay as soon there is power on it the relay activate. I would like to be ''Sleeping'' or inactive until i push the button but it dose the opposite. Hope you understand what i mean. the picture i put is with the code button from arduino software

so as you can see when the button is push the led on 13 is on the relay is off when i let go its the opposite. is it normal that there are not sync together??? i know if i invers the HIGH and LOW it dose what i want but there are still not sync.

Click image for larger version

Name:	2014-11-18 22.43.38.jpg
Views:	228
Size:	106.3 KB
ID:	393409
Click image for larger version

Name:	2014-11-18 22.43.57.jpg
Views:	114
Size:	99.4 KB
ID:	393417

that the code i used

Quote:
/*
Button

Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.


The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground

* Note: on most Arduinos there is already an LED on the board
attached to pin 13.


created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Ultimbow is offline  
post #9 of 22 (permalink) Old 11-19-2014, 12:44 PM
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (10/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,602
As a test, try any pin other than 13. If you want to use an analog pin just put A in front of the number. For relay use, the code is the same if it's an analog or digital pin.

I like using the analog pins for relays since they are just on/off in order to leave the digital pins available for other tasks (like PWM, LCD screens, SD card readers, etc). It may depend on how many analog input devices you need though. It doesn't technically matter which you use.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
AnotherHobby is offline  
post #10 of 22 (permalink) Old 11-19-2014, 11:57 PM
Planted Tank Obsessed
 
PhysicsDude55's Avatar
 
PTrader: (0/0%)
Join Date: Oct 2011
Location: Dallas, TX
Posts: 339
Relay boards use the opposite logic than what you're thinking.

LOW will energize the relay, HIGH will de-energize the relay.

So yes, the relay will be in the opposite state as the LED in pin 13.

You can alter how the relay acts by using the Normally Open (NO) or Normally Closed (NC) contacts. You can wire something on the NC contact, which means that it will be disconnected when the relay is energized.

DIY Enthusiast


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by PhysicsDude55; 11-20-2014 at 11:39 PM. Reason: cut out gibberish
PhysicsDude55 is offline  
post #11 of 22 (permalink) Old 11-21-2014, 03:31 AM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
I tought it might have been put together wrong... will just write the code for it so it work like i want Thanks
This is what i have donne so far i put it in a differnt post but when i add more stuff will post in here.

Ph controller

https://www.plantedtank.net/forums/sh...d.php?t=742809
Ultimbow is offline  
post #12 of 22 (permalink) Old 11-21-2014, 05:19 AM
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2011
Location: Australia
Posts: 33
For those relays, change your code so it's like this

Quote:
digitalWrite(pin, HIGH);
pinMode(pin, OUTPUT);
That way it won't turn on straight away. Then you just have to do the inverse (LOW = on, HIGH = Off)
STReNT is offline  
post #13 of 22 (permalink) Old 11-24-2014, 11:10 PM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
Her is an update of where i am at i just learn to make function and rtc now i want to try to make the dossing pump working with clock my guess is it with the timealram but will check more on it later. and after that will try to make sub menu on lcd.

Form some reason the ph is slow to get his reading stable. for now every thing run from the uno but they will be a 12v powersupply and a stepdown for the ph meter so it has exactly a stable 5v to be more presisce

https://www.youtube.com/watch?v=GMR0...lL8RGA&index=2

here is my code so far


Quote:
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <LiquidCrystal.h>
#define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0
#define Offset 0.91 //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40 //times of collection
int pHArray[ArrayLenth]; //Store the average value of the sensor feedback
int pHArrayIndex=0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int relay = 10;
int pumpA = 9;
int pumpB = 8;



void setup()
{
pinMode(pumpA,OUTPUT);
pinMode(pumpB,OUTPUT);
pinMode(relay,OUTPUT);
pinMode(LED,OUTPUT);
Serial.begin(9600);
Serial.println("pH meter experiment!"); //Test the serial monitor
lcd.begin(16,2);
lcd.print("Welcome Ultimbow");
delay(1000);
lcd.clear();
setSyncProvider(RTC.get);

}


void loop()
{
digitalClockDisplay();
phController();
}



void phController()
{
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue,voltage;
if(millis()-samplingTime > samplingInterval)
{
pHArray[pHArrayIndex++]=analogRead(SensorPin);
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
pHValue = 3.5*voltage+Offset;
samplingTime=millis();
}
if(millis() - printTime > printInterval) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
{
Serial.print("Voltage:");
Serial.print(voltage,2);
lcd.setCursor(0, 0);
lcd.print("PH:");
Serial.print(" pH value: ");
Serial.println(pHValue,2);
lcd.print(pHValue,2);
digitalWrite(LED,digitalRead(LED)^1);
printTime=millis();

}
if(pHValue >= 7.00)
{
digitalWrite(relay,HIGH);
}
if(pHValue <= 6.99)
{
digitalWrite(relay,LOW);
}

}
double avergearray(int* arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
Serial.println("Error number for the array to avraging!/n");
return 0;
}
if(number<5){ //less than 5, calculated directly statistics
for(i=0;i<number;i++){
amount+=arr[i];
}
avg = amount/number;
return avg;
}else{
if(arr[0]<arr[1]){
min = arr[0];max=arr[1];
}
else{
min=arr[1];max=arr[0];
}
for(i=2;i<number;i++){
if(arr[i]<min){
amount+=min; //arr<min
min=arr[i];
}else {
if(arr[i]>max){
amount+=max; //arr>max
max=arr[i];
}else{
amount+=arr[i]; //min<=arr<=max
}
}//if
}//for
avg = (double)amount/(number-2);
}//if
return avg;

}

void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();

lcd.setCursor(8,0);
lcd.print(hour());
lcdprintDigits(minute());
lcdprintDigits(second());
delay(1000);
}

void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}

void lcdprintDigits(int digits)
{
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}

Ultimbow is offline  
post #14 of 22 (permalink) Old 11-29-2014, 02:40 AM Thread Starter
Planted Member
 
Ultimbow's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2009
Location: Canada, Quebec
Posts: 163
here is a question for the more experimented arduino programer.

i am working on programing a time for my dossing pump using time alarm. everything work but when the timer "activate" the clock freeze on lcd then when the fuction is finish it catch back where it suppose to be (check video). I know its because of the delay i put but is there a different way to code it so that doesn't happen. its not a major issue i can live with it but was wondering how to modified it.

https://www.youtube.com/watch?v=tN00...ature=youtu.be

her the code that i put together.

Quote:
#include <LiquidCrystal_I2C.h>
#include <TimeAlarms.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);


int led1=12;
int led2=11;
int led3=10;

void setup()
{
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);

Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("hello");
delay(1000);
lcd.clear();
setSyncProvider(RTC.get);
Alarm.alarmRepeat(17,25,00, MorningAlarm);

}

void loop()

{
digitalClockDisplay();
Alarm.delay(1000);

}


void MorningAlarm(){
Serial.println("Alarm: - turn lights off");
lcd.setCursor(0,0);
lcd.print("LED ON");

if(MorningAlarm)
{
ledCycle();
}
lcd.clear();

}


void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();

lcd.setCursor(8,0);
lcd.print(hour());
lcdprintDigits(minute());
lcdprintDigits(second());


}

void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}

void lcdprintDigits(int digits)
{
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}

void ledCycle()
{

digitalWrite(led1,HIGH);
Alarm.delay(1000);
digitalWrite(led1,LOW);
Alarm.delay(1000);
digitalWrite(led2,HIGH);
Alarm.delay(1000);
digitalWrite(led2,LOW);
Alarm.delay(1000);
digitalWrite(led3,HIGH);
Alarm.delay(1000);
digitalWrite(led3,LOW);
Alarm.delay(1000);
}

Ultimbow is offline  
post #15 of 22 (permalink) Old 11-29-2014, 05:16 AM
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2011
Location: Australia
Posts: 33
Arduino's are single threaded, so when your alarm activates you've got a total of 6 seconds worth of delays. Until that function finishes, the code that runs to update the clock won't run
STReNT is offline  
Reply

Tags
None

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the The Planted Tank Forum forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
Linear Mode Linear Mode



Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

 
For the best viewing experience please update your browser to Google Chrome