# OSA raspberry pi aquarium controller - controller has been put to work on my 125g



## scapegoat (Jun 3, 2010)

I've decided to join the automation brigade. I constantly forget to dose fertilizers so decided at the very least I'd set something up to automatically dose those for me... well, i haven't gotten around to that yet.

Right now I've got a system that allows me to schedule relays for daily on/off times, as well as reading the temperature from a waterproof thermometer. Neither of which are actually attached to my fish tank, or all that usable at the moment. 

I'm still very much developing, and prototyping, my aquarium controller. 

I know a lot of folk go with the arduino; but I didn't. I wanted my choices to be nearly 100% unfettered. I did have to make some concessions... a specific framework and noSQL database did not support the ARM chip, nor did i find a usable, up to date, build for ARM.

Along with not wanting my programming choices to be limited, I wanted a GUI, and I wanted it accessible on my home network. Two things the arduino sort of fails at out of the box. Where the arduino fails, the raspberry shines. While programming it is a lot more involved, options are endless.

My controller is being programmed using node js, and using the web sockets protocol to provide a real time open connection to the Pi. This is important because the Pi is connected to my home network, which makes access to it available on any device with a current browser. phone, iPad, computer... hell, even my PS3 could bring up the GUI. The browser effectively provides a native like application. 

The video below demonstrates the, very, basic GUI. Buttons for the 6 relays currently under control, and the temp sensor reporting back. I can schedule each relay independently to turn on or off, the schedule is set for every day of the week. I didn't show this because it checks every minute, and I didn't think anyone wanted to sit and watch a video for 2+ minute of nothing happening.

Future updates will be including the ability to schedule a relay to a data point... namely the temp sensor, so they turn on/off base on a given temp. and then of course the peristaltic pumps will be wired up and tested.

anyway, here is the video.


----------



## Down_Shift (Sep 20, 2008)

i'll be the first to say it- you're on to something here.

Definitely marketable software here.


----------



## scapegoat (Jun 3, 2010)

Down_Shift said:


> i'll be the first to say it- you're on to something here.
> 
> Definitely marketable software here.


thank you. the code is not nearly production level; but I intend on cleaning it up with prototype 2. I will be open sourcing the code... since there is no real reason not to.

The code will ultimately get out, since it is all javascript. I can't obfuscate or protect in any way. So, i'll release it to a github account, garner feedback, and more folks helping to make it as good as possible. With the correct license of course.

I wouldn't mind making some cash off the work though, and I've got some plans on how to accomplish that. But for now I'll concern myself with getting it done.


----------



## mistergreen (Dec 9, 2006)

Nice. I might have to switch to the pi too. I've built a network interface for the arduino but it's pretty limited. 

I've thought about the production/money issue too. It might be best if it's done with donation.

Sent from my iPad using Tapatalk HD


----------



## scapegoat (Jun 3, 2010)

What do you mean donation?


----------



## Whiskey (Feb 15, 2005)

That is really cool!

I use arduino's for the tanks, but I also have a pi for a media center. Can you do PWM outputs with the pi? I notice a couple of interface boards there, are they shields you bought? Or something you built?

Thanks,
Whiskey


----------



## benjaf (Mar 27, 2012)

Great - now I'll have to buy yet another Pi, and figure out how to use it to control an arduino or similar..


----------



## mistergreen (Dec 9, 2006)

scapegoat said:


> What do you mean donation?


You can give out the code and spec for free but ask for donations if they want.


Sent from my iPad using Tapatalk HD


----------



## scapegoat (Jun 3, 2010)

Whiskey said:


> That is really cool!
> 
> I use arduino's for the tanks, but I also have a pi for a media center. Can you do PWM outputs with the pi? I notice a couple of interface boards there, are they shields you bought? Or something you built?
> 
> ...


So that big board on top of the Pi is known as a Gertboard. It is an expansion board that supports a bunch of different functions that you can access via jumper wires. As you can see in the video, I am doing just that. I'm taking advantage of the Open Controller Driver on the right side of the board to bring the relay pins to ground to turn them on. 

The gertboard is a great prototyping tool for the Pi. but, I wouldn't use it for a final product. It costs more than the Pi. So in this case I've learned that I want an OCD for the relay control... in fact, I probably want one for everything that is being ran on DC that is turning on/off since it is capable of supporting 50v and 500mA on each port, is completely isolated from the Pi, and doesn't require any flyback diodes. The actual OCD chip is about $5 right away, or waaaay less if bought in bulk.

I just have to learn about making boards next.

The other item with the display is a dc to dc regulator to bring my 12v source down to 5v to run the relay. The ground from this is also running to the ground pin on the OCD, which is how the relays then get grounded. 

The Pi has a single PWM pin, but i think the gertboard allows more.



benjaf said:


> Great - now I'll have to buy yet another Pi, and figure out how to use it to control an arduino or similar..


well... if you pick up a gertboard, it has a ATmega chip on it, so it'll run arduino code right on that w/ inputs from the pi. https://projects.drogon.net/raspberry-pi/gertboard/using-the-arduino-ide/



mistergreen said:


> You can give out the code and spec for free but ask for donations if they want.


Ah yeah, that thought has crossed my mind. I'm going to give out the code anyway once my site is up and it is completed enough to share.


----------



## mistergreen (Dec 9, 2006)

You can also hook up your existing arduino to the PI, via the USB ports, I think.

http://www.raspberrypi.org/forum/viewtopic.php?f=44&t=46881


----------



## benjaf (Mar 27, 2012)

mistergreen said:


> You can also hook up your existing arduino to the PI, via the USB ports, I think.
> 
> http://www.raspberrypi.org/forum/viewtopic.php?f=44&t=46881


Yes, this is much more likely to be my approach. There are a couple of libraries to handle direct communication, and an Arduino clone is MUCH cheaper than a Gertboard. They are pretty nifty but so expensive!


----------



## scapegoat (Jun 3, 2010)

benjaf said:


> Yes, this is much more likely to be my approach. There are a couple of libraries to handle direct communication, and an Arduino clone is MUCH cheaper than a Gertboard. They are pretty nifty but so expensive!


Yeah, i bought it because I didn't have much of a clue as to what was possible with the Pi. It has been perfect for prototyping though.

But i know now I just need a bunch of OCD's on a board of their own, and probably a GPIO expansion board to handle more then what the Pi can by itself


----------



## benjaf (Mar 27, 2012)

scapegoat said:


> Yeah, i bought it because I didn't have much of a clue as to what was possible with the Pi. It has been perfect for prototyping though.
> 
> But i know now I just need a bunch of OCD's on a board of their own, and probably a GPIO expansion board to handle more then what the Pi can by itself


The main reason I would even need any other controller than the Pi is the lack of PWM pins. 1 just doesn't cut it and 100Hz soft-PWM is way to slow for light dimming. But I guess one could just try to find an I2C board for that..


----------



## O2surplus (Jan 31, 2010)

benjaf said:


> The main reason I would even need any other controller than the Pi is the lack of PWM pins. 1 just doesn't cut it and 100Hz soft-PWM is way to slow for light dimming. But I guess one could just try to find an I2C board for that..


Adafruit's got an I2C controllable 16 channel 12bit PWM break out board that would probably serve your needs nicely. Check it out- http://www.adafruit.com/products/815


----------



## benjaf (Mar 27, 2012)

O2surplus said:


> Adafruit's got an I2C controllable 16 channel 12bit PWM break out board that would probably serve your needs nicely. Check it out- http://www.adafruit.com/products/815


12 bit resolution no less, hmm.. I'll have to do some work to safely drive a MOSFET off of that. But that is certainly the right sort of thing!


----------



## O2surplus (Jan 31, 2010)

benjaf said:


> 12 bit resolution no less, hmm.. I'll have to do some work to safely drive a MOSFET off of that. But that is certainly the right sort of thing!


Why do you need to drive a MOSFET? The chip can output 10ma per channel. Most Led drivers don't require even a fraction of that on their PWM pin to function correctly.


----------



## benjaf (Mar 27, 2012)

O2surplus said:


> Why do you need to drive a MOSFET? The chip can output 10ma per channel. Most Led drivers don't require even a fraction of that on their PWM pin to function correctly.


True. But I am not using dimmable drivers, I'm using MOSFETs to switch the LEDs directly.


----------



## hamato (Jun 7, 2008)

On a side note what relay board are you using? I see some on the bay listed as " 4-Channel Relay Module DC 5V With Optocoupler For Arduino PIC ARM AVR DSP" for under $5. Will this work for simple 6v peristaltic dosing pumps?


----------



## mistergreen (Dec 9, 2006)

hamato said:


> On a side note what relay board are you using? I see some on the bay listed as " 4-Channel Relay Module DC 5V With Optocoupler For Arduino PIC ARM AVR DSP" for under $5. Will this work for simple 6v peristaltic dosing pumps?


With a relay, there are 2 power sources. One to move the magnet to the on position (say 5v/arduino). It's called coil voltage. And another separate power source for your device not connected to the arduino. It's called contact voltage. You should make sure on both specs when buying relays.


----------



## scapegoat (Jun 3, 2010)

and most of those larger relays are used for 110v AC, such as mine.

I'm using a mosfet board for the time being, same as HunterX's, until I can make some cheap open collector driver boards; which, i think, are better/simpler.

I'm using the OCD on my gertboard to handle bringing the relays to ground. however, the OCD, i think, will handle a 50v load on each pin! So a 12v power supply for pumps would be a no brainer.

this is the OCD https://www.adafruit.com/products/970 itself.


----------



## mistergreen (Dec 9, 2006)

An easy solution for the 110v contact relay is to plug in a power adaptor say 6v for the peristaltic pump.


Sent from my iPad using Tapatalk HD


----------



## hamato (Jun 7, 2008)

mistergreen said:


> An easy solution for the 110v contact relay is to plug in a power adaptor say 6v for the peristaltic pump.


I actually have to power an arduino based device (currently powered from 10v power supply) 2 of the 6v dosing pumps and a 12v water pump. I'm trying to do this with a minimum of power supplies & excess equipment. I doubt I'll ever be switching any 120v stuff from my controller. The ebay relays have 5v control and AC250V 10A; DC30V 10A on the output side so I think they should work with some regulation, but open to your suggestion on the best route to go!

Looks like both HunterX and scape are using the same mosfet board. I just want to order stuff soon as ebay has a 1month lead time


----------



## scapegoat (Jun 3, 2010)

i'm using an ac to dc power converter for everything DC related. it's rated at 12v and 2.1a. the thing is, it gets wired directly to mains. Search amazon for dc to dc regulator and you'll find a plethora of options to bring your 30v down to whatever you need. I'm using Amazon.com : DROK Adjustable 4.0-40V to 1.25-37V 5/12V DC LM2596 Voltage Regulator Experimental Power Buck Converter+LED Voltmeter : Electronics and it came preset to 5v out.

A lot of my hardware decisions were directly taken from Hunter's controller. w/o his controller I'd still be sitting on 2 Pi's thinking, "gosh... i should get started"

You'll notice a lot of similarities between the two units as I start building it within a box for actual use. I think mine may end up simpler in appearance because I'm not using any mechanical switches, and both the Pi and relay board require 5v, so i only have 1 dc to dc regulator.

As I'm learning about electronics, as I go, and what I want/need to use, you'll start to see a larger separation between the units when I get to work on my second model.

The mosfet board won't be used with that version as I think I very much prefer the open collector driver. it's a much simpler, and MUCH cheaper, item to use. it'll just require some building on my part.

Once I get prototype 2 done I'll release the code. I'll also be working with a buddy who keeps a reef to build a controller for him to test. something I'm happy to do for others post prototype 2 creation, for component costs (including shipping) and nominal charge for time to put the unit together and shipping.

Once prototype 2 is done for the basic controller I'll move on to ATO code/hardware additions. After that I think I'm going to build an RGB LED fixture and software to control that w/ the controller. I'm dreaming of a full day cycle including dawn and dusk colors, to moonlighting, to everyone's favorite "thunder storm" 

I've got a lot planned for this thing!


----------



## scapegoat (Jun 3, 2010)

I'll have another video up within the next couple days.

Currently this prototype controller is doing everything I want from it.

I can do the following from the GUI:


turn on/off up to 6 relays by clicking a button
schedule any of those relays to turn on/off with military time (schedule is only daily)
assign any of those relays to turn on/off based on temperature from the sensor as well as giving it a temperature to turn on if the tank temp falls below. it'll then turn off once the temp is reached.
tell 2 dosing pumps to turn on at a specific time each day and dose by mL. I give the pump a time and mL, backend figures out how long to turn the pump on to dose that mL based on 12v giving me 100mL in a minute. so 15mL is around 8.8 seconds. I still need to test this to ensure I'm getting 15 mL of liquid

So I will be dosing ferts daily, so probably mixing either a weaker concentration or dosing less. Currently this thing is all still hooked up to a breadboard and on my computer desk. I'll start designing the box and wiring layout. I'm very hopeful to have this thing hooked up to the tank this weekend so I can see it in real action, and start planning out mk 2.

Does anyone have any controller suggestions? as in, what you'd like to see, control, schedule off of? 

A few future additions will be:

ATO
LED dimming w/ PWM
password protection
off network access
data graphing

i'd really like to offer open source, freely available, controller software that is competitive w/ some of the commercial examples on the market.


----------



## salman (Apr 16, 2013)

This sounds really interesting. I like automation. I can probably do the hardware part but not too good with software. You think there is a way to control more than 6 relays with raspberry pi? I saw online somewhere a guy was controlling 16 relays using only 4 pins from pi. Are you also planning to do possibly a sunrise/sunset with LED's? That would be interesting.

What OS do you recommend for Rpi?


----------



## scapegoat (Jun 3, 2010)

salman said:


> This sounds really interesting. I like automation. I can probably do the hardware part but not too good with software. You think there is a way to control more than 6 relays with raspberry pi? I saw online somewhere a guy was controlling 16 relays using only 4 pins from pi. Are you also planning to do possibly a sunrise/sunset with LED's? That would be interesting.
> 
> What OS do you recommend for Rpi?


yeah, I could totally run more if I used a microchip and told it what to do over I2C. Thing is, I only really need 4-5. 2 heaters, one LED fixture, one pump, and my co2. Now, if I was running this on multiple tanks, like my breeding rack, i'd consider it.

I am planning on building an LED fixture as my next big project to handle the sunset/sunrise stuff. I have a BML fixture, and it really doesn't need to be dimmed at all, so i don't see a point in programming that right now.

as far as OS, i'm using Adafruit.com's occidentalis (based on raspian) because it comes with a bunch of useful additions to the kernal for dealing with sensors and such.


----------



## scapegoat (Jun 3, 2010)

I've ordered some float switches from amazon. I top off the sump every couple days, and some times forget and come home to the obnoxious sound of air being sucked into the pump and a tank full of bubbles.

I'll have two, one to trigger a small pump to start, and another as a fail safe if the water level gets too high.

Since i've got an 8 channel relay, and only 6 relays i'm controlling, one of the remaining two will go through this switch. This is easy because the relays just need to be brought to ground, so the switch will merely sit between the relay pin and ground. the second switch will actually sit between the first switch and ground and be "normally on" so that if the sump water gets too high (the top off pump stuck on for some reason) the other float switch will float and kill the connection.

this doesn't require any additional programming, and is all wiring... so why the hell not for $12?

I need to consider connectors for things like probes and these float switches. I was looking at hunter's controller and i suppose the DIN connectors would do nicely enough. I might just solder everything together this time around though.


----------



## mistergreen (Dec 9, 2006)

hmmm, the RPi has no analog input without an addition chip. That means no analog sensors. No pwm except 1.

Maybe plugging in an arduino to this is the way to go. It's cheaper than a gerty board. Why add a bunch of components to extend the RPi when a single arduino will do.
I think that's my route if the coding isn't too much of a problem. I can handle it but I'm think of userbility for folks.

Oh, looks like somebody started a project for home automation already with Rpi and arduino
http://ni-c.github.com/heimcontrol.js/

I'll give it a try. If it needs something for the aquarium hobby, I'll mod it. This project looks exactly what I wanted to do with the arduino originally.


----------



## scapegoat (Jun 3, 2010)

I'll have to check that out. I'd like to know how they got mongodb working since it doesn't support arm. Amd all the builds I've found for it were older and took hours to build on the pi.

No real interest in the arduino right now though. The pi does everything I need at the moment.


----------



## mistergreen (Dec 9, 2006)

I think the mongodb is used to store your settings for the devices.


----------



## scapegoat (Jun 3, 2010)

I know what mongodb is for, I wanted to use it for my project along with another library. Neither were able to be installed right away because neither support the ARM chip. Mongodb ended up being impossible to get going because I needed the latest. The most recently converted version was too old and the time it took to build the software was... hours.

But I wonder of npm could assist with that. I'll give it shot with version 2.


----------



## biogenetic40379 (Jan 19, 2012)

I am making a DIY reef controller this semester for one of my classes. Should be fun


----------



## mistergreen (Dec 9, 2006)

I tried installing all of the software onto the pi. A 4 gig sd card is not enough. Go for 8 or 16GB.

It's a long and tedious process btw. Compiling can take hours since it's only a little mobile computer. When you have everything up and running, I'd suggest you make a disk image copy of your SD card on your real 'computer'. So when or if it crashes and the SD card is corrupted, you can easily mount the disk image over.

Here are a list of compatible sd cards
http://elinux.org/RPi_SD_cards


----------



## scapegoat (Jun 3, 2010)

mistergreen said:


> I tried installing all of the software onto the pi. A 4 gig sd card is not enough. Go for 8 or 16GB.
> 
> It's a long and tedious process btw. Compiling can take hours since it's only a little mobile computer. When you have everything up and running, I'd suggest you make a disk image copy of your SD card on your real 'computer'. So when or if it crashes and the SD card is corrupted, you can easily mount the disk image over.
> 
> ...


that was the plan. I even have an 8gb here waiting.

but in the end I decided i'd rather use stuff that works for it right away and get going. If anything I've learned a bit more about using node, express, and socket.io for web development.

i just got my 2 float switches in, I need to figure out how i'm mounting them as well as how to switch it NO or NC.

figuring out box layout was a bit more difficult than I anticipated. I've got everything, roughly, sitting on plywood waiting to be marked and holes drilled to mount the hardware. 

Mine will be a bit more difficult to set up because it is being mounted between wall studs. so the plug that powers the unit will be underneath, with the outlets and pumps in front. The unit will then open up above the outlets/pumps to get to the hardware. I'll leave a space at the top for ventilation (and network cable) so the two fans will be in the bottom to pull cool air into the box.

I'm unable to really work on the box because my panel saw is inaccessible due to the weather; we have a car in the garage now in front of the saw and work bench.

really looking forward to having this thing on the tank so i've less to worry about w/ it. i'm planning on a complete tank overhaul in the spring though and am seriously considering moving the current inhabitants to a 40 breeder and going either asian or south american themed w/ some smaller gar.


----------



## scapegoat (Jun 3, 2010)

It's totally been awhile since I've updated. I've stalled a bit just being busy with life as well as taking my time to think about the project more.

I decided that the gertboard was much too large to place in a "final" product; especially when I was only using one little chip. So i purchased said chip, and a quarter perma board meant for a Pi w/ ribbon cable.

I need to plan out the board a bit more before getting to work on soldering because I want everything Pi related attached to it, and it is quite small.

I also picked up a plastic indoor electrical box that'll give me about 9"x9" interior space to mount hardware; while the outlets and pumps will get mounted to the door and wired up w/ ample length of stranded wire. All main AC voltage items will go on the left, low DC voltage items on the right.

The attached pictures show the box w/ the quarter board and gertboard next to each other (inside the box for scale), as well as the chip on a breadboard for prototyping.

I need to figure out how to best attach sensors, like the thermometer, and the float switches. So if anyone has any recommendations for that, I'd really appreciate it. I was thinking maybe stereo jacks since I only need low voltage and 2 points of connection.


----------



## mistergreen (Dec 9, 2006)

You can use RJ jacks for inputs. It's fairly easy to work with. You need a crimper and ether net cables though. 

I got the idea from lego mindstorm.


----------



## scapegoat (Jun 3, 2010)

That would work pretty well. I have a box of Ethernet cable... over 400' and the crimping tool. Just need the right ends. Forgot that I needed more than 2 wires for those. The float switches will use stereo jacks.

I love it when a plan comes together


----------



## dubels (Jun 14, 2012)

Any plans for PH controller functions? I have been looking into using a Raspberry Pi to control a tank but don't have a clue in regards to programming. Going to keep an eye in this project to see how it all develops. Thanks for sharing


----------



## scapegoat (Jun 3, 2010)

So i'm not building a box. My woodworking tools are out in the garage, which also contains my wife's STi for the winter; so there isn't any room to work.

Instead I purchased a plastic electrical box that measures 12"x12".

Unfortunately I only have around 9"x9" to work.










and a closer look of how i'm planning on mounting everything.










I am mounting everything to some acrylic that will mount to the box. The box itself will be mounted to a piece of plywood mounted between wall studs. Hence the 9"x9" space I have to work.

So, this is the plan currently. The low voltage electronics are precariously combined via their mounting holes w/ stand offs. The pi will connect to the white perma-board via a ribbon cable, and everything will then connect to the perma-board.

To the right of the perma board is the mosfet board (red) w/ the dc to dc regulator on top.

You may be wondering where the dosing pumps and outlets go... that's the super duper funtime part.

I have a lot less wiring to do than the arduino builds b/c everything i'm controlling will use a web GUI. Which, now that I'm looking at the picture, may need to move the Pi b/c the ethernet port is at the bottom, way too close to 110v.


----------



## scapegoat (Jun 3, 2010)

not a huge update. I've started over. After getting the previous code working as a proof on concept, I decided to have a go at making it a bit cleaner.

I've also began keeping the code in version control on github: https://github.com/bugeyed/osa

I have also purchased a dremel and dremel work station so I can begin drilling the plastic for screws... yet am still playing with the layout. I've decided to mount one of the terminal blocks to the side in order to receive hot, share neutral, and ground to go to the outlets that will be mounted in the door.

in any case, there isn't much to look at. I'm hoping to clean up my basement work bench to begin putting the thing together. then I'll get to work adding the probe stuff back in.

but for anyone inclined, please check out the git repository.


----------



## scapegoat (Jun 3, 2010)

I'm finally getting this thing wired up. I've done what I can to keep the 120v wires cleanly out of the way. I've wired it up with 18g lamp wire. Good for 10a, which is all the main power port is good for. I'm also going to put a 10a fuse inline with the main load coming in; just to be extra safe. I have one around here somewhere

this thing... for all intents and purposes, is ready to fire up for testing. I'm going to blow the box out with compressed air, as well as the ac to dc converter. my main goal is to make sure the dc to dc regulator is reporting 12v in and 5v out, and nothing blows up. after that is done I can grab some 5v electrical cabling and wire up the relay and Pi, to the power and to each other.

once that is secured, i'll do some more work on the web based front end, and finally get the mosfet board hooked up to the Pi to control my peristaltic pumps.

and obviously I need to check the wiring for the 10th time. and yes... that is 14g speaker wire being used for the 12v power supply. it's all I had on hand.

please keep in mind this is a prototype. I've, mostly, enough parts to make a second. but it'll be mounted in either a wooden box, or I'll get myself a nice 3d printer and learn how to design for that.










and after triple checking everything, i plugged it in. the unit successfully powers on without anything exploding. The white arrow is pointing to the display on the ac regulator showing the input is 12v and the output is 5v. so it's time to power the Pi, the relay, and to hook them all up. 










I've got 2-3 items I need to schedule, two pumps, and an auto top off system. so for the time being I'll have 3-4 outlets set for scheduling, one hooked up to my float switches, and probably nothing on the 6th for now.


----------



## mistergreen (Dec 9, 2006)

The main power to the box will need a surge protector. Current spikes can affect other appliances in your house. 

I had my lights, heater, and filter connected straight into the wall for a month and then my electric stove's switch turned on and off by itself for an hour exactly at the time my lights turned on. I couldn't figure it out for the longest time. I even opened up the electric stove and disconnected the switch to see.


----------



## bigd603 (May 10, 2011)

mistergreen said:


> The main power to the box will need a surge protector. Current spikes can affect other appliances in your house.
> 
> I had my lights, heater, and filter connected straight into the wall for a month and then my electric stove's switch turned on and off by itself for an hour exactly at the time my lights turned on. I couldn't figure it out for the longest time. I even opened up the electric stove and disconnected the switch to see.


Wow, thats crazy. I never would have thought that could happen.


----------



## scapegoat (Jun 3, 2010)

I've dedicated the last couple days to the GUI. I think I've finally landed on a general look and feel.

Please keep in mind that this is web based, but developed for phone use. I have some modifications to make for tablets, and even more for desktops.

Here is the dashboard: You'll notice 6 blocks, two of which currently have something in place. This area is going to be used for "quick glances." Are my lights on? yes. what is the water temperature? Eventually, other items will be displayed here... and ultimately, deciding on what is displayed there will happen in the config page.

I've left it at 6 items for simplicity. I'm not sure what else to stick in there at the moment, probably pH. I might raise that section up closer to the title, or remove the title and raise it up to the fill in logo and include a twitter feed so potential users could get notifications of updates, or controller news.










Next is the menu open. Currently displaying the home button (to be replaced with a dashboard icon), and outlet button, and a, non-functional, config icon. the menu is toggled by the three white lines at the top right.










The only place to go from here is the outlets list. This is a really simple listing, with a button/notifier that an outlet is turned on, along the with the label and edit button. I might change the layout later on to look more like the dashboard... but i thought this was easy to read at a glance. The controller code on the Pi actually sends the information to the front end via web sockets. If you're on your phone looking at this, and someone else is on the computer looking at the same screen, and you turn an outlet on, you'll both be told instantly. pretty cool.



















Finally we have the edit modal. This still needs to be spruced up and made prettier. You'll notice that we only have a "save & close" button. This is in order to keep the front end and back end in sync. When you change any of the data on the front end, the front end data is automatically modified due to the two-way automatic binding with AngularJS. You can therefore only close the modal via that button, which then sends the modified data to the server to be updated there.










and yes, you can change the label here. I might include the ability to set an icon as well; which could replace the computer on/off icon. If I change the list layout to blocks, that's a certainty.


----------



## AnotherHobby (Mar 5, 2012)

That's a really nice looking GUI so far! This is a cool project.


----------



## Adrand (Feb 13, 2012)

Amazing. Thanks for keeping this thread updated, its great to see the progress.


----------



## scapegoat (Jun 3, 2010)

Thanks! means a lot. Tomorrow should be another big day as I'm planning on getting the pumps hooked back up and retested, their page situated, and the cover cut up to receive the outlets and pump.


----------



## mistergreen (Dec 9, 2006)

First thing I'd like to see is the controller's time & date and then the states of all of the devices without clicking on them like a preview of aquarium at a glance.


----------



## scapegoat (Jun 3, 2010)

Yup, that's the plan. Hadn't thought about controller date/time, I'll toss that in tomorrow.


----------



## bigd603 (May 10, 2011)

Hey Scapegoat, that UI looks great! It's really fun to see all these projects coming together.


----------



## scapegoat (Jun 3, 2010)

bigd603 said:


> Hey Scapegoat, that UI looks great! It's really fun to see all these projects coming together.



Thanks. The coolest part of building this is seeing what others are doing too. I swiped a lot of ideas from hunter on the hardware... And I really owe it to him for inspiring me to get started.

I'm loving watching all the controller and dosing projects come together.


----------



## bigd603 (May 10, 2011)

I agree, I think Hunter's build has inspired a lot of us, myself included. Shifts auto Doser is really neat as well, and was my first build. Once I get my PCBs in, I'm gonna be getting a lot of the other stuff Hunter recommended (like the power supply).


----------



## AnotherHobby (Mar 5, 2012)

bigd603 said:


> I agree, I think Hunter's build has inspired a lot of us, myself included. Shifts auto Doser is really neat as well, and was my first build. Once I get my PCBs in, I'm gonna be getting a lot of the other stuff Hunter recommended (like the power supply).


For sure! It was this build's use of relays for power control that inspired me to do mine. Same goes for the auto doser, and for me also the current light controller. There are so many great ideas I've learned here!


----------



## scapegoat (Jun 3, 2010)

speaking of inspiration. I've ordered that pressure sensor and am looking forward to putting it to use. I've also ordered a water level sensor. with these two analog sensors I now need to order analog to digital converters. So I'm researching those.

I'm also changing out my main power feed to this sucker: 




10a fuse and switch in one. Tomorrow I'll reveal the front cover, as I'm intending on finally taking my dremel to it and getting power to some outlets. Once that is done it's sort of ready for use.


----------



## scapegoat (Jun 3, 2010)

small update, as I had some real work to attend to today.

just got the outlets and pumps attached to the front door; still have to wire them up though.










I don't recommend using a plastic electrical box as a project box... this stuff is a nightmare to work with. But thankfully I have a corded dremel.


----------



## AnotherHobby (Mar 5, 2012)

I think every project box has its challenges, and you're doing a fine job with yours!


----------



## scapegoat (Jun 3, 2010)

Quick video showing that the web UI works, and instantly.

https://www.youtube.com/watch?v=lBmBi4KFUVQ

the pumps are all wired up, and coded. It's time to get this sucker mounted in my fish room...

oh, and a crappy shot of the internals. it's a mess, I know. remember, "Prototype" haha


----------



## AnotherHobby (Mar 5, 2012)

You have to love those moments when you click your button and it works!


----------



## scapegoat (Jun 3, 2010)

AnotherHobby said:


> You have to love those moments when you click your button and it works!


I love the moments when I plug things in for the first time and it doesn't catch on fire! I just finished soldering the pumps and outlets an hour or so prior to testing them. It was nice to see it work... now, I think I just need to install it. I want to get my float switches taken care of though, since I need to top off this tank daily just about.

It's also exciting that the controller works instantly. There is zero lag because I'm using web sockets instead of AJAX. I've got an ongoing open connection between my browser and the server/application on the Pi.


----------



## scapegoat (Jun 3, 2010)

My controller has officially been put to work. though, I've still some work to do cleaning up my maintenance room and cleaning up the wires. I also need to pick up some airlines and bigger containers for the ferts. I'll be setting up my ATO within the next week or two as well.

right now it's controlling my co2 and lights. co2 turns on at 11am, and off at 6pm, while the lights are 12-8. dosing will be done daily, midnight for the macros and 12:30 for the micros. 

In the near future I want to redo my entire tank... I'd love to build a new sump out of plywood to fit under the stand. really clean up my maintenance room.


----------



## salman (Apr 16, 2013)

Nice to see it work. I have been following your project and liked the wifi capability so i got the raspberry pi and the programming for this is been challenging since i am not too familiar with it at all. I am kind of in over my head on this. lol. The last time i built something was an elevator using Basic Stamp as a class project few years ago but this is way too complicated.
Are you planning to have any details on how to set this thing up on Raspberry Pi? Would be very helpful.


----------



## scapegoat (Jun 3, 2010)

salman said:


> Nice to see it work. I have been following your project and liked the wifi capability so i got the raspberry pi and the programming for this is been challenging since i am not too familiar with it at all. I am kind of in over my head on this. lol. The last time i built something was an elevator using Basic Stamp as a class project few years ago but this is way too complicated.
> Are you planning to have any details on how to set this thing up on Raspberry Pi? Would be very helpful.


Absolutely! I have to clean up my code a bit more and I'll re-release it. If you're looking for hardware inspiration, see Hunter's arduino controller. My hardware choices were basically cut and paste from his.


----------



## salman (Apr 16, 2013)

Yes, I have seen Hunter's arduino controller and that's what inspiresd me to make one. I am good with hardware and is it is no problem for me but the software is little (maybe a lot) rusty. If i can set up the basic program to run on pi, i can learn to modify and tweak. This is the first time i am working with Raspberry pi/arduino. Thank you for the help.


----------



## HunterX (May 19, 2012)

Scape,

I love the interface on this. I really wish I went touchscreen on mine. IOT do so now would require me to build a completly new box. HMMMM I'm seriously thinking about it though.


----------



## Chon_Lee (Jul 4, 2014)

Remote touchscreen.


----------



## glacious (Oct 13, 2014)

Very cool project, I'll be decommissioning an my old RasPi projects to re-purpose one for this. I just poked around on the Github page, is the latest version from Aug1 or has Github just not been updated?


----------



## scapegoat (Jun 3, 2010)

the latest version is not up there. I'll see about updating the repository this weekend.

But please keep in mind that it is heavily WIP. the front end is not nearly done. the dashboard doesn't do anything, and the two items that it displays now are hardcoded as a means to design the appearance and play with ideas.

Currently, it does a wonderful job dosing and scheduling things on and off. 

I need to put together a to do list and start knocking out functionality; but I've been working on a large freelance job for the past 1.5 months and haven't had time to play with this. I might take a week off of working to focus on my controller software.


----------



## glacious (Oct 13, 2014)

Thanks for the reply! I've got the Pi setup now running a few relays via Python scripts and cronjobs. Nothing fancy but it get's the job done with light, night light, temp probe, heater+filter cutoffs.


----------



## scapegoat (Jun 3, 2010)

the latest code has been pushed to the git repository: https://github.com/bugeyed/osa

Please note: root is required to run the project.

I am using Adafruit's OS as it comes prebuilt with a bunch of useful software. https://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-2

Since we're using a raspberry pi, it's not as straight forward to reuse as it would be if we were using a arduino. We've multiple choices of OS, multiple programming languages to use, etc.

In the near future I need to do more documentation on setting up a new raspberry pi... I may look into packaging an entire OS to drop onto an SD card so that it works with minimal fuss.

My next step is to reproduce the current project onto another Raspberry Pi, and set everything up on a breadboard so I can continue working on additional features. Such as using I2C to handle various sensors through a single GPIO. 

I'm lagging way behind, but am hoping to catch up in November.


----------



## glacious (Oct 13, 2014)

excellent, I'll have to try it out.

What are you using for dosing?


----------



## scapegoat (Jun 3, 2010)

glacious said:


> What are you using for dosing?


what do you mean exactly?


----------



## Dropped (Oct 14, 2014)

Love your work there sir!

I have Pi on the way to me at the moment and will be looking to do something similar, would be keen to work on getting this to run on an SD card, if you need a hand sing out.


----------



## glacious (Oct 13, 2014)

scapegoat said:


> what do you mean exactly?


Not so much what you're dosing, but how? Peristaltic 12v pumps?

The Pi can't do 12v alone, so do you just have the pumps connected to 12v controlled by a 5v relay that the Pi controls via GPIO?


----------



## glacious (Oct 13, 2014)

I picked up a 12v peristaltic pump, and I'm driving it with a separate 12v power supply. It's controlled via a TIP120 transistor and a RasPi. Seems to work well, just need to play with the dosing for each pump. Looks like a 0.2sec tick gives me 0.5ml.


----------



## Dropped (Oct 14, 2014)

just picked up a Pi will let you guys know how i get on, is there a new copy of the software?


----------



## saiko (Mar 30, 2007)

scapegoat said:


> In the near future I need to do more documentation on setting up a new raspberry pi... I may look into packaging an entire OS to drop onto an SD card so that it works with minimal fuss.


That would be awesome, especially for challenged guys like me 

Also do you have BOM of your equipments you put up somewhere please?


----------



## HunterX (May 19, 2012)

Hey Scape, How has the controller been running?


----------



## glacious (Oct 13, 2014)

Are you using any kind of PWM on this dosing pumps, or just on/off? Since the Pi only has one true PWM pin, I'm looking into using the PWM option in WiringPi, which for smaller dosing pumps should work out well. Going to do some testsing and see if I get consistent results, slowing the pumps down would give me better accuracy (right now it's ~ 1ml if its triggered for 0.7 seconds).


----------



## salman (Apr 16, 2013)

glacious said:


> Are you using any kind of PWM on this dosing pumps, or just on/off? Since the Pi only has one true PWM pin, I'm looking into using the PWM option in WiringPi, which for smaller dosing pumps should work out well. Going to do some testsing and see if I get consistent results, slowing the pumps down would give me better accuracy (right now it's ~ 1ml if its triggered for 0.7 seconds).


You can just use MOSFET board to control the dosing pumps.


----------



## glacious (Oct 13, 2014)

salman said:


> You can just use MOSFET board to control the dosing pumps.


I did some testing using two pumps on standard GPIO pins with software PWM (built into WiringPi). The dosing was very accurate (+/- 0.1ml) over 4-5ml test samples. The pins were driving a TIP120 to power the pumps.


----------



## handal (Jan 11, 2014)

Hey Scape any updates on the controller?


----------

