iAqua: My Touch Interface Aquarium Controller (Arduino)
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 07-09-2014, 04:38 PM   #1
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,359
Default

iAqua: My Touch Interface Aquarium Controller (Arduino)


Grab a beer and a bag of potato chips, because this is one incredibly long post. Sorry, but I didn't know how else to do it. If you don't like reading, just scroll down to pictures.

iAqua

Bootup screen (the copyright is a joke):



This project started out with a relatively small scope, inspired by stilo, which is a touch screen aquarium controller that I stumbled across. I wanted to control power (everything including CO2), dosing pumps, and my Current Satellite Plus lights through a touch screen interface. Once I started digging into the UTFT touchscreen libraries, found that UTFT has a library add-on called UTFT_tinyFat that allows you to read graphics from an SD card and display them on the screen. That's when I realized I could make a rich iPhone inspired GUI (hence the name iAqua), and that's when the snowball started rolling down hill.

This is my first beginning-to-end Arduino project where I wrote the code myself. I've made dosing pumps and a light controller, but that was taking other people's code and doing some light editing. This one I started from scratch, although a bunch of code is borrowed, modified, and inspired by other works. In the end it's close to 7000 lines of code (including blank spaces and comments). I don't even want to know how many hours I've put into this.

This is also the FIRST time I've ever written C/C++, so I'm sure it's incredibly simple and inefficient code. I'm sure any programmer will scratch their head at what I've done, but it works, so I'm proud. So first things first... give credit where credit is due.

CREDITS:
  • Connecting Display, making it work, understanding touch and graphics: stilo project.
  • IR Current Satellite Plus Control: Indychus
  • Ramping Code: Curt_Planted
  • Making dosing pumps: Shift and mistergreen
  • Everything else: Google and the Internet
KEY FEATURES:

• Colorful iPhone inspired touch screen interface
• Nearly all settings are accessed and changed in the GUI, not in code
• All settings saved/retrieved with EEPROM (persistent memory after reboot)
• All graphics stored on external SD card
• Scheduling is available in the GUI for power relays, lighting fades, and dosing pumps
• Automated control of 8 power relays (120v, optically isolated for safety)
—• Light1, Light2, Filter, Circulation Pump, Heater, CO2, Aux1, and Aux2
—• All power relays can be toggled on/off in the GUI at any time
—• 6 of the power relays can be scheduled for daily on and off times (not filter or heat)
—• One touch Feeding routine that controls power
——• Sets all power relays to a configured state for a configured amount of time
——• example: turn off filter, circulation pump, heater, and CO2 for 10 minutes
——• Returns all power relays to previous state when time has expired
——• *If CO2 schedule turned off CO2 during feeding, it will not turn back on
• Automated control of Heater for safety
—• Configurable high temp to turn off heater power relay
—• Temp on home screen turns red, and stays red until you touch it to acknowledge you've seen it
—• Configurable low temp to turn heat back on
—• Configurable low temp to sound a tone alarm (i.e. heater broke)
• Automated control of Current Satellite Plus via IR, or any LED lights controllable via PWM (up to 4 channels, RGBW)
—• Adjust and save 4 lighting modes (High Sun, Mid Sun, Low Sun, Moon)
—• Automated fading between light modes
—• Schedule start time and duration of each of the following ramps
——• Moon to Low Sun
——• Low Sun to Mid Sun
——• Mid Sun to High Sun
——• Mid Sun to Low Sun
——• Low Sun to Moon
• Automated control of 2 dosing pumps for Macro and Micro liquid fertilizer
—• Schedule individual days and time for each pump to run
—• Calibrate/Test pump speed in GUI for each pump
—• Configurable amount of mL to pump per dose (applies to both pumps)
—• Configurable volume of fertilizer reservoir
—• Fill button to reset volume when you fill so it can tell you how much is left
• Set date/time directly in GUI•
• Auto-dimming display
—• Display dims to match ambient lighting
—• Display goes to full bright when touched, returns to dim after a user settable amount of time
—• Dimming can be disabled and brightness can be manually adjusted in the GUI
• Home screen displays in real time (updated every 5 sec):
—• Date/Time
—• Aquarium water temperature
—• Number of hours since fish were fed
—• Current lighting mode
—• If lighting is actively fading, it shows what mode is transitioning to what, and how much time is left
—• Remaining fertilizer in Macro/Micro reservoirs
—• On/Off status of all 8 power outlets

PARTS & COST:

If you want to build one, the total cost of 1 unit is right around $100-150 depending on what you do. The list below is $100 worth of stuff. That doesn't include the enclosure (free to $20), any wiring (maybe $10), breadboards (maybe $10), 120v outlets (probably $5), or other trim. It's just the core electronics. It also doesn't include a few diodes or resistors that you'll need, but those are dirt cheap. The last thing not on the list is a 12v power supply which is easy to find and cheap. I had the rest on hand, so it's cost me $100 so far. It also does not include any hardware to run your lights with PWM if that's your thing. However, you can have the code for free, so that helps.

I will not build one for you, so please do not ask.

This breakdown is not 100% of the parts you need, but it's all the main pieces:SCREEN MOCKUPS:

I built the GUI in Photoshop (the layered files and templates are in the download). It's not a perfect one to one match, but it's very close. The TFT screen uses a fixed width font, and my PS mockup does not, so that's one example of a difference. The real time shows am/pm, but that's not it the mockups. Little stuff like that.

The HOME screen is the primary screen that's always up. It's the status of everything at a glance. It shows date and time at the top, with the temp as the main focus. The number above the little fish bowl on the left is hours since the last feeding (or minutes left in current feeding if you are running it). The next panel is lighting. This shows that the light is fading from high sun to mid sun and has 37 minutes left. The next panel is dosing info. There are 11 doses of Macros left and 12 doses of Micros (the colors empty as the doses go down). The last panel shows the status of power outputs. All are on except Aux1 and Aux2. The bottom has a dock with a home button (refresh), a button to start feeding, and button to quickly get to power toggles, and a settings button for everything else.

The FEEDING screen is engaged from the dock of the home screen. It immediately switches the power config to your predetermined setting (I turn off heat, CO2, filter, and circulation pump). It will countdown if you leave it here, and return home when it's done. You can also hit the restart button to restart the timer, or hit stop to stop it immediately. The little home icon at the bottom allows you to go home so you can do other things while feeding is running.

The POWER screen is engaged from the dock of the home screen. It just lets you quickly turn power outputs on or off individually, or all at once with the master buttons.

The SETTINGS screen is engaged from the dock of the home screen. It lets you get to all of the configuration options.



The LIGHT MODES screen is accessed by the first icon on the settings screen. This screen lets you create, edit, and save 4 lighting modes. It adjusts the Current Satellite Plus (or your PWM lights) live while keeping track of up/down movements of each color (0-42 for CSP and 0-255 for PWM). Once you save each one, you can then schedule 6 fades between modes that allow you to ramp light up in the morning and down in the evening.

The CLOCK screen is self explanatory, but super handy. RTC chips don't keep perfect time, so this lets you quickly adjust it if it starts to drift.

The FEEDING screen lets you decide how many minutes you want to have your power outputs shut down for, and which outlets you want on/off during the feeding cycle.

The SCHEDULE screen will be covered below.

The HEATER screen lets has an OFF setting to set temp threshold where it will shut down your heater power. This will protect you if it malfunctions. The ON setting is when it will turn the heater back on if the temp drops to a certain level. The LOW WARN will sound an alert if you get down to that temp. This would likely mean your heater broke.

The DOSING screen lets you configure your dosing pumps. The top is how many mL you want to dose every time. It applies to both Micros and Macros. The FULL setting is where you set the capacity of your dosing reservoirs (applies to both). The FILL button will "top off" your reservoirs in memory, and keep track of how much is left (displayed on the home screen). So when you top them off in real life, you push FILL on this screen. The bottom 2 panels are for calibrating your dosing pumps. You need to set how many milliseconds it takes to pump 1 mL. There is a test button that will pump your above dosing amount (10 mL in this case) so you can test your setting.

The SCREEN screen lets you adjust the display. Return home will do what it says and go back to the home screen automatically after the minutes configured. The auto-dim level sets how bright/dim you want auto dimming to be. I apply a simple bump or drop to the auto-dimming. The auto-dim seconds is how long you want it to dim after you last touched it. The last setting is if you don't want auto-dimming (turn them all to 0) you can set a static brightness.




The last part is Scheduling. It had to make compromises with some flexibility here since you can't swipe, scroll, or have tables or anything like that. The location of every single item on screen is hard coded. That said, I like how it turned out.

The POWER schedule is the first one. You get to schedule 1 on time and 1 off time for 6 of the power relays. I figured no need to schedule the filter or the heater, so I excluded them. Tap on any row to edit the schedule.

The POWER: LIGHT 1 screen is an example of editing the schedule of a power relay. You simply choose on and off hour and minute, and can choose to enable to disable that item's schedule.

The DOSING schedule lets you choose the time you schedule Macros and Micro independently. Tap on the Macro or Micro button to get to each schedule. These schedules let you select which days you want each to run at the specified time.



The LIGHT RAMP schedule lets you decide when to fade from one lighting mode to another. You cannot choose any different scenarios. Based on the modes you set in the lighting screen, this will do 6 fades for you. There are 3 fades to ramp up, and 3 to ramp back down. Once it arrives at it's destination (say from mid sun to high sun), it will remain there until the next ramp. So in this case, it would start ramping up to high sun at 11:30, and arrive there an hour later at 12:30, and would stay in high sun until 6pm when it would start ramping down to mid sun again.

The FADE 4 screen shows editing an individual fade. It shows the 4th fade being from high sun to mid sun. You set a start time and duration. It handles the rest.



This is what my project space looked like at the end of June, so it's clearly not 100% assembled yet. I'm headed out of town tomorrow, so it'll probably be a couple of weeks before that gets done. I already have a little Arduino UNO running my pumps and lights, so I'm not in a huge hurry.



WRAP UP:

Feeling ambitious? Here is the current 1.0.1 code, SD card images, and layered Photoshop files: iAqua.zip
Here is every library used in the sketch all zipped up: iAqua_libraries.zip
Here are all of the raw images as PNG files for reference: iAqua_PNG_files.zip

// CURRENT VERSION: 1.0.1 (7/13/14)
// - created smart startup routine
// - fixed math bug with dosing pump speed saving to eeprom
// - changed PWM pins for dosing pumps to make room for RGBW PWM pins
// - changed from previous RTC library to RTClib.h
//
// VERSION: 1.0
// - initial version

There are a few tiny things I have to finish up in the code, like sounding the low temperature alarm, but it's 99% complete. It has also not been thoroughly bug tested yet, but it seems to be running well thus far. I guarantee there will be adjustments to the code, so if you dig in and start to modify it, just keep very good track of what you do.

If you know electronics, are resourceful enough to hunt through the stilo project and figure out how to hook up the screen (over 30 wires, see the bundle in the pic above), and are very comfortable with an Arduino, you might be able to build the whole thing with what I've shared. That said, as you can see, what isn't posted here yet are the schematics, links to all of the libraries you need, an actual DIY explanation of how to do it, and all that jazz.

I haven't done any of that, and it'll be a bit of work to put it all together, and to explain how it all works. The code won't even boot up on a Mega unless you have the SD card hooked up and all of the graphics loaded. As such, it's not even testable until you get that far, which means you've dove in quite deep.

So I guess one big questions is, is there anybody that would actually build this that wants/needs me to put all of that information together? I can do it, but I don't want to waste my time if nobody is going to tackle it.

Whew! That was a lot to type up!

I am going to be gone on Vacation until Sunday. I should have limited Internet connectivity to answer questions, but I won't be working on the project and won't have my computer and resources with me. When I get back, I'll make a walkthrough video of how it all works. I'm sure there are plenty of questions, so fire away.

Last edited by AnotherHobby; 09-09-2014 at 12:04 PM.. Reason: spelling
AnotherHobby is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 07-09-2014, 05:55 PM   #2
75ona76
Planted Member
 
PTrader: (2/100%)
Join Date: May 2014
Location: Wichita, Ks
Posts: 212
Default

I for one would be very interested in more details. I have to say that you have done an amazing job!
__________________
Using Tapatalk
75ona76 is offline   Reply With Quote
Old 07-09-2014, 06:38 PM   #3
scapegoat
Planted Tank Guru
 
scapegoat's Avatar
 
PTrader: (14/100%)
Join Date: Jun 2010
Location: philadelphia, pa
Posts: 2,192
Default

you SOB haha. I'm working on a raspberry pi project of similar scope. super cool project you've got going on here!
__________________
scapegoat is offline   Reply With Quote
Old 07-09-2014, 07:15 PM   #4
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,047
Default

Heh, looks nice.
Is this fully working or is it just a mock up?

I'm building a web controller but can only find a weekend here or there to work on it.
I've finally made it relatively secure from outside hackers.
mistergreen is online now   Reply With Quote
Old 07-09-2014, 07:32 PM   #5
Adrand
Planted Member
 
PTrader: (6/100%)
Join Date: Feb 2012
Location: Boston, MA
Posts: 185
Default

This is great to see. I dont know if I would ever have the expertise to pull it off but might have to try if you put up some instructions. At least keep us updated on your progress and how it works out for you.
Adrand is online now   Reply With Quote
Old 07-09-2014, 07:36 PM   #6
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,359
Default

Quote:
Originally Posted by 75ona76 View Post
I for one would be very interested in more details. I have to say that you have done an amazing job!
Thanks! I'll start posting details early next week when I get back in town.

Quote:
Originally Posted by scapegoat View Post
you SOB haha. I'm working on a raspberry pi project of similar scope. super cool project you've got going on here!
Ha! I think Pi might be better for the GUI stuff, but I haven't used one. The Arduino is great for hardware projects, and Pi is great for software ones.

Quote:
Originally Posted by mistergreen View Post
Heh, looks nice.
Is this fully working or is it just a mock up?

I'm building a web controller but can only find a weekend here or there to work on it.
I've finally made it relatively secure from outside hackers.
It's fully functional and running on my desk right now. Every single feature is implemented and works, except the low temp alarm tone, which will probably take about 15 min when I get back. So short of bug testing or any other fine tuning, it's ready for assembly and then hookup.

Those pictures are mockups, because I can't take screenshots on it, but they basically look nearly identical to the screen itself (240x320). If I have time tonight before I leave, I might make a video tour of it, otherwise it'll be next week after I get home.

A web controller would be cool. For a follow up project, I was thinking of making one with pi and connecting it to the Arduino. Not sure what I'd do it remotely, but it might be fun.
AnotherHobby is offline   Reply With Quote
Old 07-09-2014, 07:37 PM   #7
sumer
No Feeling is final
 
sumer's Avatar
 
PTrader: (23/96%)
Join Date: Feb 2010
Location: FoCo, CO
Posts: 606
Default

Okay..
First, thank you so very much for taking your time to type this down.
Second, KUDOS. What a great DIY. I love it.

believe it or not but I have a similar thing in my mind. Of course, I have no experience in Arduino world. I wish they ran on PowerShell.
Its been 6-7 years I used C.
Anyway, to answer your question, YES! I will build this.
I have started reading about arduino and would probably have one here in about a week.
It will take me some time to get acquainted but I will DO this DIY for sure.
Believe me, this is such an awesome DIY.
Thanks once again.
sumer is online now   Reply With Quote
Old 07-09-2014, 07:38 PM   #8
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,359
Default

Quote:
Originally Posted by Adrand View Post
This is great to see. I dont know if I would ever have the expertise to pull it off but might have to try if you put up some instructions. At least keep us updated on your progress and how it works out for you.
Sometimes you just have to dive in. You might surprise yourself.
AnotherHobby is offline   Reply With Quote
Old 07-09-2014, 07:44 PM   #9
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,047
Default

Very nice that it's fully functional. Yeah, I want it fully web enabled so I can go traveling and still keep an eye out on the tank.

I'm using the arduino mega & wifi shield. I'll distribute the code eventually. It's a whopper.
mistergreen is online now   Reply With Quote
Old 07-09-2014, 07:50 PM   #10
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,359
Default

Quote:
Originally Posted by sumer View Post
Okay..
First, thank you so very much for taking your time to type this down.
Second, KUDOS. What a great DIY. I love it.

believe it or not but I have a similar thing in my mind. Of course, I have no experience in Arduino world. I wish they ran on PowerShell.
Its been 6-7 years I used C.
Anyway, to answer your question, YES! I will build this.
I have started reading about arduino and would probably have one here in about a week.
It will take me some time to get acquainted but I will DO this DIY for sure.
Believe me, this is such an awesome DIY.
Thanks once again.
Thanks so much for the kind words. I've been following your tank and excellent photography for a long time.

Isn't your DIY LED 4 channels? I haven't read much into your controller or how that's set up, but you should be able to control them with PWM since I included that in the code. It'd get you the scheduling with ramping and fading. Maybe you already have that though.

Details will follow when I return from vacation.

Quote:
Originally Posted by mistergreen View Post
Very nice that it's fully functional. Yeah, I want to fully web enabled so I can go traveling and still keep an eye out on the tank.

I'm using the arduino mega & wifi shield.
Sweet! I'll be hitting you up for tips when I get that far.
AnotherHobby is offline   Reply With Quote
Old 07-09-2014, 08:07 PM   #11
scapegoat
Planted Tank Guru
 
scapegoat's Avatar
 
PTrader: (14/100%)
Join Date: Jun 2010
Location: philadelphia, pa
Posts: 2,192
Default

I feel like the race is on now! I'll be working on mine more tonight
__________________
scapegoat is offline   Reply With Quote
Old 07-09-2014, 08:50 PM   #12
Wasserpest
Are these real?
 
Wasserpest's Avatar
 
PTrader: (175/100%)
Join Date: Jun 2003
Location: Monterey, CA
Posts: 15,096
Default

This is a fantastic project. Thanks so much for sharing! I felt like referencing this thread in the stickies post on top of this forum. So I did.
Wasserpest is offline   Reply With Quote
Old 07-09-2014, 09:45 PM   #13
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,359
Default

Quote:
Originally Posted by scapegoat View Post
I feel like the race is on now! I'll be working on mine more tonight
MUHAHAHAHAHA!

Quote:
Originally Posted by Wasserpest View Post
This is a fantastic project. Thanks so much for sharing! I felt like referencing this thread in the stickies post on top of this forum. So I did.
Thanks! Wow.

So I just remembered one of the big features I have yet to program. I don't think it'll be that difficult, but it's very important. Right now when it starts up, it just starts up to default power settings (all on except aux1 and aux2) and doesn't touch the lighting modes. This is not ideal if it gets the power reset at an off time. So, the next thing I need to code it to read in all of the schedule data to determine where the lights should be and which power relays should be on/off. This'll be the first thing I work on when I get home.
AnotherHobby is offline   Reply With Quote
Old 07-09-2014, 09:50 PM   #14
vanish
Planted Member
 
vanish's Avatar
 
PTrader: (0/0%)
Join Date: Apr 2014
Location: Longmont, CO
Posts: 283
Default

I am interested, but probably would not get to it for a few months. I have a Current Sat+ and was going to to the simpler project, but this one kicks butt.
__________________
75G Discus Planted, 55G Goldfish, 55G Angelfish, 2G Emersed, 150G Coming Soon!
vanish is offline   Reply With Quote
Old 07-10-2014, 04:44 AM   #15
HunterX
Planted Tank Obsessed
 
HunterX's Avatar
 
PTrader: (22/100%)
Join Date: May 2012
Location: Springfield MO
Posts: 361
Default

Subscribed!
HunterX is offline   Reply With Quote
Reply

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 04:24 PM.


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