Open Aquarium has been designed to help you to take care of your fish by automating the control and maintenance tasks that take place in the fish tanks and ponds. Open Aquarium consists of two different and complementary kits: Basic and Aquaponics, and many several extra accessories.
There are 5 sensors available in the platform to measure the key parameters in the fish tank such as temperature, pH or Conductivity and then some others to control the correct state of the fish tank (level and leakages). In addition, there are 4 different actuators to automate tasks such as heating or cooling the water, feeding the fish, activating the pumps for water change or medicines administration, and controlling the intensity of the light to simulate the day/night cicles.
A complete Open Source API is included to easily control the board through Arduino. And we have also designed a web application that allows to store in a data base the information gathered and visualize it from a browser and from iPhone / Android devices. We have released it as Open Source code too, so that you can improve it and make it personal for your own product!
Open Aquarium has been designed to work with both 220V (Europe) & 110V (US). For more info go to the "Electrical Features section"
Basic Kit:DISCLAIMER: A bad use or failure of the elements of Open Aquarium (heaters, fan cooler, etc) may vary the ideal living conditions of the fish risking their lives. Please have this into account when setting the system in your fish tank. Open Aquarium is an educational and experimentation platform. Try the system on a fish tank with no fish in it until you get the right conditions and check the system stability during some weeks.
The pack we are going to use in this tutorial is the Open Aquarium platform from Cooking Hacks. Open Aquarium is fully compatible with Arduino UNO.
Open Aquarium must be powered by an external power supply (12V - 2A).
Open Aquarium has been designed to work with both 220V (Europe) & 110V (US). To use the RF Power Strip in 110V power setups you just need to use this 110-220V Power Converter.
Open Aquarium gateway communicates with the RF power strip with FSK modulation (Frequency-shift keying) at 433MHz.
Can I use the 433MHz radios included in Open Aquarium in the US?
Yes. The US Federal Communications Commission (FCC) regulates operation at 433 MHz under Regulation 10CFR47 Part 15.231. This frequency band is intended for remote control, although some other usages are possible with some restrictions:
References:
http://www.ti.com/lit/an/swra090/swra090.pdf
Steve Montgomery, General Manager, Digital Six Laboratories, LLC, 11/26/2013
Can I use the 433MHz radios included in Open Aquarium in Europe?
Yes. The 433MHz band is unlicensed and free of use in Europe. For extra information about the R&TTE / CEPT / ETSI directive read the next document.
Open Aquarium counts with a C++ library that lets you read easily all the sensors and send the information by using any of the available radio interfaces. This library offers an simple-to-use open source system.
Open Aquarium includes a high level library functions for a easy manage of the board. Before start using this functions you should download the files from this link. This zip includes all the files needed in one folder, "OpenAquarium". Copy this folder in the arduino IDE folder "libraries". Don't forget include these libraries in your codes.
Download the Open Aquarium Libraries for Arduino.
Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. Inside the folder will be the .cpp files, .h files and often a keywords.txt file, examples folder, and other files required by the library.
To install the library, first quit the Arduino application. Then uncompress the ZIP file containing the library. For installing Open Aquarium library , uncompress OpenAquarium.zip. It should contain a folder called "Open Aquarium", with files like OpenAquarium.cpp and OpenAquarium.h inside. Drag the Open Aquarium folder into this folder (your libraries folder). Under Windows, it will likely be called "My Documents\Arduino\libraries". For Mac users, it will likely be called "Documents/Arduino/libraries". On Linux, it will be the "libraries" folder in your sketchbook.
The library won't work if you put the .cpp and .h files directly into the libraries folder or if they're nested in an extra folder. Restart the Arduino application. Make sure the new library appears in the Sketch->Import Library menu item of the software.
That's it! You've installed a library!
Sensor initializing functions:
init() //Include: initports(), welcome(),initDS18B20() and initRTC() initports() //Initialize all ports welcome() //Print a welcome message
Lighting program:
lighting() //Give necessary day light for fish depending on time fadelight() //Fading light lightON() //Turn ON the light lightOFF() //Turn OFF the light
Leak functions:
leak() //If water leakage detected, turn off all pumps and an alarm sounds
Delete variable function:
newday() //Delete all variables
Feed fish functions:
feedfish() //Makes a rotation of the automatic fish feeder readyforfeeding() //Prepare feeder for feeding
Water change functions:
empty() //Empty aquarium, turns ON pump1 until level2 detected and dosing drops fill() //Fill aquarium after empty turning ON pump2 until level1 detected
Water level functions:
waterlevel1() //Get the status of the water level 1 and print a message waterlevel2() //Get the status of the water level 2 and print a message readwaterlevel(out) //Get the status of the water level 1 or 2
Pumps functions:
pumpON(out) //Turn ON the water pump with the number "out" pumpOFF(out) //Turn OFF the water pump with the number "out" perpumpON(out) //Turn ON the peristaltic pump with the number "out" perpumpOFF(out) //Turn OFF the peristaltic pump with the number "out"
Buzzer functions:
alarm() //Alarm sound playTone() //Makes song sound openingsong() //Makes a melody with buzzer
RTC functions:
initRTC() //Initializing necessary for the RTC setTime() //Get the computer's time and date getTime() //Get a struct with current time and date printTime(now) //Serial print the struct obtained with getTime
Power strip functions:
sendPowerStrip(plug) //Send a signal to turn on or off a plug
DS18B20 functions:
initDS18B20() //Initializing necessary for sensor DS18B20 readtemperature() //Return the value of the DS18B20 sensor tempcontrol(temperature) //Temperature control with Power strip (25-27°C).Heater in socket 5 and //fan cooler in 4. An alarm sounds if temperature is higher than 30°C
Aquaponics functions:
calibratepH(calibration_point_4,calibration_point_7,calibration_point_10) //pH sensor calibration readpH() //Return pH value in mV pHConversion(mvpH) //Returns the value of the pH sensor calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal) //EC sensor calibration readResistanceEC() //Returns EC Value in resistance ECConversion(_resistanceEC) //Returns EC Value in µS/cm
The complete kit can be found here.
The parts of this kit are:
This sealed digital temperature probe lets you precisely measure temperatures in wet environments with a simple 1-Wire interface. The DS18B20 sensor provides 9 to 12-bit (configurable) temperature readings over a 1-Wire interface, so that only one wire (and ground) needs to be connected from a central microprocessor.
Features:
The DS18B20 sensor has three connections (positive, negative and data).
Gateway connection
Connect the red wire with the positive terminal (marked as "VCC" in the board), the black wire with the negative terminal (marked as "GND" in the board) and the white wire with the Data terminal (marked as "DATA" in the board).
After connecting the cables, tighten the screws.
Getting data:
The water temperature can be read with a simple function. This function return a float with the value.
Example:
{ temperature = OpenAquarium.readtemperature(); }
Upload the next code for seeing water temperature in the serial monitor:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" float temperature; void setup() { OpenAquarium.init(); //Initialize Serial.begin(115200); } void loop() { temperature = OpenAquarium.readtemperature(); //Read the sensor Serial.print("Temperature: "); Serial.print(temperature); Serial.println("'C"); delay(2000); //Wait 2 seconds }
Here is the USB output using the Arduino IDE serial port terminal:
The Open Aquarium gateway has a built in Real Time Clock (RTC), which keeps it informed of the time. This allows Open Aquarium to be programmed to perform time-related actions.
Features:
Setting the time:
The RTC can be synchronized with the computer with this function in the setup()
{ OpenAquarium.setTime(); //write time to the RTC chip }
Getting the time:
You can read the date and time with this function
{ now = OpenAquarium.getTime(); //Get date and time }
Setting the time:
Upload the next code to set the time:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" DateTime now; void setup() { Serial.begin(115200); OpenAquarium.initRTC(); //Initialize RTC OpenAquarium.setTime(); //write time to the RTC chip } void loop() { delay(1000); }
Getting the time:
Upload the next code to get the time:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" DateTime now; void setup() { Serial.begin(115200); OpenAquarium.initRTC(); } void loop() { now = OpenAquarium.getTime(); //Get date and time //First way: Print date and time at once Serial.print("1er way: "); OpenAquarium.printTime(now); //Second way: separate variables Serial.print("2nd way: "); Serial.print(now.month(), DEC); Serial.print("/"); Serial.print(now.day(), DEC); Serial.print("/"); Serial.print(now.year(), DEC); Serial.print(" "); switch (now.dayOfWeek()) // Friendly printout the weekday { case 1: Serial.print("MON"); break; case 2: Serial.print("TUE"); break; case 3: Serial.print("WED"); break; case 4: Serial.print("THU"); break; case 5: Serial.print("FRI"); break; case 6: Serial.print("SAT"); break; case 7: Serial.print("SUN"); break; } Serial.print(" "); Serial.print(now.hour(), DEC); Serial.print(":"); Serial.print(now.minute(), DEC); Serial.print(":"); Serial.println(now.second(), DEC); delay(1000); }
Here is the USB output using the Arduino IDE serial port terminal:
Freatures:
Water level has two connections. Connect the wires in the water level connector. The contacts have not polarization.
Gateway connection
Connect two wires into the terminal. Wires position doesn't matter.
After connecting the cables, tighten the screws.
Getting data:
The water level switch can be read with two simple functions and you can also choose the number of water level to read.
Example:
{ OpenAquarium.waterlevel1(); OpenAquarium.readwaterlevel(2); }
Upload the next code for seeing data in the serial monitor:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" int status=0; void setup() { OpenAquarium.init(); //Initialize Serial.begin(115200); } void loop() { Serial.println("1st way"); OpenAquarium.waterlevel1(); delay(1000); //Wait 2 seconds Serial.println("2nd way"); status = OpenAquarium.readwaterlevel(1); if (status==HIGH){ Serial.println("Aquarium full"); } if (status==LOW){ Serial.println("Aquarium empty"); } Serial.println(""); }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
The Automatic Fish Feeder has only one connector.
Gateway connection
Bend the connector and insert it into the bigger gland.
Connect it into the "FEEDER" connector.
Actuating:
Makes a rotation of the fish feeder.
Example:
{ OpenAquarium.feedfish(); OpenAquarium.readyforfeeding(); }
Upload the next code for feeding fish at 11:30 and at 23:30:
NOTE: If you want to feed your fish more than one time a day you have to use readyforfeeding() function one minute before feed them..
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" DateTime now; void setup(){ Serial.begin(115200); OpenAquarium.init(); } void loop(){ now =OpenAquarium.getTime(); OpenAquarium.printTime(now); if (now.hour() == 11 && now.minute() == 30){ OpenAquarium.feedfish(); } if (now.hour() == 23 && now.minute() == 29){ OpenAquarium.readyforfeeding(); } if (now.hour() == 23 && now.minute() == 30){ OpenAquarium.feedfish(); } if (now.hour() == 23 && now.minute() == 59){ OpenAquarium.newday(); } }
Here is the USB output using the Arduino IDE serial port terminal:
Upload the next code for a full example of Open Aquarium Basic.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" float temperature; DateTime now; void setup(){ Serial.begin(115200); OpenAquarium.init(); } void loop(){ now =OpenAquarium.getTime(); OpenAquarium.printTime(now); temperature=OpenAquarium.readtemperature(); Serial.println(temperature); OpenAquarium.waterlevel1(); if (now.hour() == 11 && now.minute() == 30){ OpenAquarium.feedfish(); } if (now.hour() == 23 && now.minute() == 59){ OpenAquarium.newday(); } delay(500); }
Step 1:
Insert a flange on a suction cup.
Step 2:
Put the suction cup arround the water level and tight it right.
Step 3:
Insert the water level into your aquarium. Water level must be completely submerged.
Step 4:
Take another flange with a suction cup and hold the DS18B20 cable.
Step 5:
Place the temperature sensor into your aquarium and sitck it to the wall. The sensor must be inserted at least 4 cm in water.
Step 6:
Hang the fish feeder on the edge of your aquarium.
Step 7:
Screw it right to the wall.
Step 8:
Power OpenAquarium.
The parts of this kit are:
NOTE: Aquaponics extension needs Open Aquarium shield in order to work.
Features:
The pH sensor probe has only one connector which integrates all the different wires of the sensor. It is a BNC connector.
You can connect it directly to the Open Aquarium Aquaponics board.
After connecting the cable, tighten the connector.
Getting data
With this functions we can read the value of the sensor.
Example:
{ OpenAquarium.calibratepH(calibration_point_4,calibration_point_7,calibration_point_10); int mvpH = OpenAquarium.readpH(); //Value in mV of pH float pH = OpenAquarium.pHConversion(mvpH); //Calculate pH value }
Calibrating the sensor
In order to calibrate the pH sensor you can buy the pH calibration kit calibration kit and obtain the pH values in mV (millivolts) with the function OpenAquarium.readpH() for the three values of pH. Now you must change the #defines in the top of the sketch.
#define calibration_point_4 2153 //Write here your measured value in mV of pH 4 #define calibration_point_7 1972 //Write here your measured value in mV of pH 7 #define calibration_point_10 1816 //Write here your measured value in mV of pH 10
Upload the next code for seeing data in the serial monitor.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" #define calibration_point_4 2221 //Write here your measured value in mV of pH 4 #define calibration_point_7 2104 //Write here your measured value in mV of pH 7 #define calibration_point_10 2031 //Write here your measured value in mV of pH 10 void setup() { Serial.begin(115200); OpenAquarium.init(); OpenAquarium.calibratepH(calibration_point_4,calibration_point_7,calibration_point_10); delay(1000); } void loop() { int mvpH = OpenAquarium.readpH(); //Value in mV of pH Serial.print(F("pH Value in mV = ")); Serial.print(mvpH); Serial.print(F(" // pH = ")); float pH = OpenAquarium.pHConversion(mvpH); //Calculate pH value Serial.println(pH); delay(2000); //Wait two seconds }
Here is the USB output using the Arduino IDE serial port terminal:
NOTE: When you use the pH sensor you can't use the level number 2. However you can still using level 1.
Features:
The electro-conductivity sensor probe has two connections. Connect the wires in the EC connector. The contacts have not polarization.
After connecting the cable, tighten the connector.
Getting data
With this simple function we can read the value of the sensor.
Example:
{ OpenAquarium.calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal); float resistanceEC = OpenAquarium.readResistanceEC(); //EC Value in resistance float EC = OpenAquarium.ECConversion(resistanceEC); //EC Value in µS/cm }
Calibrating the sensor
In order to calibrate the electro-conductivity sensor you can buy the conductivity calibration kit and obtain the EC values in resistance with the function OpenAquarium.readResistanceEC() for two values of EC. Now you must change the #defines in the top of the sketch. For example if you use the calibration kit with 10500 µS/cm and 40000 µS/cm you will need to write something like this:
#define point_1_cond 40000 // Write here your EC calibration value of the solution 1 in µS/cm #define point_1_cal 40 // Write here your EC value measured in resistance with solution 1 #define point_2_cond 10500 // Write here your EC calibration value of the solution 2 in µS/cm #define point_2_cal 120 // Write here your EC value measured in resistance with solution 2
Upload the next code for seeing data in the serial monitor.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" #define point_1_cond 40000 // Write here your EC calibration value of the solution 1 in µS/cm #define point_1_cal 40 // Write here your EC value measured in resistance with solution 1 #define point_2_cond 10500 // Write here your EC calibration value of the solution 2 in µS/cm #define point_2_cal 120 // Write here your EC value measured in resistance with solution 2 void setup() { Serial.begin(115200); OpenAquarium.init(); OpenAquarium.calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal); delay(500); } void loop() { float resistanceEC = OpenAquarium.readResistanceEC(); //EC Value in resistance Serial.print(F("EC Value in resistance = ")); Serial.print(resistanceEC); Serial.print(F(" // EC Value = ")); float EC = OpenAquarium.ECConversion(resistanceEC); //EC Value in µS/cm Serial.print(EC); Serial.println(F(" uS/cm")); delay(2000); //Wait 2 seconds }
Here is the USB output using the Arduino IDE serial port terminal:
NOTE: When you use the electro-conductivity sensor you can't use the dosing pump number 3. However you can still using dosing pumps number 1 and 2.
Upload the next code for a full example of Open Aquarium Aquaponics.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" #define point_1_cond 40000 // Write here your EC calibration value of the solution 1 in µS/cm #define point_1_cal 40 // Write here your EC value measured in resistance with solution 1 #define point_2_cond 10500 // Write here your EC calibration value of the solution 2 in µS/cm #define point_2_cal 120 // Write here your EC value measured in resistance with solution 2 #define calibration_point_4 2221 //Write here your measured value in mV of pH 4 #define calibration_point_7 2104 //Write here your measured value in mV of pH 7 #define calibration_point_10 2031 //Write here your measured value in mV of pH 10 void setup(){ Serial.begin(115200); OpenAquarium.init(); OpenAquarium.calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal); OpenAquarium.calibratepH(calibration_point_4,calibration_point_7,calibration_point_10); delay(500); } void loop(){ float resistanceEC = OpenAquarium.readResistanceEC(); //EC Value in resistance Serial.print(F("EC Value in resistance = ")); Serial.print(resistanceEC); Serial.print(F(" // EC Value = ")); float EC = OpenAquarium.ECConversion(resistanceEC); //EC Value in µS/cm Serial.print(EC); Serial.println(F(" uS/cm")); int mvpH = OpenAquarium.readpH(); //Value in mV of pH Serial.print(F("pH Value in mV = ")); Serial.print(mvpH); Serial.print(F(" // pH = ")); float pH = OpenAquarium.pHConversion(mvpH); //Calculate pH value Serial.println(pH); delay(2000); }
Step 1:
Insert a flange on a suction cup.
Step 2:
Fix the pH sensor with the flange.
Step 3:
Insert the pH sensor into the water. The sensor must be inserted at least 4 cm in water.
Step 4:
Insert another flange on a suction cup and fix the electroconductivity sensor.
Step 5:
Insert the electroconductivity sensor in the water. The sensor must be inserted at least 4 cm in water.
Step 6:
Power OpenAquarium.
To facilitate the installation of Open Aquarium, the kits include different types of boxes. In this step, we will explain you a way to mount the box but it is only an example. You can set the box as you want depending on the number of sensors, the type of power supply, the number of actuators or the place where you are going to place the box.
You can differentiate between two types of boxes.
To mount this box, you will need the following material.
First, you have to put the glands and the vent plug in the different holes of the box.
You have to tight the nuts.
Once the glands are fixed, you need to fix the Arduino to the internal plate with four M3 screws and nuts.
Then, you have to fix the plate to the box.
Now you have to take the Open Aquarium Gateway and screw the sensor and actuators in the correct position.
Mind the wires position.
You can choose the nearest gland to screw the sensor easily.
After that tighten all the glands, put on the Open Aquarium Gateway over the Arduino.
Finally, you can close the box.
And you have got the gateway box ready to use.
To mount this box, you will need the following material.
First, you have to put the glands in the different holes of the box and tight their nuts.
Once the glands are fixed, you need to fix the Arduino to the internal plate with four M3 screws and nuts.
Then, you have to fix the plate to the box.
Then, you have to take the Open Aquarium Gateway and screw the sensor and actuators in the correct position.
Now take the Aquaponics extension board and put it over Open Aquarium shield.
Screw the EC sensor
Now put the BNC pigtail in the box.
Connect the pH sensor to the external BNC connector.
Connect the BNC pigtail to the Aquaponics extension.
Now put the Open Aquarium Gateway over the Arduino and the RF communication module.
Finally you can close the box. You have got the gateway box with Aquaponics ready to use.
Open Aquarium has been designed to work with both 220V (Europe) & 110V (US). To use the RF Power Strip in 110V power setups you just need to use this 110-220V Power Converter.
Features:
Features:
To use this actuator you will need the following materials:
First, you need to power the RF Power Strip.
Then, connect the shield to the computer with the USB cable, put the antenna and put the jumpers in the correct position (RX, at the right).
Connect the RX module to the Open Aquarium gateway.
Once you have got the device ready for reading the values of the remote control, you need to upload the reading RF code to your Arduino.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" void setup() { Serial.begin(115200); RemoteReceiver::init(0, 2, readCodes); } void loop() { } void readCodes(unsigned long receivedCode, unsigned int period) { RemoteReceiver::disable(); interrupts(); unsigned long code=receivedCode; code = code & 0xFFFFF; code |= (unsigned long)period << 23; code |= 3L << 20; Serial.println(code); RemoteReceiver::enable(); }
Now, open the serial monitor and press the different buttons of the remote control to a distance of 10 centimeters from the antenna and you will see the codes of each button.
For example these are the received codes when you press the button 1 ON:
1580367986 1605533810 1597145202 1613922418 1588756594
And these are the received codes when you press the button 1 OFF:
1580367988 1605533812 1597145204 1613922420 1588756596
Please, note you receive multiple codes for a single button, all of them are valid, but we recommend choosing the value fixed when holding down the button for 2 seconds. You can also observe that both are often consecutive and have a difference of 2.
For example we have choose these two codes:
on1: 1613922418
off1: 1613922420
Save all your chosen codes for all the buttons in a .txt file.
If you want to use tempcontrol(temperature) function in order to control your aquarium temperature you have to modify the library.
Put your codes at the beginning of the OpenAquarium.h file and connect the heater in socket 5 and the fan cooler in socket 4.
NOTE: You can also change temperature range in tempcontrol(temperature) function to adecuate it for your fish species.
After that, put the jumpers in the correct position (TX, at the left).
Now, change the RX module to the TX module.
Once you have got the device ready for sending the values of the remote control, you need to put the saved codes of each button in the code and upload it to your Arduino.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" //Power strip codes. Please insert here your own codes generated with //RF_Receive_remoteControl_codes unsigned long on1 = 1613922418; unsigned long off1 = 1613922420; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); } void loop() { OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.println("Plug 1: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off1);//Turn OFF plug 1 Serial.println("Plug 1: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on2); //Turn ON plug 2 Serial.println("Plug 2: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off2);//Turn OFF plug 2 Serial.println("Plug 2: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on3); //Turn ON plug 3 Serial.println("Plug 3: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off3);//Turn OFF plug 3 Serial.println("Plug 3: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on4); //Turn ON plug 4 Serial.println("Plug 4: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off4);//Turn OFF plug 4 Serial.println("Plug 4: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on5); //Turn ON plug 5 Serial.println("Plug 5: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off5);//Turn OFF plug 5 Serial.println("Plug 5: OFF"); delay(3000); //Wait five seconds }
You will be able to see how it turns on and off all the plugs in your RF power strip.
NOTE: When sending RF codes It's important that there is a minimum distance of 1 meter between the Open Aquarium antenna and the RF power strip. With smaller distances you can lose some pulses. Please check that you don't lose any pulse when your Open Aquarium is installed in the final place.
Actuating:
The RF power strip can be activated with a simple function which must include the code of the plug that we want to actuate.
Example:
{ OpenAquarium.sendPowerStrip(on1); //Turn ON the plug number 1 OpenAquarium.sendPowerStrip(off3); //Turn OFF the plug number 3 }
Upload the next code to turn on and off all the plugs in your RF power strip:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include <OpenAquarium.h> #include <Wire.h> //Power strip codes. Please insert here your own codes generated with //RF_Receive_remoteControl_codes unsigned long on1 = 1613922418; unsigned long off1 = 1613922420; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); } void loop() { OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.println("Plug 1: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off1);//Turn OFF plug 1 Serial.println("Plug 1: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on2); //Turn ON plug 2 Serial.println("Plug 2: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off2);//Turn OFF plug 2 Serial.println("Plug 2: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on3); //Turn ON plug 3 Serial.println("Plug 3: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off3);//Turn OFF plug 3 Serial.println("Plug 3: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on4); //Turn ON plug 4 Serial.println("Plug 4: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off4);//Turn OFF plug 4 Serial.println("Plug 4: OFF"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(on5); //Turn ON plug 5 Serial.println("Plug 5: ON"); delay(3000); //Wait five seconds OpenAquarium.sendPowerStrip(off5);//Turn OFF plug 5 Serial.println("Plug 5: OFF"); delay(3000); //Wait five seconds }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
The water leak sensor has two connections. Connect the wires in the water leak connector. The contacts have not polarization
Gateway connection
Connect two wires into the terminal. Wires position doesn't matter.
After connecting the cables, tighten the screws.
Read values:
Leak sensor reads an analog value and makes alarm sound if it detects water presence.
Example:
{ OpenAquarium.leak(); //Reads value of the leak sensor and make alarm sound }
Upload the next code for seeing data in the serial monitor. If there is water leakage, an alarm sound.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" void setup() { OpenAquarium.init(); //Initialize Serial.begin(115200); } void loop() { OpenAquarium.leak(); delay(2000); //Wait 2 seconds }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
You can connect the fan cooler in any of the available sockets in the RF power strip. If you are going to use tempcontrol(temperature) function you have to connect it in socket 4.
Actuating:
The RF power strip can be activated with a simple function which must include the code of the plug that we want to actuate.
Example:
{ OpenAquarium.sendPowerStrip(on1); //Turn ON the plug number 1 OpenAquarium.sendPowerStrip(off3); //Turn OFF the plug number 3 }
Upload the next code to control the temperature between 26 and 28°C
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" float temperature; //Power strip codes unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); OpenAquarium.init(); } void loop() { temperature=OpenAquarium.readtemperature(); Serial.println(temperature); if(temperature>28){ OpenAquarium.sendPowerStrip(on4); //Turn ON plug 4 Serial.println("Fan ON"); } if(temperature<26){ OpenAquarium.sendPowerStrip(off4); //Turn OFF plug 4 Serial.println("Fan OFF"); } delay(500); }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
You can connect the heater in any of the available sockets in the RF power strip. If you are going to use tempcontrol(temperature) function you have to connect it in socket 5.
Actuating:
The RF power strip can be activated with a simple function which must include the code of the plug that we want to actuate.
Example
{ OpenAquarium.sendPowerStrip(on1); //Turn ON the plug number 1 OpenAquarium.sendPowerStrip(off3); //Turn OFF the plug number 3 }
Upload the next code to control the temperature between 25 and 27°C
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" float temperature; //Power strip codes unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); OpenAquarium.init(); } void loop() { temperature=OpenAquarium.readtemperature(); Serial.println(temperature); if(temperature<25){ OpenAquarium.sendPowerStrip(on5); //Turn ON plug 5 Serial.println("Heater ON"); } if(temperature>27){ OpenAquarium.sendPowerStrip(off5); //Turn OFF plug 5 Serial.println("Heater OFF"); } delay(500); }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
The water pump has two connections (positive and negative).
Gateway connection
Connect the brown wire with the positive terminal (marked with a "+"" in the board), the blue wire with the negative terminal. As you can see, you can connect this actuator in two different positions. Or, if you want, you can connect two different actuators.
After connecting the cables, tighten the screws.
Actuating:
The pump can be activated with a simple function which must include the number of pump (1 or 2)
Example:
After connecting the cables, tighten the screws.
{ OpenAquarium.pumpON(1); //Turn ON the pump number 1 OpenAquarium.pumpOFF(2); //Turn OFF the pump number 2 }
Upload the next code to activate/deactivate the pump each five seconds:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" void setup() { Serial.begin(115200); OpenAquarium.init(); } void loop() { OpenAquarium.pumpON(1); //Turn ON the pump number 1 (insert 1 or 2) Serial.println("Pump 1: ON"); delay (5000); //Wait five seconds OpenAquarium.pumpOFF(1); //Turn OFF the pump number 1 (insert 1 or 2) Serial.println("Pump 1: OFF"); delay (5000); //Wait five seconds }
Features:
The peristaltic pump has two connections (positive and negative).
Gateway connection
Connect the red wire with the positive terminal (marked with a "+"" in the board), connect the black wire with the remaining terminal. As you can see, you can connect this actuator in three different positions. Or, if you want, you can connect three different actuators.
After connecting the cables, tighten the screws.
Actuating:
The pump can be activated with a simple function which must include the number of pump (1, 2 or 3)
Example:
After connecting the cables, tighten the screws.
{ OpenAquarium.perpumpON(1); //Turn ON the pump number 1 OpenAquarium.perpumpOFF(3); //Turn OFF the pump number 3 }
NOTE: If you want to use empty() function, you can choose number of drops changing it in OpenAquarium.h file
Upload the next code to activate/deactivate the peristaltic pump each five seconds:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" void setup() { Serial.begin(115200); OpenAquarium.init(); } void loop() { OpenAquarium.perpumpON(1); //Turn ON the peristaltic pump number 1 (insert 1 or 2) Serial.println("Peristaltic pump 1: ON"); delay (5000); //Wait five seconds OpenAquarium.perpumpOFF(1); //Turn OFF the peristaltic pump number 1 (insert 1 or 2) Serial.println("Peristaltic pump 1: OFF"); delay (5000); //Wait five seconds }
Here is the USB output using the Arduino IDE serial port terminal:
Features:
LED lamp has a mini jack connection - two connections (positive and negative)
Gateway connection
Connect the brown wire with the positive terminal (marked with a "VCC" in the board), the blue wire with the negative terminal (marked with a "GND" in the board).
After connecting the cables, tighten the screws.
Actuating:
Light intensity changes in order to simulate daylight
Example:
After connecting the cables, tighten the screws.
{ OpenAquarium.lighting(now); }
Upload the next code for lighting program:
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" DateTime now; void setup(){ Serial.begin(115200); OpenAquarium.init(); } void loop(){ now =OpenAquarium.getTime(); OpenAquarium.printTime(now); OpenAquarium.lighting(now); }
Features:
You can connect the RGB LED waterproof with the RGB controller in any of the available sockets in the RF power strip.
Actuating:
The RF power strip can be activated with a simple function which must include the code of the plug that we want to actuate.
Example:
{ OpenAquarium.sendPowerStrip(on1); //Turn ON the plug number 1 OpenAquarium.sendPowerStrip(off3); //Turn OFF the plug number 3 }
Upload the next code to turn LED ON at 22:15 and OFF at 23:59
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" DateTime now; //Power strip codes unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); OpenAquarium.init(); OpenAquarium.setTime(); } void loop() { now =OpenAquarium.getTime(); OpenAquarium.printTime(now); if (now.hour() == 22 && now.minute() == 15){ OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.println("RGB ON"); } if (now.hour() == 23 && now.minute() == 59){ OpenAquarium.sendPowerStrip(off1); //Turn OFF plug 1 Serial.println("RGB OFF"); } }
Here is the USB output using the Arduino IDE serial port terminal:
Upload the next code for a full example of Open Aquarium Extra accesories.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" float temperature; DateTime now; //Power strip codes unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); OpenAquarium.init(); } void loop() { now =OpenAquarium.getTime(); OpenAquarium.printTime(now); temperature=OpenAquarium.readtemperature(); Serial.println(temperature); OpenAquarium.lighting(now); OpenAquarium.tempcontrol(temperature); OpenAquarium.waterlevel1(); OpenAquarium.waterlevel2(); if (now.hour() == 8 && now.minute() == 30){ OpenAquarium.feedfish(); } if (now.hour() == 22 && now.minute() == 29){ OpenAquarium.readyforfeeding(); } if (now.hour() == 22 && now.minute() == 30){ OpenAquarium.feedfish(); } if (now.hour() == 12 && now.dayOfWeek()==7){ OpenAquarium.empty(); OpenAquarium.fill(); } OpenAquarium.leak(); if (now.hour() == 22 && now.minute() == 15){ OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.println("RGB ON"); } if (now.hour() == 23 && now.minute() == 59){ OpenAquarium.sendPowerStrip(off1); //Turn OFF plug 1 Serial.println("RGB OFF"); OpenAquarium.newday(); } delay(500); }
Step 1:
Before filling your aquarium, remove plastic protection from LED Strip.
Then glue RGB LED Strip at the bottom of the aquarium wall.
Take out cables and connect it to the RF Power Strip.
Step 2:
Insert rubber hose into the pump.
Step 3:
Insert first pump into your aquarium.
Step 4:
Carry rubber hose to a bucket for empty aquarium water (water changes function).
Step 5:
Repeat same process for the other pump and place it into a bucket.
Step 6:
Carry rubber hose to the aquarium for refill it with clean water.
Step 7:
Places peristaltic pumps togheter near to the bucket with clean water.
Step 8:
Carry rubber hose to the bucket with clean water to drop medicine.
Step 9:
Place water leak sensor arround the aquarium and the buckets.
Stick it straight to the table without too many loops.
Step 10:
Put the LED Lamp on the top of your aquarium.
Adapt it to the lenght of your aquarium with the extendable brackets.
Step 11:
Place the aquarium heater inside of your tank and hang the aquarium fan cooler on the edge of the wall.
Connect them to the RF Power Strip.
NOTE: If you are going to use tempcontrol(temperature) function, you have to connect fan cooler in socket 4 and aquarium heater in socket 5 of the Power Strip.
Step 12:
Finally, power OpenAquarium.
OpenAquarium gateway communicates sending all data to the server to save it by Wi-Fi, GPRS or 3G technology. (see figure 1)
Figure 1. Communication schema
In this server, you should install Apache with PHP module and MySQL database, and configure it. You can see the following tutorial and complete all the instructions to make it possible.
Ubuntu: https://help.ubuntu.com/community/ApacheMySQLPHP
Windows: http://www.ampsoft.net/webdesign-l/how-to-install-apache-php-mysql.html
Mac: http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/
Once finished it, you should create a MySQL database with the following tables to save all sensors data.
CREATE DATABASE IF NOT EXISTS `openaquarium`; USE `openaquarium`; -- -- Table structure for table `measurements` -- DROP TABLE IF EXISTS `measurements`; CREATE TABLE `measurements` ( `_id` int(11) NOT NULL AUTO_INCREMENT, `node_id` int(11) NOT NULL, `sensor_type` varchar(45) NOT NULL, `value` varchar(45) NOT NULL, `date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `unit` varchar(45) NOT NULL, `node_type` varchar(45) NOT NULL, PRIMARY KEY (`_id`), KEY `fk_node_id_idx` (`node_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Table structure for table `actuators` -- DROP TABLE IF EXISTS `actuators`; CREATE TABLE `actuators` ( `_id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(45) DEFAULT NULL, `state` tinyint(4) DEFAULT NULL, PRIMARY KEY (`_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO actuators VALUES (1, 'pump1', 0); INSERT INTO actuators VALUES (2, 'pump2', 0); INSERT INTO actuators VALUES (3, 'peristalticPump1', 0); INSERT INTO actuators VALUES (4, 'peristalticPump2', 0); INSERT INTO actuators VALUES (5, 'peristalticPump3', 0); INSERT INTO actuators VALUES (6, 'socket1', 0); INSERT INTO actuators VALUES (7, 'socket2', 0); INSERT INTO actuators VALUES (8, 'socket3', 0); INSERT INTO actuators VALUES (9, 'socket4', 0); INSERT INTO actuators VALUES (10, 'socket5', 0); INSERT INTO actuators VALUES (11, 'feederFish', 0); INSERT INTO actuators VALUES (12, 'ledLight', 0);
We have released the source code of the web application with an open source license! The idea is you can use it as a "proof of concept" and then modify it and build over it your desired final application. Download here!
To finish the system configuration, you should extract the zip file inside Apache server folder (usually /var/www).
oppenaquarium-app folder
Includes all the files needed to work perfectly the web application.
config.php
Configuration file. This file is very important because here you should set the database parameters, to connect it and make all necessary operations and the user authentication values, used in the web application to make login.
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Diego Becerrica */ //Database connection DB::$user = 'YOUR USER'; DB::$password = 'YOUR PASSWORD'; DB::$dbName = 'YOUR DATABASE NAME'; DB::$host = 'YOUR HOST'; DB::$encoding = 'utf8'; //Web application connection $user_login = "admin"; $user_passw = "3627909a29c31381a071ec27f7c9ca97726182aed29a7ddd2e54353322cfb30abb9e3a6df2ac2c20fe23436311d678564d0c8d305930575f60e2d3d048184d79"; //12345
The first five parameters that begin with DB::, are for establishing the database connection. You should edit it for a correct connection.
DB::$user Database user
DB::$password Database password
DB::$dbName Database name. If you have copied the code of this tutorial, the name is openAquarium.
DB::$host Database host
DB::$encoding Database encoding. The database encoding is utf8.
Finally, the last two parameters, are used for authenticating user in the web application.
$user_login User name for login. By default "admin" but you can change it.
$user_passw Password used in login. This password are encrypted by SHA512. By default "12345" but is highly recommended that you change it. You can use this web to make your own SHA512 password: http://www.convertstring.com/Hash/SHA512
get_actuators.php
File used by the gateway to know how turn on or turn off the different actuators.
meekrodb.2.2.class.php
File used to manage the database.
openaquarium.php
File that centralize all the operations used in web application.
set_sensors.php
File used by the gateway to save the values of all sensors in the database.
stop_feeder.php
File used by the node to stop fish feeder in database.
Please make sure that all these files have the correct permissions (at least read and execute).
We can use the Roving RN-171 or the WiFi PRO module. This module fits in the XBee socket of our Communication Shield and allows to connect your Arduino/RasberryPi shield to a WiFi network.
Example codes for Roving RN-171
This example sends all the sensor data info to a web server
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include <OpenAquarium.h> #include <Wire.h> #define point_1_cond 40000 // Write here your EC calibration value of the solution 1 in µS/cm #define point_1_cal 40 // Write here your EC value measured in resistance with solution 1 #define point_2_cond 10500 // Write here your EC calibration value of the solution 2 in µS/cm #define point_2_cal 120 // Write here your EC value measured in resistance with solution 2 #define calibration_point_4 2221 //Write here your measured value in mV of pH 4 #define calibration_point_7 2104 //Write here your measured value in mV of pH 7 #define calibration_point_10 2031 //Write here your measured value in mV of pH 10 String wifiString; char buffer[20]; int flag = 0; // auxiliar variable DateTime now; String levelstatus1; String levelstatus2; String waterleakstatus; void setup() { Serial.begin(115200); OpenAquarium.init(); //Initialize sensors power OpenAquarium.calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal); OpenAquarium.calibratepH(calibration_point_4,calibration_point_7,calibration_point_10); wificonfig(); } void loop() { now =OpenAquarium.getTime(); OpenAquarium.printTime(now); if ( now.second() == 0 && flag == 0 ){ //Only enter 1 time each hour //Get Gateway Sensors float temperature = OpenAquarium.readtemperature(); float resistanceEC = OpenAquarium.readResistanceEC(); //EC Value in resistance float EC2 = OpenAquarium.ECConversion(resistanceEC); //EC Value in µS/cm int mvpH = OpenAquarium.readpH(); //Value in mV of pH float pH2 = OpenAquarium.pHConversion(mvpH); //Calculate pH value int status1 = OpenAquarium.readwaterlevel(1); if(status1==HIGH){ levelstatus1= "Full"; } else if (status1==LOW){ levelstatus1= "Empty"; } int status2 = OpenAquarium.readwaterlevel(2); if(status2==HIGH){ levelstatus2= "Full"; } else if (status2==LOW){ levelstatus2= "Empty"; } int waterleak = analogRead(3); if (waterleak>1020){ waterleakstatus="No"; } else if (waterleak<=1020){ waterleakstatus="Si"; } //Create string of the floats to send it dtostrf(temperature,2,2,buffer); String temperature_wf = String (buffer); dtostrf(EC2,2,2,buffer); String EC_wf = String (buffer); dtostrf(pH2,2,2,buffer); String pH_wf = String (buffer); /* You must create strings with this structure: "sensor_type:value;sensor_type2:value2;...." Note the ";" between different structures And where sensor_type: 0 - Temperature 1 - EC 2 - pH 3 - Waterlevel1 4 - Waterlevel2 5 - waterleak For example: "0:26.94;1:2300.16;2:7.15;" This means that you send data of the gateway: Temperature=26.94, EC=2300.16 and pH=7.15 */ //Cut data in several string because the wifi module have problems with longer strings wifiString= "0:" + temperature_wf + ";1:" + EC_wf + ";2:" + pH_wf; sendwifi(); enterCMD(); wifiString= "3:" + levelstatus1 + ";4:" + levelstatus2 + ";5:" + waterleakstatus; sendwifi(); enterCMD(); flag = 1; } else if (now.second() == 30 && flag == 1){ flag = 0; } } void check(){ delay(1000); autoflush(); } void wificonfig(){ while (Serial.available()>0){ } enterCMD(); // Sets DHCP and TCP protocol Serial.print(F("set ip dhcp 1\r")); check(); Serial.print(F("set ip protocol 18\r")); check(); // Configures the way to join the network AP, sets the encryption of the // network and joins it Serial.print(F("set wlan join 0\r")); //The auto-join feature is disabled check(); Serial.print(F("set wlan phrase YOUR_PASSWORD\r")); //Insert here the password of the WLAN check(); Serial.print(F("join YOUR_WLAN_NAME\r")); //Insert here the name of the WLAN check(); } void enterCMD(){ Serial.println(""); //To see clearer when debugging // Enters in command mode Serial.print(F("$$$")); delay(100); check(); Serial.flush(); } void sendwifi(){ Serial.print(F("set i h 0\r")); check(); Serial.print(F("set d n 192.168.1.64\r")); check(); //Insert here your IP //Configures HTTP connection Serial.print(F("set i r 80\r")); check(); Serial.print(F("set o f 1\r")); check(); Serial.print(F("set c r GET$/OpenAquarium/set_sensors.php?data=")); Serial.print(wifiString); Serial.print(F("\r")); check(); // Calls open to launch the configured connection. Serial.print(F("open\r")); check(); } void autoflush() { while (Serial.available()>0) { Serial.read(); } }
This example gets all actuators state from a web server
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Copyright (C) Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * a * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascón * Implementation: Marcos Martinez, Luis Martin & Jorge Casanova */ #include <OpenAquarium.h> #include <Wire.h> char recv[512]; int cont; char pump1_wf; char pump2_wf; char peristalticPump1_wf; char peristalticPump2_wf; char peristalticPump3_wf; char socket1_wf; char socket2_wf; char socket3_wf; char socket4_wf; char socket5_wf; char feederFish_wf; char ledLight_wf; unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; void setup() { Serial.begin(115200); OpenAquarium.init(); //Initialize sensors power cleanVector(); wificonfig(); } void loop() { getActuators(); Serial.println(); if (pump1_wf == '0'){ OpenAquarium.pumpOFF(1); //Turn OFF the pump number 1 Serial.print(F("Pump 1: OFF")); } else if (pump1_wf == '1'){ OpenAquarium.pumpON(1); //Turn ON the pump number 1 Serial.print(F("Pump 1: ON")); } else{ Serial.print(F("Pump 1 BAD DATA")); } if (pump2_wf == '0'){ OpenAquarium.pumpOFF(1); //Turn OFF the pump number 2 Serial.print(F("Pump 2: OFF")); } else if (pump2_wf == '1'){ OpenAquarium.pumpON(2); //Turn ON the pump number 2 Serial.print(F("Pump 2: ON")); } else{ Serial.print(F("Pump 2 BAD DATA")); } if (peristalticPump1_wf == '0'){ OpenAquarium.perpumpOFF(1); //Turn OFF the peristaltic pump number 1 Serial.print(F("Peristaltic pump 1: OFF")); } else if (peristalticPump1_wf == '1'){ OpenAquarium.perpumpON(1); //Turn ON the peristaltic pump number 1 Serial.print(F("Peristaltic pump 1: ON")); } else{ Serial.print(F("Peristaltic pump 1 BAD DATA")); } if (peristalticPump2_wf == '0'){ OpenAquarium.perpumpOFF(2); //Turn OFF the peristaltic pump number 2 Serial.print(F("Peristaltic pump 2: OFF")); } else if (peristalticPump2_wf == '1'){ OpenAquarium.perpumpON(2); //Turn ON the peristaltic pump number 2 Serial.print(F("Peristaltic pump 2: ON")); } else{ Serial.print(F("Peristaltic pump 2 BAD DATA")); } if (peristalticPump3_wf == '0'){ OpenAquarium.perpumpOFF(3); //Turn OFF the peristaltic pump number 3 Serial.print(F("Peristaltic pump 3: OFF")); } else if (peristalticPump3_wf == '1'){ OpenAquarium.perpumpON(3); //Turn ON the peristaltic pump number 3 Serial.print(F("Peristaltic pump 3: ON")); } else{ Serial.print(F("Peristaltic pump 3 BAD DATA")); } if (socket1_wf == '0'){ OpenAquarium.sendPowerStrip(off1); //Turn OFF plug 1 Serial.print(F("Socket 1: OFF")); } else if (socket1_wf == '1'){ OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.print(F("Socket 1: ON")); } else{ Serial.print(F("Socket 1 BAD DATA")); } if (socket2_wf == '0'){ OpenAquarium.sendPowerStrip(off2); //Turn OFF plug 2 Serial.print(F("Socket 2: OFF")); } else if (socket2_wf == '1'){ OpenAquarium.sendPowerStrip(on2); //Turn ON plug 2 Serial.print(F("Socket 2: ON")); } else{ Serial.print(F("Socket 2 BAD DATA")); } if (socket3_wf == '0'){ OpenAquarium.sendPowerStrip(off3); //Turn OFF plug 3 Serial.print(F("Socket 3: OFF")); } else if (socket3_wf == '1'){ OpenAquarium.sendPowerStrip(on3); //Turn ON plug 3 Serial.print(F("Socket 3: ON")); } else{ Serial.print(F("Socket 3 BAD DATA")); } if (socket4_wf == '0'){ OpenAquarium.sendPowerStrip(off4); //Turn OFF plug 4 Serial.print(F("Socket 4: OFF")); } else if (socket4_wf == '1'){ OpenAquarium.sendPowerStrip(on4); //Turn ON plug 4 Serial.print(F("Socket 4: ON")); } else{ Serial.print(F("Socket 4 BAD DATA")); } if (socket5_wf == '0'){ OpenAquarium.sendPowerStrip(off5); //Turn OFF plug 5 Serial.print(F("Socket 5: OFF")); } else if (socket5_wf == '1'){ OpenAquarium.sendPowerStrip(on5); //Turn ON plug 5 Serial.print(F("Socket 5: ON")); } else{ Serial.print(F("Socket 5 BAD DATA")); } if (ledLight_wf == '0'){ OpenAquarium.lightOFF(); //Turn OFF plug 5 Serial.print(F("Light: OFF")); } else if (ledLight_wf == '1'){ OpenAquarium.lightON(); //Turn ON plug 5 Serial.print(F("Light: ON")); } else{ Serial.print(F("Led Light BAD DATA")); } if (feederFish_wf == '1'){ OpenAquarium.feedfish(); Serial.print(F("Feeding fish")); enterCMD(); sendfeederstatus(); delay(500); } else if (feederFish_wf == '0'){ OpenAquarium.readyforfeeding(); Serial.print(F("Feeder OFF")); } else{ Serial.print(F("Fish Feeder BAD DATA")); } cleanVector(); enterCMD(); delay(5000); } void cleanVector(){ recv[0] = 0; recv[1] = 0; recv[2] = 0; recv[3] = 0; recv[4] = 0; recv[5] = 0; recv[6] = 0; recv[7] = 0; recv[8] = 0; recv[9] = 0; recv[10] = 0; recv[11] = 0; } void wificonfig(){ while (Serial.available()>0){ } enterCMD(); // Sets DHCP and TCP protocol Serial.print(F("set ip dhcp 1\r")); check(); Serial.print(F("set ip protocol 18\r")); check(); // Configures the way to join the network AP, sets the encryption of the // network and joins it Serial.print(F("set wlan join 0\r")); //The auto-join feature is disabled check(); Serial.print(F("set wlan phrase YOUR_PASSWORD\r")); //Insert here the password of the WLAN check(); Serial.print(F("join YOUR_WLAN_NAME\r")); //Insert here the name of the WLAN check(); } void getActuators(){ Serial.print("set dns name 192.168.1.64\r"); check(); //Insert here your IP //Configures HTTP connection Serial.print("set ip adress 0\r"); check(); Serial.print("set i r 80\r"); check(); Serial.print("set com remote 0\r"); check(); Serial.print("open\r"); check(); Serial.flush(); Serial.print("GET /OpenAquarium/get_actuators.php\r"); checkData(); } void enterCMD(){ Serial.println(""); //To see clearer when debugging // Enters in command mode Serial.print(F("$$$")); delay(100); check(); Serial.flush(); } void check(){ delay(1000); autoflush(); } void checkData(){ cont=0; delay(3000); while (Serial.available()>0) { recv[cont]=Serial.read(); delay(10); cont++; } recv[cont]='\0'; pump1_wf= recv[0]; pump2_wf= recv[1]; peristalticPump1_wf= recv[2]; peristalticPump2_wf= recv[3]; peristalticPump3_wf= recv[4]; socket1_wf= recv[5]; socket2_wf= recv[6]; socket3_wf= recv[7]; socket4_wf= recv[8]; socket5_wf= recv[9]; feederFish_wf= recv[10]; ledLight_wf= recv[11]; //Serial.print("Received:"); //Serial.print(recv); autoflush(); delay(100); } void autoflush() { while (Serial.available()>0) { Serial.read(); } } void sendfeederstatus(){ Serial.print(F(" set i h 0\r")); check(); Serial.print(F("set d n 192.168.1.64\r")); check(); //Insert here your IP //Configures HTTP connection Serial.print(F("set i r 80\r")); check(); Serial.print(F("set o f 1\r")); check(); Serial.print(F("set c r GET$/OpenAquarium/stop_feeder.php\r")); check(); // Calls open to launch the configured connection. Serial.print(F("open\r")); check(); }
Example codes for Roving WiFi PRO
This example sends all the sensor data info to a web server
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Description: Open Aquarium platform for Arduino control several * parameters in order to make a standalone aquarium. Sensors gather * information and correct possible errors with different actuators. * * This example send all the sensor data info to a web server * * Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascon * Implementation: Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" #define point_1_cond 40000 // Write here your EC calibration value of the solution 1 in µS/cm #define point_1_cal 40 // Write here your EC value measured in resistance with solution 1 #define point_2_cond 10500 // Write here your EC calibration value of the solution 2 in µS/cm #define point_2_cal 120 // Write here your EC value measured in resistance with solution 2 #define calibration_point_4 2221 //Write here your measured value in mV of pH 4 #define calibration_point_7 2104 //Write here your measured value in mV of pH 7 #define calibration_point_10 2031 //Write here your measured value in mV of pH 10 String wifiString = ""; char buffer[20]; int flag = 0; // auxiliar variable DateTime myTime; String levelstatus1; String levelstatus2; String waterleakstatus; char aux_str[90]; int8_t answer; char response[300]; //Enter here your data const char server[] = "http://YOUR_SERVER_IP"; const char server_port[] = "YOUR_SERVER_PORT"; const char wifi_ssid[] = "YOUR_WIFI_SSID"; const char wifi_password[] = "YOUR_WIFI_PASSWORD"; const char GET[] = "openaquarium/set_sensors.php?data="; void setup() { Serial.begin(115200); OpenAquarium.init(); //Initialize sensors power OpenAquarium.calibrateEC(point_1_cond,point_1_cal,point_2_cond,point_2_cal); OpenAquarium.calibratepH(calibration_point_4,calibration_point_7,calibration_point_10); wifiString.reserve(1000); wifireset(); wificonfig(); } void loop() { myTime =OpenAquarium.getTime(); OpenAquarium.printTime(myTime); Serial.println(" "); delay(500); if ( myTime.second() == 0 && flag == 0 ){ //Only enter 1 time each minute //Get Gateway Sensors float temperature = OpenAquarium.readtemperature(); float resistanceEC = OpenAquarium.readResistanceEC(); //EC Value in resistance float EC2 = OpenAquarium.ECConversion(resistanceEC); //EC Value in µS/cm int mvpH = OpenAquarium.readpH(); //Value in mV of pH float pH2 = OpenAquarium.pHConversion(mvpH); //Calculate pH value int status1 = OpenAquarium.readwaterlevel(1); if(status1==HIGH){ levelstatus1= "Full"; } else if (status1==LOW){ levelstatus1= "Empty"; } int status2 = OpenAquarium.readwaterlevel(2); if(status2==HIGH){ levelstatus2= "Full"; } else if (status2==LOW){ levelstatus2= "Empty"; } int waterleak = analogRead(3); if (waterleak>1020){ waterleakstatus="No"; } else if (waterleak<=1020){ waterleakstatus="Si"; } //Create string of the floats to send it dtostrf(temperature,2,2,buffer); String temperature_wf = String (buffer); dtostrf(EC2,2,2,buffer); String EC_wf = String (buffer); dtostrf(pH2,2,2,buffer); String pH_wf = String (buffer); /* You must create strings with this structure: "node_id:sensor_type:value;node_id2:sensor_type2:value2;...." Note the ";" between different structures And where sensor_type: 0 - Temperature 1 - EC 2 - pH 3 - Waterlevel1 4 - Waterlevel2 5 - waterleak For example: "0:0:56;0:1:17.54;0:2:56.45" This means that you send data of the gateway: Soil moisture=56, Soil temperature=17.54 and Air humidity=56.45 */ //Cut data in several string because the wifi module have problems with longer strings wifiString= "0:" + temperature_wf + ";1:" + EC_wf + ";2:" + pH_wf; sendGET(); wifiString= "3:" + levelstatus1 + ";4:" + levelstatus2 + ";5:" + waterleakstatus; sendGET(); flag = 1; } else if (myTime.second() == 30 && flag == 1){ flag = 0; } } //********************************************************************* //********************************************************************* void sendGET() { int str_len = wifiString.length() + 1; char char_array[str_len]; wifiString.toCharArray(char_array, str_len); snprintf(aux_str, sizeof(aux_str), "AT+iRLNK:\"%s:%s/%s%s\"\r", server, server_port, GET, char_array); sendCommand(aux_str,"I/OK",20000); } //********************************************** void wifireset() { Serial.println(F("Setting Wifi parameters")); sendCommand("AT+iFD\r","I/OK",2000); delay(1000); sendCommand("AT+iDOWN\r","I/OK",2000); delay(6000); } //********************************************** void wificonfig() { Serial.println(F("Setting Wifi parameters")); sendCommand("AT+iFD\r","I/OK",2000); delay(2000); snprintf(aux_str, sizeof(aux_str), "AT+iWLSI=%s\r", wifi_ssid); answer = sendCommand(aux_str,"I/OK",10000); if (answer == 1){ snprintf(aux_str, sizeof(aux_str), "Joined to \"%s\"", wifi_ssid); Serial.println(aux_str); delay(5000); } else { snprintf(aux_str, sizeof(aux_str), "Error joining to: \"%s\"", wifi_ssid); Serial.println(aux_str); delay(1000); } snprintf(aux_str, sizeof(aux_str), "AT+iWPP0=%s\r", wifi_password); sendCommand(aux_str,"I/OK",20000); delay(1000); if (answer == 1){ snprintf(aux_str, sizeof(aux_str), "Connected to \"%s\"", wifi_ssid); Serial.println(aux_str); delay(5000); } else { snprintf(aux_str, sizeof(aux_str), "Error connecting to: \"%s\"", wifi_ssid); Serial.println(aux_str); delay(1000); } sendCommand("AT+iDOWN\r","I/OK",2000); delay(6000); } //********************************************** int8_t sendCommand(const char* Command, const char* expected_answer, unsigned int timeout){ uint8_t x=0, answer=0; unsigned long previous; memset(response, 0, 300); // Initialize the string delay(100); while( Serial.available() > 0) Serial.read(); // Clean the input buffer Serial.println(Command); // Send Command x = 0; previous = millis(); // this loop waits for the answer do{ if(Serial.available() != 0){ // if there are data in the UART input buffer, reads it and checks for the asnwer response[x] = Serial.read(); x++; // check if the desired answer is in the response of the module if (strstr(response, expected_answer) != NULL) { answer = 1; } } } // Waits for the asnwer with time out while((answer == 0) && ((millis() - previous) < timeout)); return answer; } //**********************************************
This example gets all actuators state from a web server
/* * OpenAquarium sensor platform for Arduino from Cooking-hacks. * * Description: Open Aquarium platform for Arduino control several * parameters in order to make a standalone aquarium. Sensors gather * information and correct possible errors with different actuators. * * This example send all the sensor data info to a web server * * Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * Version: 1.0 * Design: David Gascon * Implementation: Jorge Casanova */ #include "OpenAquarium.h" #include "Wire.h" //Enter here your data const char server[] = "http://YOUR_SERVER_IP"; const char server_port[] = "YOUR_SERVER_PORT"; const char wifi_ssid[] = "YOUR_WIFI_SSID"; const char wifi_password[] = "YOUR_WIFI_PASSWORD"; const char GET[] = "openaquarium/get_actuators.php\r"; const char GETfeeder[] = "openaquarium/stop_feeder.php\r"; char recv[512]; int cont; char pump1_wf; char pump2_wf; char peristalticPump1_wf; char peristalticPump2_wf; char peristalticPump3_wf; char socket1_wf; char socket2_wf; char socket3_wf; char socket4_wf; char socket5_wf; char feederFish_wf; char ledLight_wf; unsigned long on1 = 1597145202; unsigned long off1 = 1597145204; unsigned long on2 = 1597145220; unsigned long off2 = 1597145222; unsigned long on3 = 1597145112; unsigned long off3 = 1597145114; unsigned long on4 = 1597144950; unsigned long off4 = 1597144952; unsigned long on5 = 1597144464; unsigned long off5 = 1597144466; int8_t answer; char response[300]; char aux_str[90]; void setup() { Serial.begin(115200); OpenAquarium.init(); //Initialize sensors power cleanVector(); wifireset(); wificonfig(); } void loop() { getActuators(); Serial.println(); if (pump1_wf == '0'){ OpenAquarium.pumpOFF(1); //Turn OFF the pump number 1 Serial.print(F("Pump 1: OFF ")); } else if (pump1_wf == '1'){ OpenAquarium.pumpON(1); //Turn ON the pump number 1 Serial.print(F("Pump 1: ON ")); } else{ Serial.print(F("Pump 1 BAD DATA ")); } if (pump2_wf == '0'){ OpenAquarium.pumpOFF(1); //Turn OFF the pump number 2 Serial.print(F("Pump 2: OFF ")); } else if (pump2_wf == '1'){ OpenAquarium.pumpON(2); //Turn ON the pump number 2 Serial.print(F("Pump 2: ON ")); } else{ Serial.print(F("Pump 2 BAD DATA ")); } if (peristalticPump1_wf == '0'){ OpenAquarium.perpumpOFF(1); //Turn OFF the peristaltic pump number 1 Serial.print(F("Peristaltic pump 1: OFF ")); } else if (peristalticPump1_wf == '1'){ OpenAquarium.perpumpON(1); //Turn ON the peristaltic pump number 1 Serial.print(F("Peristaltic pump 1: ON ")); } else{ Serial.print(F("Peristaltic pump 1 BAD DATA ")); } if (peristalticPump2_wf == '0'){ OpenAquarium.perpumpOFF(2); //Turn OFF the peristaltic pump number 2 Serial.print(F("Peristaltic pump 2: OFF ")); } else if (peristalticPump2_wf == '1'){ OpenAquarium.perpumpON(2); //Turn ON the peristaltic pump number 2 Serial.print(F("Peristaltic pump 2: ON ")); } else{ Serial.print(F("Peristaltic pump 2 BAD DATA ")); } if (peristalticPump3_wf == '0'){ OpenAquarium.perpumpOFF(3); //Turn OFF the peristaltic pump number 3 Serial.print(F("Peristaltic pump 3: OFF ")); } else if (peristalticPump3_wf == '1'){ OpenAquarium.perpumpON(3); //Turn ON the peristaltic pump number 3 Serial.print(F("Peristaltic pump 3: ON ")); } else{ Serial.print(F("Peristaltic pump 3 BAD DATA ")); } if (socket1_wf == '0'){ OpenAquarium.sendPowerStrip(off1); //Turn OFF plug 1 Serial.print(F("Socket 1: OFF ")); } else if (socket1_wf == '1'){ OpenAquarium.sendPowerStrip(on1); //Turn ON plug 1 Serial.print(F("Socket 1: ON ")); } else{ Serial.print(F("Socket 1 BAD DATA ")); } if (socket2_wf == '0'){ OpenAquarium.sendPowerStrip(off2); //Turn OFF plug 2 Serial.print(F("Socket 2: OFF ")); } else if (socket2_wf == '1'){ OpenAquarium.sendPowerStrip(on2); //Turn ON plug 2 Serial.print(F("Socket 2: ON ")); } else{ Serial.print(F("Socket 2 BAD DATA ")); } if (socket3_wf == '0'){ OpenAquarium.sendPowerStrip(off3); //Turn OFF plug 3 Serial.print(F("Socket 3: OFF ")); } else if (socket3_wf == '1'){ OpenAquarium.sendPowerStrip(on3); //Turn ON plug 3 Serial.print(F("Socket 3: ON ")); } else{ Serial.print(F("Socket 3 BAD DATA ")); } if (socket4_wf == '0'){ OpenAquarium.sendPowerStrip(off4); //Turn OFF plug 4 Serial.print(F("Socket 4: OFF ")); } else if (socket4_wf == '1'){ OpenAquarium.sendPowerStrip(on4); //Turn ON plug 4 Serial.print(F("Socket 4: ON ")); } else{ Serial.print(F("Socket 4 BAD DATA ")); } if (socket5_wf == '0'){ OpenAquarium.sendPowerStrip(off5); //Turn OFF plug 5 Serial.print(F("Socket 5: OFF ")); } else if (socket5_wf == '1'){ OpenAquarium.sendPowerStrip(on5); //Turn ON plug 5 Serial.print(F("Socket 5: ON ")); } else{ Serial.print(F("Socket 5 BAD DATA ")); } if (ledLight_wf == '0'){ OpenAquarium.lightOFF(); //Turn OFF plug 5 Serial.print(F("Light: OFF ")); } else if (ledLight_wf == '1'){ OpenAquarium.lightON(); //Turn ON plug 5 Serial.print(F("Light: ON ")); } else{ Serial.print(F("Led Light BAD DATA ")); } if (feederFish_wf == '1'){ OpenAquarium.feedfish(); Serial.print(F("Feeding fishes ")); sendfeederstatus(); delay(500); } else if (feederFish_wf == '0'){ OpenAquarium.readyforfeeding(); Serial.print(F("Feeder OFF ")); } else{ Serial.print(F("Fish Feeder BAD DATA ")); } cleanVector(); delay(5000); } //********************************************************************* //********************************************************************* void sendfeederstatus(){ snprintf(aux_str, sizeof(aux_str), "AT+iRLNK:\"%s:%s/%s\"\r", server, server_port, GETfeeder); sendCommand(aux_str,"I/OK",5000); delay(100); } //********************************************** void cleanVector(){ recv[0] = 0; recv[1] = 0; recv[2] = 0; recv[3] = 0; recv[4] = 0; recv[5] = 0; recv[6] = 0; recv[7] = 0; recv[8] = 0; recv[9] = 0; recv[10] = 0; recv[11] = 0; } //********************************************** void wifireset() { //Serial.println(F("Setting Wifi parameters")); sendCommand("AT+iFD\r","I/OK",2000); delay(1000); sendCommand("AT+iDOWN\r","I/OK",2000); delay(6000); } //********************************************** void wificonfig() { // Serial.println(F("Setting Wifi parameters")); sendCommand("AT+iFD\r","I/OK",2000); delay(2000); snprintf(aux_str, sizeof(aux_str), "AT+iWLSI=%s\r", wifi_ssid); answer = sendCommand(aux_str,"I/OK",10000); /* if (answer == 1){ snprintf(aux_str, sizeof(aux_str), "Joined to \"%s\"", wifi_ssid); Serial.println(aux_str); delay(5000); } else { snprintf(aux_str, sizeof(aux_str), "Error joining to: \"%s\"", wifi_ssid); Serial.println(aux_str); delay(1000); } */ snprintf(aux_str, sizeof(aux_str), "AT+iWPP0=%s\r", wifi_password); sendCommand(aux_str,"I/OK",20000); delay(1000); /* if (answer == 1){ snprintf(aux_str, sizeof(aux_str), "Connected to \"%s\"", wifi_ssid); Serial.println(aux_str); delay(5000); } else { snprintf(aux_str, sizeof(aux_str), "Error connecting to: \"%s\"", wifi_ssid); Serial.println(aux_str); delay(1000); } */ sendCommand("AT+iDOWN\r","I/OK",2000); delay(6000); } //********************************************** void getActuators(){ Serial.println(F(" ")); snprintf(aux_str, sizeof(aux_str), "AT+iRLNK:\"%s:%s/%s\"\r", server, server_port, GET); sendCommand(aux_str,"I/OK",10000); delay(100); checkData(); } //********************************************** void checkData(){ cont=0; delay(3000); while (Serial.available()>0) { recv[cont]=Serial.read(); delay(10); cont++; } recv[cont]='\0'; pump1_wf= recv[8]; pump2_wf= recv[9]; peristalticPump1_wf= recv[10]; peristalticPump2_wf= recv[11]; peristalticPump3_wf= recv[12]; socket1_wf= recv[13]; socket2_wf= recv[14]; socket3_wf= recv[15]; socket4_wf= recv[16]; socket5_wf= recv[17]; feederFish_wf= recv[18]; ledLight_wf= recv[19]; //Serial.print("Received:"); //Serial.print(recv); delay(100); } //********************************************** int8_t sendCommand(const char* Command, const char* expected_answer, unsigned int timeout){ uint8_t x=0, answer=0; unsigned long previous; memset(response, 0, 300); // Initialize the string delay(100); while( Serial.available() > 0) Serial.read(); // Clean the input buffer Serial.println(Command); // Send Command x = 0; previous = millis(); // this loop waits for the answer do{ if(Serial.available() != 0){ // if there are data in the UART input buffer, reads it and checks for the asnwer response[x] = Serial.read(); x++; // check if the desired answer is in the response of the module if (strstr(response, expected_answer) != NULL) { answer = 1; } } } // Waits for the asnwer with time out while((answer == 0) && ((millis() - previous) < timeout)); return answer; } //**********************************************
Open Aquarium includes an application to visualize real data of all your sensors in a web browser. If you have followed correctly all the previous section, you will be able to connect to this URL.
http://your-ip/openaquarium-app
and see this screen where you can fill user and password credentials to login.
In user field you should type the user name that you have written in config.php file, and then in password fields, your own password without encryption. Once completed, you should click to connect button at the bottom of the form and you arrive to the main screen when you can see all sensor values.
Finally, in the menu, you can click in actuators option to see all actuators states.
You can access to the web application from iPhone or Android devices, using a mobile web browser and typing the URL of your server in it.
There is a forum available in which you can get support for Open Aquarium.
NOTE: Due to the constant evolution of the product pictures shown may vary from actual product. Product specifications subject to change without notice.
Basic Kits
Aquaponics Kit
Extra accesories
If you are interested in Internet of Things (IoT) or M2M projects check our open source sensor platform Waspmote which counts with more than 100 sensors available to use 'off the shelf', a complete API with hundreds of ready to use codes and a low consumption mode of just 0.7µA to ensure years of battery life.
Know more at:
Get the Starter Kits at: