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.
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.
- 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
• 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):
—• 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.
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.
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.
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.
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.
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.
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.
screen will be covered below.
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.
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.
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.
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.
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.
Feeling ambitious? Here is the current 1.0.4
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
Here is the Fritzing Breadboard/schematic file: iAqua.fzz
// CURRENT VERSION 1.0.4
// - the smart startup routine has been reworked and fixed by robsworld78 at The Planted Tank forums!
// - added a first run routine that will zero out all EEPROM data that is needed by iAqua
// - see the warning immediately below:
// - ////////////////////////////////////////////////////////////////////////////////////////////
// - // WARNING!! IF YOU HAVE CONFIGURED iAqua BEFORE v 1.0.4 AND DO NOT WANT TO LOOSE YOUR DATA
// - // YOU MUST COMMENT OUT THE FISRT LINE OF THE startup() ROUTINE THAT CALLS firstRunSetup().
// - // IF YOU DO NOT, IT WILL ZERO ALL OF YOUR SETTINGS!!!!
// - /////////////////////////////////////////////////////////////////////////////////////////////
// VERSION 1.0.3
// - fixed smartstartup routine bugs
// - fixed dosing display when resevoir goes negative due to forgettig to hit fill
// - added robsworld78 at The Planted Tank's PWM smart startup lighting code
// - fixed issue when temp turned red, and then turned feeding time red
// VERSION: 1.0.2
// - more accurate math for how doses were calcualted on home screen
// - updated power schedules to update home screen immediately
// - day name was off using new RTC and Time library
// VERSION: 1.0.1
// - 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.