Aquarium controller with data collection on MySQL

Hello!

For my thesis I'm going to build an aquarium controller. I'm new to arduino and uC programming, but I have some experience in programming on PC.

Here is my idea of a system:

Arduino part:

  • Arduino parts:

  • Arduino MEGA

  • Ethernet shield

  • Sensor shield

  • DS1307 RTC

  • 20x4 LCD display

  • Sensors:

  • Temp: I will use DS18B20 temp. sensor for measuring water temperature. In case temp get too high or too low, it will give away an alarm(email, speaker, sms or something). It will also start the vents in the canopy to cool the water and lights.

  • Light: it will measure light intensity. It will serve as a feedback if the lights are working and how much output they are giving. Also, I will be able to see how the overall output if falling with usage

  • Current sensor(ACS712 ): they will mostly server as feedback, so I will know if the pump, that is turned on, is actually working(sometimes things break:P)

  • Water level: not sure on the type of sensor I will use. Could go with ultrasonic or eTape(http://www.milonetech.com/), or even with pressure sensor. I want to have the simplest solution that doesn't require drilling or too much work on the tank. eTape seems the easiest idea, but I would also add an additional float sensor on the top of the tank for "ALARM" state:)

  • Devices:

  • 8x opto-insulated relay switch: turning on and off all the power devices: 3x pumps, 1x lighting, 1x heater,...

  • 1x PWM 0-10V for lighting control (it has a 0-10V input): have to find and make the circuit

  • 1x PWM 0-12V for moonlight(already have a cold catode lamp) or maybe getting a bright blue LED and driving that

How it should work:
Hard to say in a few works:) Maby if I put it in modules, it will be easily to describe:)

*Basic operation: filter pump turns on as soon as systems gets online, same happens with heater. Systems monitors temperature and current on the pump and issues error if everything is not OK.
*Lights: With the help of RTC modules, they are on 10h/day, with 1h simulated sunrise and 1h simulated sundown(with the help of PWM). Current is monitored, and so is the light intensity.
*Current simulation: there will be 2 pumps on the opposite side of tank, which will turn on and off every 5 or so seconds and will simulate the current...
*Storm & weather simulation: Change in light intensity(bright clouds, dark clouds), lightning simulation with bright LED, maby change in current to be more random(have to read up on that)
*Moon simulation: during the night time, simulate the moon with LED(could use the same as for lightning)

Future ideas(for later):

  • Feeding
  • Adding nutrition for plants
  • Water testing(NO3, PO4,...)
  • CO2 control (using pH sensor and CO2 valve)

PC part:
Arduino will be connected to the network. I plan on running MySQL database on the computer on which arduino will send data from it's sensors.

Latest data will be shown on the web page(not sure yet of the design, probably something simple in the beginning) and there will be an overview of all data using graphs. For drawing of graphs, I will use monitoring tool called 'munin'. Later I might create my own scripts using RRDTool.

What do you think?
What am I missing?
Is that doable the way I want or is there a major problem somewhere in the project?
What would you do differently?

Thanks, Matej

Is that doable the way I want or is there a major problem somewhere in the project?

The project is doable. Start with one sensor at time. Get all the input working. Then, add output, via a served web page. Then, add output via GET requests to the server where the MySQL database is running.

It's not only doable, but the acquarium controller piece has been done many times before - you should be able to find writeups on-line. Communicating with MySQL isn't a new thing either, so combining the two shouldn't be too much of a problem. I wouldn't be surprised to find an existing project that had done both.

Just make sure that your shields are compatible - it's not uncommon to have conflicts where they both want to use the same pin for their own purposes. Not an insurmountable problem, but nicer if you don't have to deal with it.

As far as MySQL goes, I still haven't decided weather I would send data to server via web page or insert it directly into mysql using MySQL Connector.

I was thinking of using MySQL directly, but it might be safer and easier to solve that via web page, since SQL database could then be located at a hosting service like Amazon or other shared service...

I'm still not sure how I would "push" new settings to the controller since I would also like to do that over network and web.
One option is to run a web server on arduino(not a fan, since it causes lots of problems).
Another is for the controller to contact the server every now and then and check for a "new settings flag". If it exists, it visits a certain web page that sends back the new settings from sql database...
Anyone has any other idea?

As far as shields go, I will only use Ethernet shield. I just have to take a look at what pins are used by ethernet shield...

PaulS: that was my plan... One sensor at the time, set up all the inputs and outputs and then move to ethernet communication and so on...

wildbill: I noticed some projects like my own. I will look at their source for the hints, but I want to do most of the project on my own, since I want to gather knowledge of programming and using arduino...

I will keep you posted on the progress here...

Matej

If you push your data to the database via a GET request as PaulS suggests, you can return data to control your settings in the response. Perhaps the actual setting data to be parsed or just a flag that indicates that you need to hit another page to get updated data. Either way, no need to run a web server on the Arduino.

After some reading and thinking, I'm thinking that the best solution would be to transfer data in JSON format. From and to Arduino...

I notices there are some nice libraries already written for arduino, and for the server side, I could code something in php or python... That might be better then sending data with GET. Also, they are nicely structured because of the JSON format and easily readable if I need to debug...

Matej

I'm thinking that the best solution would be to transfer data in JSON format. From and to Arduino...

The Arduino will have a hard time parsing the JSON data. There are much easier formats to use, that don't require near as much memory to parse. Keep in mind that memory is one thing you don't have a lot of.

What would you recommend?

Also, I have the Mega 2560 model, which is a little fatter(256kb I think) with the memory, but I don't have the feeling if that's a lot of memory or not:)

Matej

I'm trying this for my first project (aquarium controller)

http://arduino-aquarium.blogspot.com/ this guy also has videos on YouTube.
Only thing I'm gonna add is a water sensor or 2 on the floor to initiate an alarm if it detects water on the floor.

For relays I made this, no Arduino in the box, Ethernet cords to communicate with Arduino.

Reefcentral.com has a thread were people have posted their Arduino code (mostly for controlling lights, adding simulated clouds)

Version 2 will have wireless shield and MySQL. Good luck