The idea comes from the question: how to optimize water consumption in my vegetables garden ? Aguilar de Segarra, where I live, belows to what we know as 'Dry Bages' ( the Bages is our shire ) and water is expensive. So is important to store as much rain water as possible, and we do it, but by now with a tank of only 1.000 liters. Considering rain statistics in our zone and the surface of our roof we could store between 20.000 and 30.000 liters per year which supposes important savings.

Anyway, is very important to not waste water and optimize usage. How ? Just watering as needed, and this is not an easy task, and even more complex for amateur gardeners like us. The watering needs for a garden have many variables to consider. Some of them are homogeneous in the garden like terrain composition, climate, etc. Others don't: plant types, slopes, etc. To be accurate it would be necessary to establish a watering plan for each crop depending on the exact location in the garden but this is too complex.

In order to simplify the project scope, I will assume some constraints as a starting point:

  • The surface of the garden is flat ( practically true ) and the soil is homogeneous ( just believe it ). Think about we're talking of a garden of about 200 m2, and not all is in use.
  • Suppose that all plants in the garden have the same water requirements. This is completely false but if I consider all kind of plants the project would be too complex: one sensor per plant kind, the irrigation system will be also complex: too many valves and pumps, etc. The economical cost of the implemented solution is not expensive but not negligible and a good starting point. Maybe we will review the solution implemented, adopting a compromise: grouping crops depending on watering needs ( high/low requirements ). We will see.

With these hypothesis the idea is the following: create a sensors network ( by now only one !! ) to measure the watering needs of a vegetables garden, and water it if needed. Of course, in an automated process and also, to avoid cabling the garden, use wireless communications and solar power.

As I have experience in the IT projects management area and this project also has an important technology component I've tried to use the same methodology than in my everyday work but simplifying as much as possible and adapting conveniently. So I have divided the project in several phases and clearly defined which tasks belong to each phase. Each task could need several hours and I try to not parallelize so many tasks ( 3 is too many !! ) but in this way the project progress. It helps me a lot to avoid complex tasks at first, and simplify when possible but mantaining functionallity. As I'm feeling comfortable with the environment I add complexity until completing the objective. Is it important to know when stop. It is also important to not change the scope of tasks during the execution, you will only add complexity, noise and you will delay all things and probably you will waste some extra money. There is always a moment to add more functionallity but probably you're thinking about a version 2.0. Obviously, if you have defined an impossible step, stop and take an step back, redefine it and start again. The objectives must be realizables...

Version 1.0 is divided in three main phases:

  • Design of a water level sensor, with wireless data trasnmission and solar powered.
  • Design of a control application that will collect sensor data and save it to a database. Finally, I have decided to not implement now the automatic watering, more details in section 'Version 2.0'.
  • Design a web site that allows to see the data in a graphical way.

These phases are not completely independents, for example, in order to test the sensor: it is necessary to have a database ready to store data, right ? It is necessary to mix tasks of different phases at same time.

I want to mention that at the end, all tasks and all stuff can be summarized in few data sheets, which I carefully mantain. Just put checkmarks when tasks and actions are finished. When you have all the checkmarks, the project is finished !!

Now the sensor is up and running, it is storing information in a database and I have developed an small web application, maslestorres.cat, to allow data visualization. The watering automation is still missing.

So:

Phase 1: 100%
Phase 2: 100%
Phase 3: 100%

At first I thought that it would be too complex, but in about 3 months, and just dedicating few hours I have built the prototype of a wireless solar powered sensor. In next paragraphs I will explain the details of each component. Again, and just searching the internet, I have found similar works and I have used parts of these projects, even when there is no exact match of what I have built. You can consider this project as an integration of parts of other shared projects in internet. I want to mention here the most important information sources that I have used:

I want to mention here the Rob Faludi book 'Building wireless sensor networks' (ISBN 978-0-596-80773-3), which has been very important in order to start all this stuff. It has a lot of simple and useful examples that helped me in this project.

In order to decide when it is time to water the garden I've used a physical magnitude which is the water volume present in soil ( VWC, or 'Volumetric Water Content' ). This magnitude can be measured with adequate sensors, but the most important thing is how to interpret this data and this is where I need still some help. I can know how much water there is in each cubical meter of soil but it is necessary to know if this is too much or not and if, for example, is necessary to open the faucet. There are a lot of papers in internet explaining magnitudes of interest for watering soils, thanks Google. A good example is the document, in spanish, of Universitat de Texas A&M 'Uso de sensores de humedad del suelo para eficientizar el riego' by Juan M. Enciso, Dana Porter and Xavier Périès. I recommend to everybody because is a complete article, easy to read and there is some data about watering needs of plants. Take care about units, they are imperial units, and the calculator must be near. Is also frequent to use percents in VWC.

I haven't found a magic table with information like: if you have tomatoes in the garden and the VWC is below x value, you must water. If it is lettuce... This table must be built yet and experience, measurements, watering and evaluating plants growth will help. Help is needed here and if somebody wants to share his experience it would be grateful, but considering that probably we will need to adapt to our garden.

I've tested two kind of sensors: DIY ( 'Do it yourself', also known as Kutrex1 ;-D ) and a commercial sensor, model Decagon EC-5. Both work and probably for our needs both are fine.

The Kutrex1 is a two-nails model, found everywhere in the internet, and is based on measuring the electrical resistance between the two nails when is buried: more water means less resistance. But every sensor will be different: kind of nail, distance between them, isolation and you must have some skills to correctly build it. This means that calibration is needed for each sensor and this part is not easy. Also consider that a buried metal sensor rusts so values will change over time. Electronics will be a little bit tricky because it will be necessary to add a transistor to power it and it will increase the total power consumption and it could be a problem considering that we will use batteries and solar power. Economical cost is the best part, around 1€ and people are using them.




The Decagon EC-5 is an analogic sensor that measures the dielectric constant of soil. It is an electronic circuit able to give us a voltage proportional to the VWC, with a little error. The manufacturer will provide the functions needed to convert voltage to VWC. It is the most expensive part of the project but it simplifies a lot of other things. Another option, cheaper than Decagon, is to use the sensor VH400 from Vegetronix, but I haven't tested it. Is also an analogic one, but its implementation will also require additional electronics to work correctly due to the voltage requirements.




More information aobut the Decagon EC-5 can be found in the manufacturer site.

For a sensors network ( more in section version 2.0 ) you can choose between Kutrex1 for field sensors and preserve the Decagon EC-5 for calibration tasks. Is an idea for a multiple sensors network with low budget.

As I wanted a wireless sensor I needed to look for some device able to read sensor data and send it to some place. Wi-fi ? It was an option but I found the ZigBee standard which was a perfect fit. Look at the definition provided:

ZigBee offers green and global wireless standards connecting the widest range of devices to work together intelligently and help you control your world.

I have choosen ZigBee devices of XBee brand, easy to find and use, with reasonable prices ( between 20€ and 100€, depending on features ). In the image, an XBee Pro with an antenna, with an XBee Explorer USB circuit ( later we will see it ).




Among other things the project XBee's can do the following:

  • Convert an analogic signal to a digital one, with an integrated A/D converter of 10 bits. The analogic signal must vary between 0 and 1,2 Volts, which perfectly fits with the Decagon EC-5 output. Also the read data is automatically sent by radio.
  • They have an sleep mode. I wake up the XBee during 10 seconds every hour, enough to get five sensor measures and send them to a computer. This mode grants a long live of the battery. It is necessary to install an 'End Device AT' firmware in the XBee. Look in the provided user guide in the manufacturer's site.
  • It only requires 3,3 Volts to be powered.
  • The choosen model, Pro series, has a 5 km outdoor range, with a transmit power output of 50mW. Bigger gardens... but in our case we can have the receiver at home and save data in a familiy computer. Cheaper models have reduced outdoor ranges, 120 m, but they need less power ( 2 mW transmit power output ).
  • Building the network with these devices is easy and it has many options, most of the configuration is automatic. In fact, only three parameters of the configuration are related to the network configuration: network name, node name and target address. Other parameters allow to adjust data sampling or the sleep mode, for example.

    So we have the sensor and the radio. How we connect them ? Easy, just connect the sensor output to the XBee input, I have choosen the AD0 input, but the XBee provides four inputs, so you can add up to 4 sensors per radio. It could be interesting to combine VWC sensors with temperature sensors, humidity sensors, etc. In other way the sensor needs power to work and generate data. Decagon recommends a voltage between 2,5 and 3,6 Volts of DC for EC-5. Note that XBee works with a voltage of 3,3 Volts and also has pin nº 13, named ON, which provides 3,3 Volts when is awake and this is perfect for the sensor. So the sensor will also sleep when the XBee sleeps. The best part is that we won't need any interface circuit between the sensor and the XBee.




    But who powers the XBee ? Here, and after looking for to many internet stores I have found a perfect match: Adafruit 390. It can be connected to an USB port, to a 5-6 Volts DC power supply or to a solar panel and charge the battery at same time that it powers the XBee. It is 25$ USA, but be patient because is always exhausted, I needed about one month to get one. As the sensor will live in the garden the power supply is a solar panel, and the battery has enough power to feed the circuit at night. It is necessary to replace a resistor in 390 circuit by a temperature sensor, because it has to work outdoor and the Li-Poly battery used can only be charged between a range of temperatures ( 0º - 50ºC ), better to not start any fire, right ? Don't worry about the mod if you choose the 390, in the Adafruit site is well explained how to do it, step by step.

    The only imperfection of the 390 is that output voltage must be adjusted to 3,3 Volts for the XBee, you will need the solder and a voltage regulator ( LD1117V33 ) with the corresponding electrolytic capacitors, you will also get a better stabilized power.

    I have added also a reset button for the XBee. It shortcuts the RESET pin ( nº 5 ) to GND ( nº 10 ). It seems a silly thing but is very useful with long sleep modes in order to wake up the XBee at your convenience and now, and with the hot solder in place, two more wires are not a hard work ;-D.

    As a summary, the main components of the prototype are:

    • Decagon EC-5
    • XBee Pro S2
    • 2 DBI 2,4 GHZ SMAM-RP ANTENNA
    • LD1117V33
    • Adafruit 390 ( USB / DC / Solar Lithium Ion/Polymer charger )
    • 10K Precision Epoxy Thermistor - 3950 NTC
    • Lithium Ion Polymer Battery - 3.7v 2600mAh
    • Medium 6V 2W Solar panel

    Add wires, electrolytic capacitors, a stereo mini-jack, heatshrink to enlarge the solar panel wire, a multimeter, a solder, few proto-boards, etc. Some of these parts come from my student days… This prototype costs about 170€ ( without VAT ) but the sensor costs more than one half. It is a compensation for a year without holidays. I plan to review the design in order to reduce costs and here new ideas are welcome.




    The proto-boards are brilliant for testing and testing again but I always loose time finding which wire has been desconnected, the components some times disconnect and it is not a good idea to consider them as a definitive circuit. I bought a board full of holes and with the solder I made it definitive, but is also one thing to improve because the result is not so clever !!




    The XBee is not soldered to the board, because I found sockets ( be careful with XBee pin spacing which is not the 2,54 mm standard, it is 2 mm !! ). Think about the XBee needs programming via computer. You can choose to use the X-CTU software ( Windows only ), provided by the manufacturer, or a terminal emulator to send AT commands via serial port. But consider that firmware updates and API mode configurations will only work with X-CTU. It is quite common to insert and remove the XBee in order to change parameters ( I have used the circuit XBee Explorer USB by Sparkfun ). If you want to test, I have used the following parameters in my working sensor, details in user guides ( Product Manual: XBee / XBee-PRO ZB RF Modules ):

    
    ID 2012
    DH 0
    DL 0
    NI EDEV1
    IR 0x07D0
    BD 7
    SM 4
    SP 0x7D0
    SN 0x5A
    ST 0x2710
    SO 4
    D0 2 
    WH 20
    		  

    Finally, we need to build a support to install the prototype in the garden and put all circuits into a water-proof box. Some painted wood, a piece of a steel reinforcing bar, a standard Legrand box ( 3€ !! ) and few cable ties to fix the box. All circuits have been fixed on a bakelite board that I have cut and I have installed in the box using 3 mm separators.










Ok, at this point we have the sensor running in the garden, but where it goes all this data ? Here I have used an open source microcontroller, the Arduino, an interesting discovery. Concretely the Arduino UNO, 8 bits and 32KB of memory, enough for this project in version 1.0. It is obvious that the Arduino needs also a radio to receive the sensor data, so we will need to adapt an XBee but we can do it with a shield. There are few circuits like this and I have used a communication shield from libelium.




In this case, and following the Rob Faludi book, I have programmed the XBee with a 'Coordinator API' firmware, this means that will only be able to change configuration parameters using X-CTU ( on a Mac you can run it using Wine or using a virtual machine, VirtualBox, for example ). It is not necessary to sleep this XBee because is located at home and power is not a problem, and with a coordinator firmware it won't work. Note that with multiple radios in the network you need a coordinator working all the time. I have used the following parameters in order to connect with the sensor radio:


ID 2012
DH 0
DL 0
CH 14
AP 2
NI COORDINATOR
BD 7
		  

The Arduino sends the received data to a computer using the provided serial port ( USB ) and an application, arduinoToSQLite, stores the data into a database.




The Arduino sketch code is simple and basically only processes the reveiced data from an XBee if it is of type 'IO Data Sample' ( 0x92 ), which can contain data from up to 4 sensors, analog or digital ( but digital data is ignored ). This application is based on the provided example in Arduino site and the formating routines come from the project Desert Home. I use a simple format for data packets, an initial delimiter '#', I separate values with commas ',' and I end the packet with a semicolon ';' in this way is easy to process data in the computer.

					
 /**
 * Copyright (c) 2012 Joan B. Altadill
 * Reading XBee analog sample data
 *
 * Data formating to send to a Mac, via serial port,
 * and store in a SQLite database: 
 * 
 * Header "#" + ZigBee IO Sample
 *
 **/

#include 

unsigned long svalue;

XBee xbee = XBee();
ZBRxIoSampleResponse ioSample = ZBRxIoSampleResponse();

void setup() { 
  Serial.begin(9600);
  xbee.setSerial(Serial);
}

// uint16_t 	getPacketLength ()
// void 	getZBRxIoSampleResponse (XBeeResponse &response)
// uint8_t 	getFrameDataLength ()
// uint8_t * 	getFrameData ()
// uint16_t 	getAnalog (uint8_t pin)

void loop() {
  //attempt to read a packet    
  xbee.readPacket();

  if (xbee.getResponse().isAvailable()) {
    // got something

    if (xbee.getResponse().getApiId() == ZB_IO_SAMPLE_RESPONSE) {
      xbee.getResponse().getZBRxIoSampleResponse(ioSample); 

      // Si s'ha llegit un paquet tipus IO sample envio a l'arduino un paquet 
      // via port serie amb el seguent format:
      // 64-bit Source address (8-bit), 
      // Per a cada port analogic actiu, el nº de port + valor llegit
      // finalment el delimitador.
      
      //64-bit address
      XBeeAddress64 senderLongAddress = ioSample.getRemoteAddress64();
      Serial.print("#");
      print32Bits(senderLongAddress.getMsb());
      print32Bits(senderLongAddress.getLsb());
      Serial.print(",");
      //Serial.print(senderLongAddress.getMsb());  
      //Serial.print(senderLongAddress.getLsb());  
        
      //for (int i = 0; i < xbee.getResponse().getFrameDataLength(); i++) {
      //  Serial.print(xbee.getResponse().getFrameData()[i], HEX);
      //}
      
      // Now, we have to deal with the data pins on the
      // remote XBee
        if (ioSample.containsAnalog()) {
          // the bitmask shows which XBee pins are returning
          // analog data (see XBee documentation for description)
            uint8_t bitmask = ioSample.getAnalogMask();
            for (uint8_t x = 0; x < 8; x++) {
              if ((bitmask & (1 << x)) != 0) {
                print8Bits(x);
                //Serial.print(x, HEX);
                Serial.print(",");
                //Serial.print(ioSample.getAnalog(x));
                print16Bits(ioSample.getAnalog(x));
                Serial.print(",");
              }
            }
        }    
    }   Serial.print(";");
  
  } else if (xbee.getResponse().isError()) {
    Serial.println(xbee.getResponse().getErrorCode());
  }
}

// these routines are just to print the data with
// leading zeros and allow formatting such that it
// will be easy to read.
void print32Bits(uint32_t dw){
  print16Bits(dw >> 16);
  print16Bits(dw & 0xFFFF);
}

void print16Bits(uint16_t w){
  print8Bits(w >> 8);
  print8Bits(w & 0x00FF);
}

void print8Bits(byte c){
  uint8_t nibble = (c >> 4);
  if (nibble <= 9)
    Serial.write(nibble + 0x30);
  else
    Serial.write(nibble + 0x37);
      
  nibble = (uint8_t) (c & 0x0F);
  if (nibble <= 9)
    Serial.write(nibble + 0x30);
  else
    Serial.write(nibble + 0x37);
}
		  

Now it is time to develop an application to receive the data that comes from the serial port. At home we have Macs, and a Mac mini is perfect for this task. So using as a template the Interfacing Cocoa example from the Arduino site, I have changed the code in order to store data in a database, using the Apple development tool XCode, which is actually free. Note that an advantage of the MacOSX 10.8 ( Mountain Lion ) is that it comes with a functional SQLite v3 database, so just SQL code is needed to create de data structures and save data. I have used Objective-C for the user interface, but mantaining C code for serial port interface ( IOKit framework ). This code is omitted here because is very similar to the example provided, just adding some lines to recompose data packets from serial port buffers that come from the Arduino and saving to the database. An example packet could be:

#0013A2004090C5FA,00,0133,;
  • # - start of packet
  • 0013A2004090C5FA - 64-bit XBee address
  • , - separator
  • 00 - XBee analog channel AD0 ( packet could contain data from up to 4 channels )
  • , - separator
  • 0133 - Sample value at XBee AD0 input, which comes from the sensor. It is an hexadecimal number, 0x0133, and it represents a voltage in mVolts. The value must be corrected in the program, because the XBee samples data with 10 bits ( 2e10 = 1024 ) and the maximum voltatge that it can read is 1,2 Volts. So we will need a code ine like this one to get the real value from sensor:
  • mV0 = wvalue0 * 1200 / 1024;
  • , - separator
  • ; - end of packet

Separators are useful in order to extract data from the packet and save it to the database. The packet is a string, class NSString, and I use a class method to decompose it. The interesting line would be:

NSArray *packet=[string componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];

I suppose that other developers will use other languages, and probably in other environments there are simpler options than this one. I will probably reconsider this application in version 2.0

Here I have to express my gratitude to my colleague Albert Fortes, for the patience and help in the application design and the selection of components used. He has selected the right components in order to create a simple web site, accessible from internet and considering these requirements: open source, multiplatform and mantaining all things as simple as possible ( but this is impossible :-D ). At the end, strange names have appeared and I have needed to read documentation, too much technical documentation. Some words used are: cherrypy, python, json, jquery, HTML5, css, javascript, bootstrap, d3 and probably I'm forgetting some ones. Nice ?

I have divided the web application in two parts:

  • In the server that hosts the database, the Mac mini, I have installed an HTTP server that publishes a web service that queries the database, taking as a parameters a date interval.
  • In the web site that hosts the maslestorres.cat I have created the page jardiNetVWC that consumes the previous web service and converts data to a line chart. These pages are hosted in an internet service provider ( ISP ).

Just to say that in MacOSX 10.8.2 there is a functional version of python, so no other installation is needed:


[joanba:~] joanba% python
Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
		  

On top of it, I have installed cherrypy, which is a web framework based in python. This simplifies a lot the web server creation in order to publish sensor data. In fact, the code needed fits in less than 100 lines. Also mention that choosen data format is json.


"""
MasLesTorres v0.1
20130121
"""

import cherrypy
import os.path
import json
import sqlite3 as sqlite
import logging
import logging.handlers

webserviceconf = os.path.join(os.path.dirname(__file__), 'maslestorres.conf')
dbname = "db/hort.db"

#Log config.
log = cherrypy.log

# Remove the default FileHandlers if present.
log.error_file = ""
log.access_file = ""

maxBytes = getattr(log, "rot_maxBytes", 10000000)
backupCount = getattr(log, "rot_backupCount", 3)

# Make a new RotatingFileHandler for the error log.
fname = getattr(log, "rot_error_file", "logs/error.log")
h = logging.handlers.RotatingFileHandler(fname, 'a', maxBytes, backupCount)
h.setLevel(logging.DEBUG)
#h.setFormatter(_cplogging.logfmt)
log.error_log.addHandler(h)

# Make a new RotatingFileHandler for the access log.
fname = getattr(log, "rot_access_file", "logs/access.log")
h = logging.handlers.RotatingFileHandler(fname, 'a', maxBytes, backupCount)
h.setLevel(logging.DEBUG)
#h.setFormatter(_cplogging.logfmt)
log.access_log.addHandler(h)

class WebService:
    
    def index(self):
        #raise cherrypy.HTTPRedirect("/html/index.html")
        return ""
    index.exposed = True

    def ExecuteSqlLiteQuery(self,Query):
        con=sqlite.connect(dbname)
        cur = con.cursor()
        cur.execute(Query)
        data = cur.fetchall()
        con.close()
        return data
    
    def ExecuteSqlLiteQueryOneRow(self,Query):
        con=sqlite.connect(dbname)
        cur = con.cursor()
        cur.execute(Query)
        data = cur.fetchone()
        con.close()
        return data

    #Per simplicitat adapto el codi a la infraestructura actual: 1 radio, 1 sensor
    #def SQLQuery(self,date1,date2,radio,channel):
    def SQLQuery(self,date1,date2):
        
        cherrypy.response.headers['Content-Type'] = "*"
        #cherrypy.response.headers['Access-Control-Allow-Headers'] = "*"
        cherrypy.response.headers['Access-Control-Allow-Methods'] = "POST, GET, OPTIONS"

        cherrypy.response.headers['Access-Control-Allow-Origin'] = "*"

        #sqlq    = "select count(*) from sensor_data" + " where time >= '" + date1 + "' and " + " time <= '" + date2 + "'"
        #counter = self.ExecuteSqlLiteQueryOneRow(sqlq)
        
        #Per simplicitat adapto el codi a la infraestructura actual: 1 radio, 1 sensor
        channel = 1
        radio   = "0013A2004090C5FA"
        
        if channel == 1:
            select = "select time, sample0 "
        elif channel == 2:
            select = "select time, sample1 "
        elif channel == 3:
            select = "select time, sample2 "
        elif channel == 4:
            select = "select time, sample3 "
        else:
            select = "select * "
        sqlq    = select + "from sensor_data" + " where time >= '" + date1 + "' and time <= '" + date2 + "' and radio_sn = '" + radio + "'"
        #print sqlq
        data    = self.ExecuteSqlLiteQuery(sqlq)
        #print data
        #counter = len(data)
        #data.insert(0,counter)
        result=[]
        for temps, mVolts in data:
            # data must be correctly parsed for jqPlot/d3: 20130210012300 --> "2013-02-10 01:23:00"
            temps_jqPlot = temps[:4] + "-" + temps[4:6] + "-" + temps[6:8] + " " + temps[8:10] + ":" + temps[10:12] + ":" + temps[12:14]
            # converteixo els mVolts llegits al XBee en VWC%, amb formula Decagon:
            # VWC (m3/m3) = 0.00133 * mV - 0.456, x100 per obtenir %
            VWC  = (0.00133 * mVolts - 0.456) * 100
            punt = [temps_jqPlot, "%.2f" % VWC]
            result.append(punt)
        return json.dumps(result)
    SQLQuery.exposed = True

if __name__ == "__main__":
    # CherryPy always starts with app.root when trying to map request URIs
    # to objects, so we need to mount a request handler root. A request
    # to '/' will be mapped to HelloWorld().index().
    cherrypy.quickstart(WebService(), config=webserviceconf)
    #else:
    # This branch is for the test suite; you can ignore it.
    #cherrypy.tree.mount(WebService(), config=webserviceconf)


		  

The configuration file that cherrypy needs is simple:


[global]
server.socket_host = "0.0.0.0"
server.socket_port = 8080
server.thread_pool = 10

log.screen: False

[/]
tools.staticdir.root: '/Users/joanba/Desktop/Arduino/maslestorres.cat/'

[/html]
tools.staticdir.on: True
tools.staticdir.dir: 'html'

		  

The web site maslestorres.cat has been time consuming, because this programming is new to me and this is the first site that I develop. I have spent several nights looking for templates, and after trying few of them I decided to choose one of the most used, Twitter Bootstrap . It is practicaly unmodified…

At this point, it is necessary to call the web service and present data in a chart, this means javascript, jquery and d3. All these components are executed in your browser so you have all the source code.

The graphical framework d3 is powerful and can create amazing graphics. But is complex and difficult to learn, but there are a lot of examples available. I haved used d3 in two pages: jardiNetVWC, where I use a simple zoomable line chart and in my personal page, Joan, where I tried to define my interests in a graphical way

Finally just to mention that development tools used are: XCode for python code and Aptana for the rest. Both are free.

After few weeks with the prototype working I can see some interesting data. At first, during this winter and after few weeks without watering the garden and no rain, the VWC had values around 12% ( check February 2013 in the graph ), after watering the garden drop by drop, 03/March/2013, with 1.000 liters, the VWC reaches a peak of 36%. 05/March/2013 starts to rain, in a continuous way during 72 hours ( 70 liters/m2 ) the VWC reaches a maximum of 44%. All these peaks decrease so fast, so I suspect that they could indicate the field capacity of the soil ( from this point the soil cannot absorbe more water leaving puddles on the ground ). After comparing these values with the ones provided in the article that I've commented in 'The sensor' section I can see that for clay soils the field capacity is around 40%.

I will update this section when I arrive to new conclusions with obtained data. In the next days I will start to grow vegetables in my garden so it will be time to get more interesting data. It will come.

Version 1.0 is well defined and I have a clear idea of where to stop, in fact is done because I'm just solving code bugs as they appear. Also I have thinking about how to improve parts of this project and some ideas have appeared. I want to comment them:

I want to integrate all sensor components in a unique circuit. Adafruit 390 is a flexible circuit for most projects but in this case I would modify it to supply the 3,3 Volts needed for the XBee without additional regulation and also with integrated sockets for the XBee, and also ( is a wish list, right ? ) some free holes in order to integrate other components like the sensor adapters. Schemas and layouts are available at github and they are the best starting point but I ignore if there are legal requirements about usage.

Reduce cost. This prototype is a good one for a hobbyist but it has no commercial future. It needs a revision about the sensor used because is too expensive and probably there are cheaper options. Also note that the idea is about a sensor network with more than one sensor, of course. Imagine that you want to water a big surface, few acres with different plants or with a complex orography, it will have zones with different watering needs and we will need to install at least one sensor in each zone. It would be convenient to fix a limit on price and analyze which changes can be done in order to reach it. Also important is to know if there are more people interested because volume prices will also help. What about 50€ ? Is it possible ?

Arduino autonomy and avoid dependency of the server… I would like to move the 'intelligence' of the project from the Mac to the Arduino, and make the system strong. For example, if the computer do not work and the database is not available, the Arduino must be able to save data locally and update the database when available again. There are important changes to do and I have started the work.

  • Add a filesystem.
    For example, using the 'Wireless SD Shield'. This part has been easy, in just two hours I've replaced the previous shield and now the Arduino is saving received data in a microSD card in addition to send the data to the arduinoToSQLite app. By now I'm saving just a time reference using the function millis() which is useless. Now a valid time reference is added in the arduinoToSQLite application, when saving data to database.
  • Add a clock (Real Time Clock).
    This is the current step, at the time that I'm writing this page, and I have selected a cheap and simple clock: Adafruit 264. I have not received yet but I have already installed the RTClib in the Arduino environment... I will change here from the Arduino UNO to an Arduino MEGA 2560.
  • arduinoToSQLite redesign.
    I have thought about this some time and I think that I have to change the application, even when I don't plan to change the functionallity, because I want to recode it in multiplatform environment. Now the arduinoToSQLite is a Mac only application and I also consider the Objective-C language too complex. So I have decided to port the arduinoToSQLite application to python which is available on most platforms, also on a Mac of course. Also I want to simplify the application: the UI will be replaced by a simple configuration file and I will install the application as a service in the computer.
  • Add a display and a keyboard.
    Let's see when I get here !!! At first only basic functions: time adjustment, display last sensor value, etc. Still an open list...