The Planted Tank Forum banner
1 - 20 of 74 Posts

· Registered
Joined
·
151 Posts
Discussion Starter · #1 ·
So, I am throwing my hat into the arduino total tank build, and I will try and document as much of my journey as possible here. I have tinkered around with the Arduino in the past, but have never attempted anything of this complexity. I have zero real world programming experience, but enjoy reading sites like hackaday, lifehacker, and such. What I'm saying here is that my code will look pathetically amateurish and possibly unreadable if viewed by a professional...

So, the goals of my personal build will be:
  • Autodosing
  • Keeping track of the fert levels and alarming if they become low (I am rather forgetful and would like a warning)
  • Keeping my light schedule
  • Controlling CO2 solenoid
  • Scheduling an auxiliary RGB strip, as I will shamelessly steal from AnotherHobby Fallen Tree Branch 60cm
  • The aux RGB strip will have sunrise, sunset, and moonlight as AnotherHobby has, ideally
  • Writing all of the alarm times to the DS1307 RAM, in case of a power outage (Unnecessary, but what the heck, why not?)
  • Keeping track of tank temp and cutting power to the tank heater in case of an issue
  • Anything else that I don't need but would like to try and implement

Thus far, my current build consists of:
  • SainSmart Arduino Mega 2560 (Knockoff from Amazon for like $28)
  • Sparkfun DS1307 RTC
  • Adafruit 20x4 LCD display
  • Adafruit 10K Precision Epoxy Thermistor
  • Small piezo buzzer for alarms
  • Assorted buttons, resistors, transistors to make it all work

This is currently it:






So far, I have achieved:
  • RTC is running and keeping time
  • Thermistor is working and updating once a second on the main screen
  • As you can see in the pics, I have the fert bottle levels displaying. Each full block is obviously 20%, and there are half blocks so I can easily see roughly how much fertilizer is in each bottle.
  • I have functions written to store the fert levels in the RTC RAM, and I am able to get them back out again (This required a lot of staring at code I didn't understand until it all kinda clicked)
  • I can now set the on/off times for the main lights
  • I can set the backlight via PWM anywhere between 0-255

So, I haven't gotten too crazy far in yet, but progress has been made. I need to finish getting the on/off time screens programmed in, then I can start writing the code to actually do something with the times!

Here is a link to the code as it stands
Current sketch

And this is the tank, awaiting its master


Good times will be had here, feel free to follow along on the journey :icon_cool
 

· Registered
Joined
·
151 Posts
Discussion Starter · #4 ·
tenthe, I will be reading the water temperature. I have a cable gland on order from adafruit that I will be using to place the temp probe somewhere in the pump line. I'm hoping it may fit into a cerges reactor...
Benjaf, I would use the EEPROM, however I will be reading/writing to it a lot over time, and EEPROM has a limited lifespan. The RAM on the DS1307 however, is unlimited read/writes
 

· Registered
Joined
·
57 Posts
Please let us know how the inline temperature probe works out! I just ordered an arduino to control my lights, and I'd love to be able to get my temperature probe out of the tank. I might try something similar.
 

· Registered
Joined
·
113 Posts
Benjaf, I would use the EEPROM, however I will be reading/writing to it a lot over time, and EEPROM has a limited lifespan. The RAM on the DS1307 however, is unlimited read/writes
How often do you dose ferts? AFAIK only writing to the EEPROM cause wear, and even then the 100.000 cycle limit is said to be a very conservative estimate.
 

· Registered
Joined
·
151 Posts
Discussion Starter · #8 · (Edited)
That looks nice hamato! Might I ask what temp probe you are using? I just received my cable gland from adafruit, however the probe wire is too small for it to make a tight fit. I'm thinking of maybe adding some shrink tubing to the probe wire to make it thicker, however I'm not too sure how that will work when it comes to being watertight...

PG-7 Gland nut from adafruit




Doesn't quite fit...


Also, got some more goodies in the mail today. RGB strip light, 12V power supply, motor shield for the dosing pumps, and a capacitive touch sensor board. I'm hoping to place some sensors inside the stand, and be able to "hit" the buttons from the outside of the stand, no physical buttons required... Not too sure if that will pan out or not

 

· Registered
Joined
·
84 Posts
I got it from ebay, basically the waterproofed ds18b20 but the shorter version. An ebay search for "mini Thermometer waterproof model temperature sensor temperature probe" will bring it up.

For the fitting I used a Heyco M4518 RLTCG 1/2 NPT BLACK-NO NUT
 

· Registered
Joined
·
151 Posts
Discussion Starter · #10 ·
hamato, I went ahead and ordered the ds18b20 myself. I looked it up, and there seems to be a one-wire library that is available for it, and it seems pretty easy to use. I am thinking that I will keep the thermistor, and use it to regulate the temperature inside the project box via a 12v computer fan.

I made quite a bit of headway in the programming today. I now have the RGB strip lights working, and have the ability to program the light timers and RGB values for morning, daytime, evening, and moonlight. I was also able to get the capacitive sensing working and tested. It appears that I will be able to use the capacitive buttons through the 3/4" plywood of my stand. This makes me happy, as I no longer need to figure out a way to have buttons unobtrusively stick out of my stand :D

I ran out of time today, but I'm hoping to get a quick video of my progress up to this point posted tomorrow. It'll be nice to have a video snapshot of the project for when I get it all finished, and maybe I can get some constructive criticism from the folks who've already blazed this trail.

Until then, enjoy planting tanks!
 

· Registered
Joined
·
151 Posts
Discussion Starter · #11 ·
Partial build video

So, I posted a video of my controller in action today. It's probably 50% done being coded now. Right now, I can set the times for the lights and co2, however there is no function to actually use that info! So, I still need to add the actual alarm function, a feeding function (to turn off the pump and heater for like 5 min), options to turn each of the components on/off individually, and probably a whole bunch more that I haven't even thought of. But, here it is anyways. Enjoy!

http://youtu.be/AZbJ8RELvgg

P.S. I can't figure out how to embed video, so there is just the link above...
 

· Registered
Joined
·
151 Posts
Discussion Starter · #12 ·
Quick update

So, I've now got the controller programmed at about 90%. I have all the alarms currently working, and everything is currently operating as I want minus the pumps. I just received the pumps in the mail, so now I can get that out of the way...
Meanwhile, I have started to get the proto board ready to go. Here is the voltage regulator I put together today. It uses a LM317T variable voltage regulator set to output 8.12v (close enough to 8!). I chose around 8v to power the arduino as 7v is the minimum cutoff, and 9v or higher would simply create excess heat on the arduinos voltage reguator. The circuit is one I copied from ladyada on her webpage. Seems to work well so far!



Also, I received the DS18B20 in the mail and have that hooked up and reading correctly. It is nice that the cord is larger and now fits into my cable gland snugly!



So, now that I have the programming almost done, and the perfboard getting setup, I am now on the hunt for a box to fit everything. The biggest concern I have now is that the 12V power supply I have is relatively huge. Not too sure where I'm gonna get a wooden or plastic box that big. Oh well... Progress is being made!
 

· Registered
Joined
·
151 Posts
Discussion Starter · #13 ·
Big update

Ok, So I am finally done programming this thing. The final tally was a 42.2kB sketch, and roughly 2000 lines of mostly unoptimized code. But, I managed to get all the ideas I had floating around realized. So, here is the mess I have created, which is everything minus the motor controller board which I took off for measurements:



The next step is to take all of the stuff on the breadboard and move it to the perfboard, and clean it up to look neat. Then its moving to this box:



Right now, I have everything in there just for reference. I will begin cutting holes for all the plugs and everything once I get the controller cleaned up. Right now, you can see the 12v power supply on the left, with the cooling fan sitting on top. Along the bottom are the 3 hobby peristaltic pumps. On the right side is the solid state relays (3 of em, one for the filter, one for the main lights, and one for the heater. The CO2 solenoid doesn't draw enough current to work with the SSRs, so it gets a reed relay.) On the bottom right is the USB extension cable so I can reprogram the board later if need be without taking everything apart. Along the top are the outlets for the filter and lights to plug into. I have a Duemilanove sitting in the middle for reference.
 

· Registered
Joined
·
151 Posts
Discussion Starter · #14 ·
Program breakdown

Ok, as far as the program goes...

Here is the main screen:


On the main screen, you can see the temperature of the tank, the day of the week, the time in hours:minutes:seconds. Then I have symbols for which 120v things are currently on. They are from left to right: filter, CO2, heater, main light. Then on the bottom I have the micro ferts on the left and Macro ferts on the right, with each block representing 20% of the bottle full, and each half block being 10%.


By hitting the select button, you get this screen:


This screen you can see the enclosure box temperature, the actual mL of the micro and macro bottles, and the cooling fan RPMs. After 5 seconds, this screen disappears and you are taken back to the main screen.

From the main screen, if you hit the enter button, it takes you to:


and hitting yes:


The feeding screen turns off the filter and heater for 5 minutes to allow the fish some quiet time to eat. I have an inline heater, which is why the heater is turned off with the pump. After the 5 min, it kicks you back to the main screen.

Moving on past the feeding selection screen, you are taken to the reset bottles screen. Selecting this just resets either the micro or Macro bottles back to being full.


 

· Registered
Joined
·
151 Posts
Discussion Starter · #15 ·
More program updates

Moving on past the reset bottle screen, you are taken to the set light times screen.




Selecting Main Light gives you:





Selecting Aux Lights takes you to:



After the Sunrise RGB, you are taken to similar screens for Sunset RGB, Moonlight on time, Moonlight RGB, and Daytime RGB.

After setting the light times, you can set the main time.


 

· Registered
Joined
·
151 Posts
Discussion Starter · #16 ·
More program....

After setting the main clock, you can set the LCD backlight brightness. This brightness is dimmed down to after 5 seconds of being on the main screen. The LCD will be visible on the outside of my tank stand, so this is needed to keep it from being full brightness all the time.


From there, we can turn on/off all the components independently:





And so on for the CO2, filter, and heater. Next is setting up the dosing pumps.








If you noticed, I have 3 pumps but only the micro and Macro ferts setup on the main screen. I have the 3rd pump setup so that if I keep it at 0 second on time, it just gets skipped over. But if I decide I need it at some point, be it for adding glut or iron or whatever, I can set the timer >0sec and it will dose along with the first two.


After setting the pump speeds and times (which I will use to calibrate the pumps to inject a certain amount of fert...) I will then set how much fert I just calibrated the pumps to. I wanted to keep the freedom of being able to decide later down the road to maybe inject 10mL of fert at a time, or maybe 5mL will be enough. I will be mixing up my liquid ferts using dry powders, so I will have a lot of flexibility. I'm currently thinking of dosing 10mL per dose, and having 500mL bottles. That sets me up for 50 doses, every other day, which means they'll last like 4 months. That may be too long... I dunno :icon_conf


And finally the size of the bottles I'll be filling. Again, I don't know if 500mL bottles will be what I finally decide on. I have this to be set between 100mL and 2000mL. That should cover me.
 

· Registered
Joined
·
151 Posts
Discussion Starter · #18 ·
and finally...

After setting the pump parameters, I can set the temperature alarms.



If the tank or box temperatures go over the alarm setting, it will start an audible alarm that will continue until it is acknowledged by hitting the menu button on the main screen. The alarms are setup so that if the tank temp alarm is reached, the power to the heater is cut. Once the temp goes back below the alarm temp, power is restored to the heater. This gives me protection from the thermometer on the heater going out and frying my fish, and will keep the tank temps hovering around the alarm setpoint until I can fix the problem. The box temp alarm doesn't do anything except alert me to a problem. Speaking of alarms, the alarm is tripped whenever the fertilizer levels reach 10% of the max bottle amount. This alarm is tripped each time the ferts are <10% of max and the ferts are injected. I put this in there to remind me of when its time to mix up a new batch.

And thats pretty much it! As I make progress getting this rats nest of wires cleaned up and put into the box, I will post more pictures and keep ya up to date. Hope this wasn't too long winded!!!
 

· Registered
Joined
·
151 Posts
Discussion Starter · #20 ·
Controlling heater

Shift,
I would rather rely on the Hydor to keep the temps stable and use my own temp probe as a backup, as that gives me redundancy. The heater is being powered through a SSR, so I could just use the Arduino to control the heater using a PID algorithm, but then I'm solely relying on my controller to keep temps in check. I'd rather rely on the engineers at Hydor first, and use myself as a last resort :red_mouth
 
1 - 20 of 74 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top