Chads Arduino Build
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


Reply
 
Thread Tools Display Modes
Old 02-19-2014, 04:07 AM   #1
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Post

Chads Arduino Build


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
Chiefston is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 02-19-2014, 04:13 AM   #2
tenthe
Algae Grower
 
PTrader: (3/100%)
Join Date: Dec 2013
Location: Los Angeles
Posts: 49
Default

Are you reading water temperature? Where did you place the probe?
tenthe is offline   Reply With Quote
Old 02-19-2014, 04:14 AM   #3
benjaf
Algae Grower
 
benjaf's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2012
Location: Denmark
Posts: 105
Default

This looks interesting, going to follow your progress.
May I suggest using the EEPROM in stead of the RTC memory? It serves the same purpose but is much easier to work with and has much larger capacity.
__________________
benjaf is online now   Reply With Quote
Old 02-19-2014, 04:17 AM   #4
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default

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
Chiefston is offline   Reply With Quote
Old 02-19-2014, 06:04 AM   #5
tenthe
Algae Grower
 
PTrader: (3/100%)
Join Date: Dec 2013
Location: Los Angeles
Posts: 49
Default

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.
tenthe is offline   Reply With Quote
Old 02-21-2014, 12:03 PM   #6
benjaf
Algae Grower
 
benjaf's Avatar
 
PTrader: (0/0%)
Join Date: Mar 2012
Location: Denmark
Posts: 105
Default

Quote:
Originally Posted by Chiefston View Post
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.
__________________
benjaf is online now   Reply With Quote
Old 02-22-2014, 04:17 PM   #7
hamato
Algae Grower
 
PTrader: (0/0%)
Join Date: Jun 2008
Location: Canada
Posts: 70
Default

Quote:
Originally Posted by tenthe View Post
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.
Here's how I do mine. Works pretty well!

hamato is offline   Reply With Quote
Old 02-22-2014, 06:03 PM   #8
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default

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


Last edited by Chiefston; 02-22-2014 at 06:32 PM.. Reason: added in new shipment of goodies
Chiefston is offline   Reply With Quote
Old 02-22-2014, 07:16 PM   #9
hamato
Algae Grower
 
PTrader: (0/0%)
Join Date: Jun 2008
Location: Canada
Posts: 70
Default

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
hamato is offline   Reply With Quote
Old 02-24-2014, 05:48 AM   #10
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default

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

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!
Chiefston is offline   Reply With Quote
Old 02-25-2014, 12:31 AM   #11
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Post 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...
Chiefston is offline   Reply With Quote
Old 02-28-2014, 04:49 AM   #12
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default 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!
Chiefston is offline   Reply With Quote
Old 03-04-2014, 03:53 AM   #13
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default 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.
Chiefston is offline   Reply With Quote
Old 03-04-2014, 04:08 AM   #14
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default 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.


Chiefston is offline   Reply With Quote
Old 03-04-2014, 04:17 AM   #15
Chiefston
Algae Grower
 
Chiefston's Avatar
 
PTrader: (1/100%)
Join Date: Dec 2011
Location: Tempe, AZ
Posts: 132
Default 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.


Chiefston is offline   Reply With Quote
Reply

Tags
arduino, controller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not 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

Forum Jump


All times are GMT. The time now is 03:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012