Introduction: V2 Controller - Smart Aquaponics
The doctor recommends we have at least 7 helpings of fresh fruit or vegetables every day.
Step 1: The Water Cycle
The Sun's energy powers the water cycle in which surface waters on the Earth evaporate into clouds, falling as rain and returning back to the Ocean as rivers. Bacteria and other living organisms break down waste from the ocean and land to create nutrients for plants in the nitrogen cycle. Oxygen cycles, iron cycles, sulfur cycles, mitosis circles and other cycles evolved with time.
Step 2: Mimicry
Circular systems are inherently sustainable. If such a system can produce majestic Redwood forests, then such a system seems like a good idea for my garden. Mimicking we functionally recreate an ocean, the earth and a water cycle using pumps. Microorganism colonizes start the nitrogen cycle and other cycles kick in as the system matures.
Step 3: Human Cycles
Then humans came to the cycle and their love for everything changed the environment. Humans affect the model in a similar way, fish are overfed with love.
Step 4: Smart Gardending
Nature seems to do better with fewer interactions with humans, humans seem to need that interactivity with nature. It seems like a problem suited for automated and connected technologies. So electronic circuits and boolean algebra were a natural fit.
Step 5: Building an Aquaponics Garden
Building a sustainable garden begins with sustainable design, sustainable materials and sustainable processes. This means reducing our plastic footprint. In this design, the wooden legs and frame beams come straight from a tree, that hurts.
Step 6: Garden Materials List
Of course, there is a price to pay for the vertical grain wood you don't have to incur.
Step 7: Pond Sheilding Your Garden
There are numerous possibilities for waterproofing grow beds. I like upcycled materials and engineered lumber with plywood being a favorite as it is made from veneer. In this instructables, we use Pond Shield which is a fish safe epoxy resin.
Apply sparkle on the edges and any rough surfaces, sand the sparkle smooth. vacuum or brush all the dust particles away. Cut the fibreglass sheets into strips of 2″ wide, long enough to go around every edge inside the grow bed. Get your fiberglassing station together. Mix 1 cup paint, 1/2 cup hardener, 2/3 cup of denatured alcohol is shown
Mix slowly using a drill paint mixer attachment for less than 2 minutes in reverse. Using a roller (pour a little at a time) paint the corners, attach the fibreglass then paint over the fibreglass. The idea is to saturate the fibreglass so there are no air pockets. Paint the rest of the grow bed when you are finished with the fibreglass.
Let it dry then lightly sand it than 4 hours to dry, then apply another liquid rubber paint coat. The dark green images are after the application of 3 coats.
Step 8: Irrigation and Drainage
The irrigation tubing is made from 1/2" PVC with holes drilled underneath every 6". The standpipe and drainage tubing is larger at 1". A 1" bulkhead kit is used as a coupling. We want to keep the top of the bed dry so the standpipe is 2" below the top of the grow bed.
Step 9: Modeling
Modelling the behaviour or structure of the water cycle is not as easy as these are enormous systems with numerous variables. The conceptual models we build are abstracted to hide complex details.
In deciding which sensors to use, a good question may be, what are the most basic components in the water cycle - a large body of water, land, energy to lift water to the land, media that saturates to runoff and gravity for water to return to the source. This establishes a basic level of data collection required in such a garden as these are the important processes that need monitoring.
Another good question may be what are the basic components of the nitrogen cycles.
Step 10: The Basic Aquaponics Sensor Set
The basic sensor set can be extended and is used to monitor and visualize the water cycle and environmental conditions.
Flowrate Sensor -a Hall effect sensor used to measure the movement of water from the tank. This also monitors pump for catastrophic failure or degradation. It is also used to monitors the irrigation lines for blockages
1-wire temperature - used to measure the water temperature in the fish tank, ambient or media temperatures
IR distance sensor - an analogue sensor that works by bouncing IR signals to an object. It is used to measure the depth of water in the grow bed. It is also used to monitors the grow bed flood and drain cycles.
Photocell sensor - an analogue based sensor whose resistance varies with the light intensity. It is used to measures levels from indoor lighting or natural lighting
Liquid sensor - is a resistive analogue sensor used to monitor for water loses through leaks.
Flow switch - is a digital sensor based on a magnetic reed switch. It used to monitor the grow bed drainage.
Float switch - is a digital sensor based on a magnetic reed On/Off switch. It is used to ensure that the fish tank water level is always sufficient.
Step 11: Linux Serial Console Inputs
The keyboard and mouse are connected to the serial console on a Linux computer to allower users to communicate with the Linux kernel and applications even on a low level.
Instead of a keyboard and mouse, we connected a microcontroller to the serial console input of the linux microcomputer on the v2 controller board.
This allows passing of sensors and actuator data between the outside world and the Linux microcontroller applications seamlessly without the need for any special Linux drivers or configurations.
The console input in a Linux computer is the serial interface used by the keyboard/mouse for data entry by a human user. The results are then normally displayed on a computer monitor screen.
Step 12: The V2 Controller Serial Interface
The v2 controller is a Linux based computer board with a microcontroller connected to the serial console input instead of the traditional keyboard. This means it can take readings from sensors directly. The output stage has various hardware drivers for a computer monitor.
Step 13: The V2 Controller Overview
The v2 controller is an embedded Linux computer that has an Atmega 2560 microcontroller connected to the serial console input. This means it can accept data in a similar way to users typing on the keyboard, only the data comes from an Arduino Mega.
The information is then processed with similar tools to data entered by a user on a keyboard. Rather than a monitor screen, the output stage of the v2 controller has open collector transistors for relays and drivers for other actuators.
The v2 controller comes preloaded with all the software required to use any of its onboard hardware components. The v2 controller further has a backend platform and API that allows access to all hardware components remotely as well as data logging, visualization, alerting and other processing tools.
In short, the v2 controller board is the physical interface to a powerful easy to use full-stack IoT platform for any physical application
Step 14: The V2 Controller Board
.it was a long journey to designing and building these boards. I can share the experience in a later instructable. There is more information here
Step 15: V2 Controller PinOut
Step 16: V2 Controller Specifications
Step 17: V2 Controller Platform Tools
Step 18: V2 Controller Block Diagram
Step 19: Connecting Analogue Sensors to the V2 Controller
Analogue sensors generally have a signal pin, a ground pin and occasionally a third power pin. The v2 controller will interface analogue sensors without any extra hardware.
Connect the analogue signal pin to any free analogue pin on the board and connect the respective power lines.
If a potential divider resistor is required, you can use an internal software pull-up one or you can switch the precision onboard one by flicking the respective dip switch.
Step 20: Connecting Digital Sensors to the V2 Controller
Connect the digital sensor line to the any respective digital pin on the board and the power pins.
if it is required, activate the software pull-up resistor for the digital sensor
Step 21: Connecting 1-Wire Sensors to the V2 Controller
Some sensors have microcontrollers that computer conditions are return values in as a stream of bits. 1-wire sensors are typical sensors. The v2 controller has various onboard circuitry for such devices.
To connect say a 1-wire temperature sensor, connect the data signal line to any of the digitals lines with a 4k7
parasitic resistor, and connect the power signals. Flick the 4k7 resistor to the ON position
Step 22: Connecting Garden Sensors to the V2 Controller
Step 23: Connecting the 8 Basic Sensors to the V2 Controller
Step 24: Connecting the Sensors to the Garden
Typical sensor locations are shown.
Step 25: Connected Garden Overview
The 2560 Atmega microcontroller runs the first and only Arduino sketch I have ever written. It polls the input pins continuously for raw values and sends these as a JSON string to the serial output.
Step 26: Serial Raw Sensor Values
Serial strings with raw pin readings sent from the microcontroller to the microcomputer are shown
Step 27: Serialized JSON String
A python script on OpenWrt serializes the sensor strings into a JSON object, appends extra elements and sends the data over the network to the API
Step 28: Connecting to the V2 Controller
- Using ethernet, connect the v2 controller to your computer
- Use a USB to ethernet adapter if required
- Power the v2 controller using a 9vdc supply
- Your computer will be assigned an automatic IP address 192.168.73.x by the v2 controller if it is enabled for automatic IP configuration (DHCP Enabled)
Step 29: Garden API Topology
The garden data is sent to the v2 API for logging, analysis, visualization, alerting and remote control.
Step 30: Accessing Data Remotely Using the Api
An HTTP rest call to the api with proper credentials will return the latest data as shown below
curl https://api.kijanigrows.com/v2/device/get/kj_v2_01
{
"baudRate": 38400,
"name": "kj_v2_01", "uptime": "1:24:10.140000", "pins": { "D38": 0, "D39": 0, "D36": 0, "D37": 0,, "D33": 0, "D30": 0, "D31": 0, "A15": 422, "A14": 468, "A11": 624, "A10": 743, "A13": 475, "A12": 527, "relay8": 0, "UART3": 0, "A1": 933, "A0": 1023, "A3": 1022, "A2": 1023 "A9": 1023, "A8": 348, "D29": 0, "D28": 0, "nutrientTemp": 22.44, "D23": 1, "D22": 0, }, "version": "v2.0.0", "wlan0": "192.168.1.2", "initialize": 0, "atmegaUptime": "00:00:34:52", "timestamp": 1473632348121, "day": 1472256000000, "time": "2016-09-11T22:19:08.121Z", "_id": "57d5d85cd065ea4654009fce" }
Step 31: Login Into the Admin Interface
- Point your browser to http://192.168.73.1
- Username : root
- Password: tempV2pwd (or whatever it was changed to)
Step 32: Confure New Device Name
- On the System menu bar, click on 'System' from the dropdown list
- Type in the new device name in the Hostname field
- Click 'Save & Apply'
- Depress the power switch Off/On new hostname take effect.
Step 33: Configuring Wifi on the V2 Controller
- Select the Wifi option from the 'Network' menu
- On the Wifi menu click on the 'Scan' button
Step 34: Selecting Wifi Network
Select your wifi network from the list using the 'Join Network' button
Step 35: Logging Into WIFI Network
- Enter the security credentials for your network
- Select 'Submit' The status wireless icon should turn blue and indicate the strength of the connection
- Click on 'Save & Apply' to complete the Wifi configuration
Step 36: Searching for Your Device
If your network connection was established successfully, your device should automatically start sending data to the remote API at https://api.kijanigrows.com/v2/devices/list
Search for your device name in the list. If it is missing, confirm your hostname and WIFI network configuration in the admin status interface.
Step 37: Account and Device Registration
Sign up for an account here https://api.kijanigrows.com/
Send your username and device name to device@kijanigrows.com
Log in after you get an email confirming your device was assigned to you.
Step 38: Mapping Device Sensors
Normally micro-controller hardware looks complicated because even the simplest sensor requires electronic interface circuits - breadboard, shields, hats, caps etc.
Software tends to appear complicated as it usually does too much - interface sensor signals, interpret the data, present readable values, make decisions, take actions etc.
For example, connecting a thermistor (temperature dependent resistor) to an analogue pin usually requires a potential divider circuit with a pullup resistor tied to Vcc. A program to display this value in Celsius will take some non-English lines of code. The hardware and software will look complicated with 8 sensors. Changing the pins or adding new sensors will require new firmware. This gets further complicated if everything has to work remotely.
The v2 controller has onboard circuitry to interface almost any sensor without external components. The firmware on the v2 controller polls all the input pins and returns raw values. The raw values are securely sent to the API where they are mapped to the respective sensors for visualization, analysis, remote control and alerting.
The mapping is done by the kj2arduino library which allows seamless interchange of sensors or pins on the v2 controller board without new software or hardware. You select your pin name and the sensor connected to the garden (or physical application) as shown in the image.
Step 39: Mapped Sensor Details
After a sensor is mapped, it's details and metadata can be accessed by clicking on the sensor type.
Here the sensor type, units, setpoints, messages, icons, notifications and the conversion code can be specified for the sensor. The conversion code (eg. ldr2lumens shown) is a function call to kj2arduino library. It converts the raw sensor values sent to humanly readable data for presentation.
Step 40: Mapped Sensor Icons
The mapped sensor values are shown as dynamic Icons on the Device Sensor tab option.
The Icons will change based on values configured in the device's sensor details interface
Step 41: Garden Animation
The sensor values can also be seen as a dynamic garden animation on the Garden Animation tab. Colors and shapes will change based on sensor setpoint values.
Step 42: Trending
The device sensor data can also be visualized as graphs for treading.
Step 43: Twitter Sensor Alerts
Alerts are sent based on device, sensor details and setpoint values.
Step 44: Smart Controller Components
Most of the components are easily available from eBay or Amazon and most variations. The v2 controller comes with all the software preinstalled. You can get the v2 controller from me at Kijani Grows. If you use a flow switch, get one with a low flow rate to avoid backflows.
Step 45: Connecting Mains Voltage Loads
This stage is optional and only necessary if you want to control your garden autonomously or remotely.
Dangerous High Electric Voltages Involved. Follow the instructions at your own risk
Break the live or neutral connection from the power cable. Tin this using a soldering iron. Connect the two ends of the power cable to the relays Normally Open (NO) connection. Connect the load to be powered on one end of the power cable and the other insert into a mains outlet as shown below. Power the open collector transistor to turn on the load via the relay. Repeat for the other switched mains output
The IO pins go to the Linux connector J19 on the v2 controller:
- Vcc - Vcc
- Gnd - Gnd
- IO20 - Relay 1
- IO19 - Relay 2
- IO18 - Relay 3
- IO22 - Relay 4
For the pump, reservoir pump, lights and feeder respectively. (it really does not matter everything is software mapped)
Step 46: An Enclosure
Using a pencil, a Dremel tool and a drill I cut everything to fit into the enclosures.
You can get this as the kit Jimmy to make your life easier.
Step 47: Starting the Smart Garden
The controller will work with any garden.
If you build one like mine, all you need is filter media in the grow bed and fish safe water in the tank. Most hydroponic media will work great, for the indoor garden I use lightweight expanded clay.
Connect the pump, indoor lighting, power cable. Depress the power button, stand back ... enjoy - let the v2 controller become part of your ecosystem.
When everything seems ok, add your fish. I have about 12 goldfish in my tank. I suggest getting a fish tank water quality test kit to monitor the garden as it cycles biologically.
I grow microgreens and sprouts by broadcasting them over the clay media. Generally, my rule with plants I grow is I better be able to start eating them within the week or they better have some medicinal properties.
Step 48: Doctor Recommends 7 Helpings of Fresh Fruit or Vegetables
.. the ones from my smart garden are my favorite ones ...
Step 49: Smart Garden Live Links
Here are some live links to my office garden and others. Refresh if nothing loads at first. Be kind.
trends - https://api.kijanigrows.com/app/#/trends/RedVic/
icons - https://api.kijanigrows.com/app/#/device_sensors/R...
animation - https://api.kijanigrows.com/app/#/animation/RedVi...
alerting - https://twitter.com/kijanigrows_tst
video - http://kijani.ddns.net:8084/javascript_simple.htm...
the v2 controller also supports video for timelapse streams
see also, ndovu, themurphy (the camera above), stupidsChickenCoop, ecovillage and the others with public access.