The Planted Tank Forum banner

TankDroid - Bluetooth Android-Arduino Controller

17K views 25 replies 16 participants last post by  Adnaanmtl 
#1 ·
Yes, yet another arduino based aquarium controller. Finally am far enough to show you guys what I've been working on.

Inspired by AH's iAqua, robsworld's Robo-Tank, and bits and pieces from other older projects.

I started off reading the iAqua mega thread, and soon realized they were hitting space limits on the MEGA. I decided to go with a DUE and had begun my build with a 3.2" LCD. Later, Rob's mega-thread had started, and one quote stuck out.

robsworld78 said:
I wanted to build one for myself but was looking at one of my phones which has the 3.2" screen and figured that's to small so decided I would resize it to fit a 5" or 7" screen
Which got me thinking... why not just control it with my phone?

In comes the bluetooth, and weeks spent learning to write an app (Android if you haven't guessed), add a couple months of trial and error - and TankDroid was born.

It more or less covers the same things as iAqua, and a little less than Robo-Tank. No remote connect (for now :hihi:).

It is not complete (maybe far from it still), and I'd like to continue evolving it - but at this point, I am confident that it works. Still coming across the occasional bug in coding or in the app - but so far working very well. I do need to re-write the app to optimize it, as I used MIT App Inventor 2 which is not the best way to write apps (Takes a few seconds for the initial opening of the app). I also need to clean up the code before I post it, and would like to have it run while I'm on vacation without errors before I'd feel confident posting it.

Features:

- Bluetooth Control
- 5 LED Channel Control @ 12-bit PWM (right now set to WW/CW/R/G/B, but will add adjustability if there's enough interest for anyone else to build one of these)
- Sunrise/Low Sun/High Sun/ Sunset/Moon Lighting
- Custom Lighting
- 8 Relay Channel Control
- Heater Limit Controls + Alarm
- 3 Temperature Probes + Calibration
- 1 pH Probe + Calibration
- Feed Settings to turn off filters etc.
- Auto Feeder
- 2 Auto Dosing pumps (may expand on this later)
- Programmable schedules for power, lights, dosing, and auto-feeding

Hardware:
- Arduino DUE
- HC-05 Bluetooth Module (reprogrammed to 115200)
- DS3231 RTC (found to be less affected by noise, and to stay in sync better than the DS1307, also runs on 3.3V)
- DFRobot pH board + probe
- Optocoupled 8 Channel Relay Board
- Optocoupled 2 Dosing Channels
- Relay for Auto feeder

The hardware is a mess for now, after having to try various configurations and swapping pieces. I will be moving everything to a custom board in the coming weeks, and likely create a new box as I put a couple too many holes in this one. Also, having the dosing pumps inside the box makes me a little nervous.



App:

First screen, upon clicking the button, list of your bluetooth devices pops up.


Then, select TANKDROID. I am going to try to change this, so it automatically finds the right device to pair without input.


Home Screen
Set to update every 3 seconds. Couple bugs still (MIN temps, fertilizer vials). Ignore pH value, probe was not connected when I took this capture. Clicking the Temp or pH icons resets the respective MIN/MAX.

Feeding icon shows last fed time or time left in feeding cycle when active.
Light icon shows the current mode, and time left to next fade, or time left in active fade when in a fade.

Dose remaining show up, accidently inverted the dose remaining in the app - so the vials actually fill up as the real ones empty :tongue:.




Custom Lighting Screen, sliders or can type in a value. Checkmarks sends the value, the left icon resumes normal lighting mode.


Power Controls - Click on the icon to toggle power.


Settings Screen:


Light Values (click and type in), checkmark sends and saves the values, and the X requests current values (used to confirm changes, or revert changes) - this goes for most the screens.


Temp Limits for heater safety:


Temperature Calibration, this screen will show the current temps as well to help in calibration - placeholders there for now.



pH Settings - same as above, placeholder for current ph for now, also just realized i mixed up the high and low (whoops!). I'll add a checkbox option to allow for CO2 control based on pH value later.




Feed settings:



RTC Sync button sends android time to the arduino. Very easy to sync, but this RTC is very good, hasn't lost a second in 8 days. The ds1307 I had lost about 4-5 seconds a day.



Fertilizer settings, refill and run buttons:


Schedules screen:



Power:


Fades:



Dosing:



Feeding


That's it for the screens for now.

To Do:

- Fix MIN temp readings
- Fertilizer Icons on home screen
- Temp & pH readings on calibration screens
- Redo Box & Clean up circuit board
- Clean up coding & app
- Add WIFI

To Do if there's interest from others to build one:

- Allow adjustability in LED channel colours
- More LED channels?
- Add more dosing pump capability
- ???

No LCD means TONS of room to add things, whole sketch is at 10% of the DUE's capacity.

Also, didn't get any shots of it, but the app scales up nicely to my 7" tablet as well.

I may go with a PI server to allow for wifi control - the PI could connect to the controller via bluetooth and offer some separation between the DUE and the outside world. Still playing with this in my mind, and won't likely get anywhere for a month or so.

Suggestions? Comments? :)
 
See less See more
20
#8 ·
Thanks everyone! Lot of hours into this one.



Nope! This is my first app! :hihi: My background is actually in Microbiology, believe it or not.


PhysicsDude55, The communication is actually quite simple over BT, as simple as sending serial commands back and forth. AppInventor made the android bit simple, but now I feel like I should do things the right way and rewrite the app properly. AppInventor has a lot of limitations.

Rob, Thanks! No schematics as of yet, but will be working on one to create a custom board soon. Not too worried about noise (at least yet), everything seems to be working great with the optos in place. The DC motors were creating more noise than the AC relays.

True test will be the next two weeks, as its now in complete control of the tank. Maybe I will try to borrow the scope and take some real measurements when the relays go on and off.

Thanks again everyone for the feedback!
 
#6 ·
When I first started my arduino project, this is what I had in mind.

Using an android phone or tablet to interface with the Arduino. I decided that it would take me too long learn to write an android app and get the interface working that I decided to just use an arduino with LCD.

I REALLY wish I would have done what you did an used android. A lot better long term potential and flexibility, and better screen/touchscreen quality.

Your project looks really good. Very impressed.
 
#9 ·
Hey all, back from vacation!

Quick update- Unfortunately, the RTC seems to have fried while I was away. It only gives out the time and date as all 0's, and will not accept any time being written to it. So, next step will be to figure out if it was a bad chip, or something I did in the wiring. Luckily that time condition put it into midnight- and essentially kept the lights off.

Fish and plants were all okay though!
 
#12 ·
Thanks guys,

I finally had some time to open everything up to figure out what went wrong (was able to run the tank manually off my phone in the meantime to turn on/off lights, dose/ co2 etc..)

Well... took a look at the RTC and immediately found my error - total rookie mistake!

I had put 2 2.2k pull up resistors for SDA and SCL - except... the one for SDA, I put it into the hole next to strip that connects to the clock. So, SDA was not pulled up - and it worked for a little while until the pin on the DUE died.

Since I was using SDA1/SCL1, I moved everything over to SDA0/SDA0 - removed the resistor (as there are internal ones for SDA0/SCL0), and it looks like I'm up and running again.

I've started working on a custom board now as well to replace my wire jungle.
 
#15 ·
This project seems amazing, and I must say that I will be willing to test this sketch and android app immediately. This is so convenient for my tank, and it will enable me to control my tank with ease, as I believe that 3.2 inch LCD is too small for my liking (the LCD size that most other sketches run). I have spare tablets that can act as a monitor too, which is great, even if it requires Bluetooth (which I believe has less range). Also if you want to keep up with the most recent activity on this project, I would recommend visiting TankDroid - Bluetooth Android-Arduino Controller - GTA Aquaria Forum - Aquarium Fish & Plants serving the Greater Toronto Area. (This same project but on a different source). Renesis also included the Github, which has the sketches on it. The link to the github is: https://github.com/renesis/Tankdroid. It seems that any help will be accepted to help with this project, so I just wanted to keep everyone here up to date.
 
#26 ·
This project seems amazing, and I must say that I will be willing to test this sketch and android app immediately. This is so convenient for my tank, and it will enable me to control my tank with ease, as I believe that 3.2 inch LCD is too small for my liking (the LCD size that most other sketches run). I have spare tablets that can act as a monitor too, which is great, even if it requires Bluetooth (which I believe has less range). Also if you want to keep up with the most recent activity on this project, I would recommend visiting TankDroid - Bluetooth Android-Arduino Controller - GTA Aquaria Forum - Aquarium Fish & Plants serving the Greater Toronto Area. (This same project but on a different source). Renesis also included the Github, which has the sketches on it. The link to the github is: https://github.com/renesis/Tankdroid. It seems that any help will be accepted to help with this project, so I just wanted to keep everyone here up to date.
Hi matagim is it possible to get source code and app on adnaanmtl@yahoo.com please thanks in advance. This link is broken now.
 
#16 ·
This is a really cool project. Great job so far. I hope you stick with it through the completion. I do have one suggestion for the app. Under fertilizer, you have dose amount, and bottle capacity. I would add in fertilizer available. This would let you know how much you have left in the bottle. You could have a button next to it called refilled or something along those lines. Just a thought.
 
#17 ·
Hey all,

I'm glad there has been some interest! I do still intend on completing this, and it has been running my tank since I started this post with a random reset bug every 3-10 days. A couple other projects have taken priority, so I haven't had as much time to work on this one - but hoping to resume work on it end of October or November.

As matagim mentioned, the arduino code is available on github.

loach guy,

It does actually have that feature! The available number of doses shows on the main screen under the test tubes. Could easily add that on the fert screen too though. Thanks for the support.

Next big step is creating the board, and finalizing a list of components.

Bluetooth module - HC-05

RTC - DS3231

Eeprom - 24LC256 - 256K I2C CMOS Serial EEPROM

Dosing pumps - 6V DC (ebay) via standard optocoupler and mosfet.. cant recall off the top of my head which ones.

Relay board - ebay controlled via a ULN2803

To be added is are extra PWM channels for lighting, and additional dosing pump support.

I did get around to testing the FRAM chip from Adafruit as a much faster replacement to the EEPROM, but it doesn't play well with the DUE as is.

Hope to have more for you guys soon!
 
#18 ·
Is the current code on GitHub usable, or is it there just for editing (thus it being split into sections)? I am just wondering if it can work if I write it into my spare Due. I am glad to hear that you attempted to finalize the components, as that will be essential for continuing the project and coding. I may check out the GitHub code to see if I can contribute.
 
#19 ·
Hey matagim,

Not really usable until the app and hardware is finalized.

The code is split for easy view-ability and efficiency, but it compiles just fine as if it were all on one page. Just download the whole zip package, and open the main file, all the other sections will open in tabs in the compiler.

The good news is, one of my major time consuming projects is nearly at an end- so should be able to resume work on this in a week or two.
 
#24 ·
Hey nice job man, I'm envious of you guys being able to learn coding so easily as it is still slow going for me. I'm stoked at all these automated controllers we are able to DIY. Not shelling out the big bucks to big companies and being able to spend time doing the fun stuff with our tanks is where its at.
 
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