In this project i'll show u how can we build a cool very cheap Aquaponic system from recycled materials. this aquaponic system will contain a planter for growing fresh food without fertilizers, a fish tank to grow healthy fish.
How It Worksfish would eat food then fish wastes would be transferred using water pump to fertilize plants in the planter after that the water will be filtered and cleaned then return again to the fish tank. this cycle would save water and grow up fish and plants with no costs.
Step 1: Building the Body "Recycling Old Pallet Wood"Building bell syphon to drain water.
Connect the Pump (Plant Watering System)
Building the Feeder
For feeder, I used DC motor and fixed a screw on its shaft so when it rotates, it rotate the screw and make fish food fall in the fish tank.
Test the rock to check if it can be used as media or not.
Testing aquaponic system:
Testing the feeder mechanism:
Step 2: Connecting Sensors and Actuators to NetduinoWe need almost all the pins on the Netduino board to complete this project.
Required sensors and actuators:
- Ultrasonic
- LDR
- DHT11
- LM35 temp sensor
- Soil moisture sensor
- 4-channel relay module
- 3 MOSFET transistors
Follow Netduino pinouts and schematic below to correctly wire eveything.
This is the schematic for wiring everything.
Testing the Connection
// Image Live ConnectedStep 3: Coding with Visual Studio for Mac- Download and Install the Development Tools
Download and install the latest version of Visual Studio for Mac.
Launch Visual Studio and click Extensions... on the menu bar. This should open the Extension Manager window. Select the Gallery Tab, type MicroFramework in the search box and you should see one result. If no results are found, ensure you are searching All Repositories and press the Refresh button.
If you don't have it installed, click install. Once installed, go the the Installed tab, and ensure the extension is listed and enabled.
You can either use the code provided below or create a new solution and add the required libraries as follows :
Choose MicroFramework Console Application:
Then set the project name and location:
Then click Create.
Edit references and add these references in selected references:
How the code should work:
The Netduino board should send sensor readings (temperature, humidity, sun light brightness....) to Firebase and receive actuator (red, blue, green of LED strip, pump state, feeder state, and heater state) values from it to make action (switch relay on or off).
The mobile application change the actuator values and read sensors values.
Code Explanation
- Main function
//ultrasonic Sensor
HC_SR04.HC_SR04 sensor = new HC_SR04.HC_SR04(Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7);
//Digital Input
var dhtSensor = new Dht11Sensor(Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D0, PullUpResistor.Internal);
Debug.Print("DHT sensor Read() ok, Humidity = " + dhtSensor.Humidity.ToString("F1") + "%, Temp = " + dhtSensor.Temperature.ToString("F1") + "°C");
//LDR
AnalogInput ldr = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);
feeder = new OutputPort(Pins.GPIO_PIN_D1, false);
heater = new OutputPort(Pins.GPIO_PIN_D2, false);
pump = new OutputPort(Pins.GPIO_PIN_D3, false);
feeder.Write(true);
heater.Write(true);
pump.Write(true);
// OutputPort relay = new OutputPort(Cpu.Pin.GPIO_Pin1,false);
//AnalogueRead Humdity
AnalogInput Humdity = new AnalogInput(Cpu.AnalogChannel.ANALOG_0);
//LM35
Debug.Print("Read TMP36");
var tmp36 = new AnalogTemperature(AnalogChannels.ANALOG_PIN_A2,
AnalogTemperature.KnownSensorType.LM35,
updateInterval: 0);
r_channel = new PWM(PWMChannels.PWM_PIN_D9, 100, 0, false);
b_channel = new PWM(PWMChannels.PWM_PIN_D10, 100, 0, false);
g_channel = new PWM(PWMChannels.PWM_PIN_D11, 100, 0, false);
r_channel.Start();
b_channel.Start();
g_channel.Start();
Program.r_channel.DutyCycle = 1;
Program.g_channel.DutyCycle = 1;
Program.b_channel.DutyCycle = 1;
In the first part of the main function we setup up our sensors (ultrasonic Sensor, DHT11, Relays, Lm35 Temperature sensor, 3 Mosfet transistors controlling the RGB Channels in the LED Strip ) with the pins as the scheme provided belowthen
Hashtable hashtable = new Hashtable();
//
hashtable.Add("airhumidity", dhtSensor.Humidity.ToString("F2"));
hashtable.Add("light", ldr_value.ToString("f2"));
hashtable.Add("Water Temp", tmp36.Temperature.ToString("f2"));
hashtable.Add("waterlevel", cm.ToString("f2"));
hashtable.Add("airtemp", dhtSensor.Temperature.ToString("F2"));
hashtable.Add("soilmoisture", Humdity.Read().ToString("f2"));
string json = JsonSerializer.SerializeObject(hashtable);
try
{
App.getdata();
}
catch (Exception e)
{
Debug.Print("error " + e.Message + " " + e.StackTrace);
Debug.Print("error " + e.Message + " " + e.StackTrace);
throw new ApplicationException("network errpr " + e.Message.ToString());
}
App.send(json);
//}
}
The code then debug the sensors value and connect to the network then after checking the network is up the app calls 2 functions are the core of our app
- App.getdata(); this function get the data from Firebase Realtime Database
And based on it it changes the relays and RGB according to the firebase data,
For the relays it turn on the pump motor or feeder motor or the heater for some time then turn them off and change the state on firebase we don't want to feed the fish all the food we have at once all pump all tank water to the plant above... here in the code for demo we set these values to 500 ms or 1/2 a sec only
public static void getdata()
{
string res = MakeWebRequest("https://aquaponicsystem-9e0ec.firebaseio.com/.json", "GET");
Debug.Print("received");
var hashtable = JsonSerializer.DeserializeString(res) as Hashtable;
string r = (hashtable["red"].ToString());
string b = (hashtable["blue"].ToString());
string g = (hashtable["green"].ToString());
int feederstate = Int32.Parse(hashtable["feederstate"].ToString());
int pumpstate = Int32.Parse(hashtable["pumpstate"].ToString());
int heaterstate = Int32.Parse(hashtable["heaterstate"].ToString());
if (feederstate==1) // first pin
{
//relay on for 5 sec
//relay off
// send 0 to firebase
Program.feeder.Write(false);
Thread.Sleep(500);
Hashtable data = new Hashtable();
data.Add("feederstate", 0);
string json = JsonSerializer.SerializeObject(data);
App.send(json);
Program.feeder.Write(true);
}
if (pumpstate==1) // third pin in relay
{
Program.pump.Write(false);
Thread.Sleep(500);
Hashtable data = new Hashtable();
data.Add("pumpstate", 0);
string json = JsonSerializer.SerializeObject(data);
App.send(json);
Program.pump.Write(true);
}
if (heaterstate==1) // second
{
Program.heater.Write(false);
Thread.Sleep(500);
Hashtable data = new Hashtable();
data.Add("heaterstate", 0);
string json = JsonSerializer.SerializeObject(data);
App.send(json);
Program.heater.Write(true);
}
Program.r_channel.DutyCycle = ((System.Convert.ToDouble(r) / 255.0)); // * .3/255
Program.g_channel.DutyCycle = ((System.Convert.ToDouble(g) / 255.0));
Program.b_channel.DutyCycle = ((System.Convert.ToDouble(b) / 255.0));
Debug.Print(r.ToString());
Debug.Print(g.ToString());
Debug.Print(b.ToString());
}
- App.send(json);
- This function simply send the data to the Firebase in form of JSON
var request = (HttpWebRequest)WebRequest.Create("https://aquaponicsystem-9e0ec.firebaseio.com/.json");
request.Method = "PATCH";
request.ContentType = "application/json";
request.KeepAlive = false;
var buffer = Encoding.UTF8.GetBytes(json);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
var response = request.GetResponse();
json = (new StreamReader(response.GetResponseStream())).ReadToEnd();
Debug.Print("Data Successfullty Sent :");
Debug.Print(json);
response.Close();
//screenshot logging dataStep 4: Unity App Developmenthttps://forum.easyar.com/portal.php?mod=view&aid=11
Simply follow this link to know how to set up AR mode. NOTE: Package name on EasyAr cloud should be same as package name on Unity app and Firebase package name, or it would show invalid key error !
Step 6: You Can Find Full Unity Project HereZip folder containing full Unity project + image target for AR:
https://drive.google.com/open?id=1-i5zR6BjpS2PxWVLspfQ4aYxVdNYoEZ3
Apk application connected to my Firebase account:
https://drive.google.com/open?id=1x5eVqVIayUtiL03tw0zdbLhaxm1C3IDl
Step 7: Demo of the Final Project RunningFinal Demo: 2D, Ar with Android app
Comments