Sony Arouje Blog

a programmer's log

Raspberry Pi controlled Aeroponic System V2

leave a comment »

Last one and half months I was working on my Aeroponic System V2. In this post I will dissect the system and will see each component and what it does. I would like to thank my wife for her tremendous support for helping me in every phase of the development, also she takes care of the germination process and replanting to the system.

Working of the Aeroponic system (video)

Aeroponic system in action

Vertical Growing Medium

2015_03_15_11_01_19_ProShot

Here the plants root are growing in Air and the nutrient mixed water will flow through the pipe in periodic intervals. As of now we are growing Spinach and Amaranth.

Irrigation pipes

2015_03_15_11_01_29_ProShot

I fixed a valve to control the water flow. Without this valve the first outlet receives more water because of gravitation and subsequent outlet receives less and the last one receives none. With this valve I can adjust the water flow and helps to get water to each outlet equally.

Reservoir

2015_03_15_11_04_55_ProShot

Normal hydroponic systems use water tanks to hold the nutrient mixed water. I decided to buy one tank as well but the tank is 1 feet tall, that means the vertical growing medium must be place above the tank level and I will loose 1.5 feet from each growing medium. I have total 6 towers and in total I will loose 9 feet of growing medium and will reduce around 30 cups.

After a lot of thoughts I come up an idea to use 6 inch pipe as the reservoir. With simple math I realize that I could store more than 50 lts of water in a 10 feet 6” pipe.

The reservoir has a Submersible pump that can pump 12000 liters per hour. It also have a wave maker to mix Nutrients or pH modifier agents.

Nutrient Feeder

2015_03_15_11_04_39_ProShot

I made two containers from a 4 inch PVC pipe and connect two dosage pumps to pump nutrient from Nutrient tank to Reservoir.

I can add Nutrients by pressing a push button in the control board or via the mobile app. For each press of Push button will add 10 ml of nutrients. Through mobile I can add any amount of Nutrients and can do it from any where from the world.

Controller system will automatically activate the wave maker after adding nutrients, so the nutrients will get mixed well.

 

Controller System

2015_03_15_11_03_29_ProShot

 

The controller system has different components, I numbered each component for ease of explanation.

1. Water Pump switch: Water pump will run in a periodic interval controlled by application running in Rasbperry pi. In some situation I wanted to run the pump immediately without waiting for the interval. With this switch I could run the motor immediately. I can also activate pump from my mobile application as well.

2. Wave Maker switch:  As I said earlier the reservoir is equipped with Wave maker to mix Nutrients or pH modifiers. I could activate Wave maker any time by pressing the push button. I used this mostly after adding pH modifiers. Nutrient feeding system will automatically switch on Wave maker after adding nutrients.

3. Nutrients Feeder switch: This push button switch will add 10 ml of nutrients to the reservoir. If I wanted to add more nutrients I could do that via the mobile application.

4. Raspberry pi: The brain of my Aeroponic system. Each and every component is connected to this device. The controller program is written in Node js.

5. Relays: component to switch on/off each hardware like Water pump, Wave maker, etc.

The system is powered with a 12v DC and 240v AC. Each power source can be switched off separately by the two buttons below the Raspberry pi.

Written by Sony Arouje

March 15, 2015 at 7:59 pm

Hydroponic controller system controlled by Raspberry Pi

leave a comment »

In one of my previous post I explained the working of my Aeroponic system. As I mentioned earlier, I wanted to automate one of the recurring task. Yes, adding nutrients. Also I created an Aeroponic system with multiple pillars, I will post another video of my new aeroponics later.

Last week-end I was working on the controller system for my new Aeroponic system. The new system includes the controller system to add nutrients to the reservoir. The system includes two peristaltic pump and a wave maker to mix the nutrient. I can add nutrients via the mobile app I created or by pressing the red button on the board. From mobile device I can specify how much milliliter of nutrients I wanted to add. By Pressing the button I can add a predefined quantity, say 10 ml for each button press.

 

fotor_(344)

 

I will post more updates soon…

Written by Sony Arouje

February 11, 2015 at 10:05 pm

Connecting XBee to Raspberry pi

leave a comment »

Last one week I was doing some research in RF communication and controlling devices using RF. So what am I going to control here, I wanted to control the water pump running in my hydroponic reservoir without running wires from my raspberry pi. This way I can extend my hydroponic system to more balconies without buying extra RPi, a single RPi will send a switch on/off command and the RF client will switch on/off the motor via a relay. Also I don’t need to setup a wifi network in my controller RPi’s.

My research for RF communication platform leads to Zigbee protocol and XBee component. XBee is a very popular Zigbee complaint product from Digi. For my testing I got two XBee Pro S2 and two XBee explorer. The explorer I bought uses USB to A/B cable, if you are buying it make sure buy A/B cable as well. You will get micro usb explorer as well.

To configure the XBee’s I use the X-CTU software from Digi, you can download it free from Digi’s website. I use the Legacy X-CTU for configuring my modules and Next Generation X-CTU for issuing commands. Configuration is pretty simple and so many sites will walk you through it. I configure my XBee’s as shown below. One XBee act as Coordinator and enabled API mode and another XBee act as router and enabled Router AT.

XBee Coordinator

  • Modem: XBP24-ZB
  • Function Set: ZIGBEE CORDINATOR API
  • PAN: <set a pan id, say 123>
  • Destination Address Low: FFFF

XBee Router

  • Modem: XBP24-ZB
  • Function Set: ZIGBEE ROUTER AT
  • PAN: <set a pan id, say 123>
  • Destination Address Low: 0000

I left all other settings as default.

Connecting to Raspberry pi

For testing I connected the XBee coordinator to my computer and XBee Router to my RPi. In RPi I created a simple node app to send some text message to coordinator. Below diagram will show you, how I connected Router XBee to my RPi. Here we use serial communication between RPi and XBee. RPi has only one set of serial communication pin and by default it’s configured for console I/O, there are so many tutorial out there to free it up and I use one from them.

connection_diagram_bb

image developed using Fritzing

I connected the XBee directly using jumper wires, the above diagram is just for illustration for that I use the breadboard.

Connect RPi 3.3 volt to XBee 3.3 volt pin, Ground to XBee ground, Rx to Xbee Tx (Data Out), Tx to XBee Rx (Data In).

Sending some data from Router Xbee to Coordinator

Now I wanted to send some data from Router XBee connected to my RPi  to the coordinator connected to my Computer.

I created a small app using node js, below is the code. To run the code we have to install two node modules.

  • xbee-api: npm install xbee-api
  • serialport: npm install serialport
var util = require('util');
var SerialPort = require('serialport').SerialPort;
var xbee_api = require('xbee-api');

var C = xbee_api.constants;

var xbeeAPI = new xbee_api.XBeeAPI({
    api_mode: 1
});

var serialport = new SerialPort("/dev/ttyAMA0", {
    baudrate: 9600,
    parser: xbeeAPI.rawParser()
});

serialport.on("open", function () {
    var frame_obj = {
        type: 0x10, 
        id: 0x01, 
        destination64: "0013A200407A25A7",
        broadcastRadius: 0x00,
        options: 0x00, 
        data: "Hello world" 
    };
    
    serialport.write(xbeeAPI.buildFrame(frame_obj));
    console.log('Sent to serial port.');
});

serialport.on('data', function (data) {
    console.log('data received: ' + data);
});


// All frames parsed by the XBee will be emitted here
xbeeAPI.on("frame_object", function (frame) {
    console.log(">>", frame);
});

 

When I run the above node app, I can see the data receiving in my Coordinator’s X-CTU app. I could also send a Remote AT (0x17) command to the router to one of the Digital pin and could turn On/Off a LED.

Seems like the communication is working fine. Let’s see what I can come up next.

 

download

Scan using your mobile phone and access/share the post from your phone.

Written by Sony Arouje

December 20, 2014 at 6:07 pm

Posted in Raspberry Pi

Tagged with , ,

Working of my very basic and crude Aeroponic System

with one comment

Here I will just show you a video of my Aeroponic system. As you can see its very basic, I didn’t want to spend much money to test whether my system works, so I used cost effective materials.

In one of my previous post I explained about how I used Rasberry pi to control the motor. If you haven’t read it, please check that out too.

 

Low Pressure Aeroponic System

 

What Next?

  • From this initial test run, I could see my system is a success. Now I will add more pillars and a high capacity tank.
  • Automate day to day activities. For e.g. I have to add nutrients to the reservoir once in two day. Using a Peristaltic pump and a motor driver I can automate the process with a click of a button from my mobile app. 
download

Scan using your mobile phone and access/share the post from your phone.

Written by Sony Arouje

December 11, 2014 at 2:22 pm

Posted in Raspberry Pi

Tagged with

Distributed Raspberry pi based Hydroponic Controller

leave a comment »

Last couple of weeks I was building a Hydroponic system controlled by Raspberry pi. As of yesterday night my system was based on a single Raspberry pi that control one or more water pumps. It was one of my design goal to add more Pi’s based controllers to the network with zero configuration.

Why more Controllers?

As I am living in an apartment and the hydroponic system is going to be installed in the balconies. Connecting the motors installed in different balconies to a single Raspberry controller will make things ugly, I don’t want wires hanging here and there. So one option is, add another Raspberry pi controller. It’s easily doable, just install the controller software I created and plug the water pump.

As I explained in my last post, this system is controlled via mobile devices. So when ever I add a controller to my hydroponic network I have to create an entry in each of the device in which my mobile app installed. Also I have to assign a static ip to each Raspberry controller or keep track of the host name. When I start thinking about it, I see a system with some complications. Yesterday night I modified my controller application, this is what I come up with.

Unifying server and Controllers with self advertisement

I created a Unifying server in node js. The controller system running in different Raspberry pi’s advertise about it when ever it joins to my wifi network. This Unifying server will get notification whenever a new controller joins. I use Node Discovery module for service discovery and publishing. In this scenario I don’t have to worry about any configuration of the controllers. Just install my controller software in each raspberry pi and plug it into my hydroponic system.

My mobile app connects to this unifying server instead of individual controller system. All the commands to the controllers will be routed via this unifying server to respective controller. Below is the routing function I come up with.

app.use('/', router);
router.use(function (req, res, next) {
    options.host = req.headers.hostid;
    options.path = req.originalUrl;
    options.method = req.method;
    


    var request = http.request(options, function (response) {
            response.on('data', function (data) {
                res.setHeader('content-type', 'application/json');
                res.send(data);
            });
        });
        if (req.method === 'POST') {
            request.setHeader('content-type', 'application/json');
            request.write(JSON.stringify(req.body));
        }
        request.end();
       
});

 

This unifying server is a very light weight system and can run in a Raspberry pi or in my computer. On of my design goal is that Controller should be self sufficient and should run in any circumstances even if there is no connection to unifying server.

The Unifying server and the Controller system is based on Node js. It’s a beautiful platform and I learned a lot about node js while building this system. Also become a huge fan of Javascript.

 

Next post I will go through the mobile app I created.

 

Happy coding…

download Scan using your mobile phone and access/share the post from your phone.

Written by Sony Arouje

November 22, 2014 at 5:37 pm

Posted in Raspberry Pi

Tagged with ,

Hydroponics system controlled by Raspberry Pi an overview

with 3 comments

Last couple of weeks I was spending my free time to understand and building a Hydroponic system to grow vegetables in my Apartment’s Balcony. I just don’t want to build a normal system that controlled by a timer, instead I want to build a system that I should be able to monitor even I am not at home, change watering schedule using my mobile device.

Before we jump into details, let me give you a brief about Hydroponic.

What is Hydroponics?

In simple terms, hydroponic is a system where you can grow vegetables without soil, mix the required nutrients in water and feed directly to plants. Advantage of this system is, we are feeding plants what they want, instead plant hunting for the nutrients from soil. Also less consumption of water as we reuse the water.

If you search in google you will get more details of Hydroponics. I am working on a subset of Hydroponic called Aeroponics, where plants grow vertically. I made the vertical growing tower based on the method described by Gunnar Shaffer.

Any Hydroponic system needs water circulation using a water pump, I used a submersible pump bought from Ebay for 225.00 INR. This pump should pump water in a periodical manner, say water for 15 mins then sleep for 60 mins and the cycle continues. We can use a timer to do that, it will cost from 1500 – 2500 INR. I decided to use one of the Raspberry pi lying in my table.

Why Raspberry pi?

As a programmer, this small brilliant device give me the flexibility of controlling the system with the programming language of my choice. For this system I used Node js platform to build the controller system. I spent a night to build the basic system that can turn on/off any device in a specific interval and some REST api’s through which mobile device can interact. Later I spent several nights to polish and enhancing my system.

For my testing I used a breadboard to turn off/on one LED. After I successfully controlled the LED, it’s the time to control the Electrical motor. I bought a 12v single channel Relay from ebay for 99.00 INR. It can control one electrical device, in my case the submersible water pump. This post will give you an idea about how to connect the Relay to your Raspberry pi.

Mobile Application

After I completed the system running in Raspberry pi, I decided to write the application for the mobile device. Through which I can interact with the system. As of now the application can

  • Turn off the pump, in case of maintenance.
  • Schedule watering interval.
  • Turn on motor to water immediately.

The mobile application is written using Cordova platform, so that app can run on my Windows or Android devices.

What Next?

  • The basic infrastructure is done, next important step is start growing veggies. It got delayed because I am waiting for two meters to measure the water content. The pH and TDS meter.
  • Suggestion system for nutrient quantity based on the previous data.
  • Distributed cluster of Pi based Aeroponics blocks controlled by a server.
  • Connect Water level monitor to Rasp pi and notify if water level of the tank goes down.

Update: see my hydroponic in action.

Thanks to

  • My wife, for her support and encouragement, for all the crazy stuffs that I am experimenting with.
  • My father who guides and clarifies all my question related to Electrical devices and suggestions to improve the system for better performance.
  • Gardenguru for providing me with key information like measuring and controlling ph and EC level. I also bought the necessary items from them like Net Cups, Hydrotons, Nutrients, etc. They have a shop near to my home, I go there and spent time talking with them. They are very enthusiastic and provide with any info about Hydroponic to a newbie like me.

 

download Scan using your mobile phone and access it from your phone.

Written by Sony Arouje

November 10, 2014 at 1:21 pm

Posted in Raspberry Pi

Tagged with ,

Node js error handling using modules inherited from EventEmitter

leave a comment »

In node js most of the operations are asynchronous and normal try-catch will not work. In case of any error and we didn’t handle it properly, our node process will crash. In this post I will explain how to handle errors properly using EventEmitter.

In this e.g. we are going to read some data from a SQLite db, I use dblite as my node module to deal with SQLite db. For this e.g. I created a UserRepository module and inherited from EventEmitter

UserRepository.js

var dblite = require('dblite');
var util = require('util');
var EventEmitter = require('events').EventEmitter;

var UserRepository = function () {
    var self = this;

    self.getUser = function (userid, callback) {
        db.query('select * from USER where USER_ID=:id', [], { id: userId },
        function (err, rows) {
            if (err)
                publishErr(err); 

            callback(rows);
        });
    };

    var publishErr = function (err) {
        self.emit('error', err);
    };
};


util.inherits(UserRepository, EventEmitter);
module.exports = UserRepository;

 

Using util.inherits, we inherits the UserRepository module from EventEmitter. Later we export that module to use in other node modules. The publishErr() function will emit an ‘error’ event in case of any error and calling module can subscribe to that event and handle the error.

Let’s use the above module in another node module. Say an express rest api.

restApi.js

var express = require('express');
var bodyParser = require('body-parser')

var UserRepository = require('./UserRepository');
var userRepo = new UserRepository();

var app = express();
app.use(bodyParser.json());
app.listen(8080);

userRepo.on('error', function (err) {
    console.log(err);
});

app.get('/users/;id', function (req, res) {
    userRepo.getUser(req.params.id, function (record) { 
        res.send(record);
    });

});

 

Let’s go through the lines in bold.

Here we are creating the instance of UserRepository module.

var UserRepository = require('./UserRepository');
var userRepo = new UserRepository();

The calling module should subscribe for the error event, that’s what we are doing here. I am just writing the error to the console. You can do whatever you want with that err object.

userRepo.on('error', function (err) {
    console.log(err);
});

 

This way we can ensure that our errors are handled properly in an elegant way.

Node js has an uncaughtException event and use it as a last resort.

process.on('uncaughtException', function (err) {
    console.log(err);
})

Written by Sony Arouje

November 7, 2014 at 5:47 pm

Posted in .NET

Follow

Get every new post delivered to your Inbox.

Join 194 other followers

%d bloggers like this: