Project in progress
iGrow: Truffle Irrigation Control and Monitoring

iGrow: Truffle Irrigation Control and Monitoring © GPL3+

IoT water control for irrigation of truffles. It monitors and controls amount of water in storage tanks on field.

  • 8 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Truffle is a fungi which grows in symbiosis with certain tree species. More specifically, near tree roots. Furthermore they can be found only on very specific soils and locations where water supply can be limited. All this makes them delicate to grow and very valuable.

Truffle farm consists from trees infected with mentioned fungi. To keep farm healthy it is needed to control humidity of the soil in which truffles grow. This part can be often challenging due to location and missing public infrastructure.

Our goal was to develop a system which works off the grid, controls water on the farm and informs farmer about possible need for resupply of it. We are calling this project Igrow!

Igrow infrastructure keeps farmer notified regarding the state of the water and reduces the amount of it brought to the site. This brings cost of farming down and reduces the workload on the farmer.


Igrow is controlling and monitoring water quantity on truffle fields as they are usually on remote locations with limited water supply. There are multiple tanks but only one has rainwater supplied from nearby roof. Igrow constantly calculates average consumption over N days and checks weather forecast to give warning before you run out of water. This gives a user clear notice when additional water needs to be transported.


Igrow is controlling two water tanks. For this purpose we designed two electronic modules. One for main watering tank, tank from which water is used for flowering and module for control of secondary water storage tank.

For control of main watering tank small low power module was developed. Its core is atmega328p micro-controller supplied by li-ion 18650 battery. Whole PCB and code is optimised for ultra low power consumption. Atmega is mostly in power-down state and wakes up every 16s. On wake up ultrasonic sensor and NRF24L01 transceiver is enabled. Water tank is measured and sent via NRF24L01. Module goes back to sleep. Module battery life is around a year. To make it really "set it and forget" additional solar charger circuit was added. This enables infinite battery life.

Secondary water storage tank electronics needs to be capable of transferring water to a main tank. For this reason bigger energy source is needed, like 12V car battery. Having this in mind Igrow secondary storage tank electronics is designed to be supplied from bigger 6V+ source. This enabled us to use Arduino mega board with ultrasonic sensor and NRF24L01, SIM800 transceivers. Arduino mega acts as a "master" of Igrow system. It itself measures water level of the secondary storage tank and listens for water level information send from main watering tank module via NRF24L01 modules. Additionally it is connected to a Igrow server using GSM module SIM800L and GPRS.


To establish wan communication SIM800L module is used. It establishes GPRS and communicates via server using http protocol. There is prepaid SIM card inserted into the on-field module. On set time intervals GPRS session is established on GSM existing network. Basic state of the system is send to the server using POST command. In case of success server responds latest data from UI is returned. This data is processed and internal settings of the hardware are adjusted.


For Igrow custom module power source we implemented Li-ion battery. It supplies 4.2-2.5V which are further regulated to constant 3.3V using buck-boost converter. Essential sub part is li-ion protection using DW01 IC to protect the battery against over-current, over-voltage and under-voltage event. In any such case power to a board is cut. Furthermore charging feature is implemented using TP4057 IC. This enables us to supply external power from 3-5v solar panel for charging the battery. Using 2500mAh Li-ion battery redundancy is expected to be in few months to a year range.


Water level is measured using SR04T waterproof ultrasonic sensor. Measuring is done every 16s and recalculated by the processor. In total we have two sensors. One is located on watering and one on storage tank.


For LAN communication transceiver NRF24L01 is used. Main flowering tank module includes upgraded 100mw transmission power version for open air range of few hundred meters. This is essential to allow reliable connection no matter the distance between modules. Communication between modules is one-way for ease of implementation. Every 16s main flowering module wakes up and sends data packet in the air. Arduino mega listens and acknowledges the packet. Solution enables superb range and minimal energy requirements.


For backend we established linux server on a virtual machine in Okeanos educational platform with LAMP stack. We have written PHP script to get data from SIM800 module. Transmitter sends HTTP POST request with data on to the server. Later PHP script saves sent data on MySQL server. PHP script to access data from the server to display it on UI was also created.


In MySQL we have made multiple tables to handle data to and from transmitter module. One table handles "status" data and the other one handles "set" data. Status data gets data from transmitter, and set data gets data to transmitter. There are also extra tables for different settings of the system.


Web app includes a login page for each individual user, that would like to login to his admin page.

User is then greeted with control page which has information about the device on site. The most important is the level of water in both tanks. UI shows percentage of water in each tank. The site also shows weather forecast using OpenWeatherAPI, for the next 2 following days. User has few additional options like setting the desired level of water or manually starting the pump.

Besides water UI also shows 12V battery state and the recommendations panel with predictions. One of the predictions is the time when additional water needs to be delivered to the field.

Calculation of consumption

In settings user fills in the data about how many truffles does he has and how much water would he like to use per one plant per day. The user also adds the data about roof size for system predictions.

After data is received system calculates for how many days water should last and how much additional water is expected from the rain. Weather is received from OpenWeather as mentioned above. Lastly the number of days till when water will last is shown on the first page under recommendations.


Pump control code (ArduinoMega)C#
Main function flow of pump control
 * This is Igrow project main code
 * Compatible with ArduinoMega and modules SIM800L, NRF24L01 and ultrasonic distance sensor. 
 * Code version: V5

#include "nRF24L01.h" // NRF24L01 library
#include "RF24.h"
#include "SPI.h"

// Server database address
const String URL = "http://<domain name>";
int ReceivedMessage[2] = {000}; //NRF24L01 packet
RF24 radio(49,48); // NRF24L01 used SPI pins
const uint64_t pipe = 0xE6E6E6E6E6E6; //NRF24L01 communication pipe

int Voltage_sense = A14; //Power supply voltage sense pin
// data
int main_tank_value = 100; //Water level in % of distant water tank
long main_tank_value_received_time = 0; //Last receiving time of distant water tank data
int main_tank_value_wanted = 50; // Wanted level in distant water tank
int secondary_tank_value = 0; //Water level in % of secondary storage tank
int Battery = 0; //Battery voltage
byte Battery_state_of_charge = 50; //SOC of battery in %
bool pump = 0; //Pump status; 1 = ON, 0 = OFF
//Mode sistema
 * 0 -> sistem ustavljen
 * 1 -> sistem deluje normalno
 * 2 -> napaka v sistemu, sistem ustavljen
 * 3 -> varčevanje z energijo
int mode = 1; //mode sistema
int GSM_sending_period_s = 60; //Na koliko časa se pošiljajo podatki na splet 
long gsm_time = 0; //Čas zadnje komunikacije z serverjem
long gsm_session_time = 0; //Čas zadnje menjave sessiona na GSM
long GSM_session_period_s = 300; //5min //Čas kolikor traja 1 session GSM interneta
long last_sucsessful_session_time = 0; //Čas zadnjega uspešnega odziva serverja

void setup(void){

pinMode(Voltage_sense, INPUT);

Serial.begin(9600); //Debug port
Serial1.begin(9600); //GSM module

radio.begin(); // Start the NRF24L01
radio.openReadingPipe(1,pipe); // Get NRF24L01 ready to receive
radio.startListening(); // Listen to see if information received
//Waiting for any data from debug port for a system to start
Serial.println("RF24 receiver running");
Serial.println("Press any key to start");

GSM_GPRS_WAIT(); //Waiting til GPRS is working

void loop(void){

  RF_SESSION(); //RF komunikacija (Distant tank watter level check)
  GSM_PROCESS(); //GSM services (GSM communication and controll)
  Battery = Battery_sense(); //Measuring power supply voltage
  Battery_state_of_charge = Battery_percentage_calculation(Battery); //Calculating battery SOC from power supply voltage
  //Water tank
  //secondary_tank_value = ; //Measuring water level in secundary storage tank
  PUMP_PROCESS(main_tank_value,main_tank_value_received_time,secondary_tank_value,main_tank_value_wanted, Battery_state_of_charge); //Pump controll
  //System check
  mode = System_check(mode); //System health check
PHP script for intercepting data from transmitterPHP

//echo 'Hello World';
//echo $RAW;

parse_str($RAW, $OUTPUT);

$TM=$OUTPUT["TM"]; //tank main

$TS=$OUTPUT["TS"]; //tank secondary

$MTWS=$OUTPUT["MTWS"]; //main tank wanted status

$M=$OUTPUT["M"]; //mode

$B=$OUTPUT["BAT"]; //battery voltage

$BSOC=$OUTPUT["BSOC"]; //battery percentage

$TM = $_POST["TM"];  //tank main
$TS = $_POST["TS"];	//tank secondary
$MTW = $_POST["MTW"]; //main tank wanted


// $TM=99;
// $TS=99;
// $MTW=99;
echo $TM;
echo $TS;
echo $MTW;
$link = mysqli_connect("IP", "USERNAME", "PASSWORD", "TARTUF");

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;

//echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
//echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

$shrani= "INSERT INTO stanje (TM,TS,MTWS,battery,mode,BSOC) VALUES (".$TM.",".$TS.",".$MTWS.",".$B.",".$M.",".$BSOC.")"; //kasneje to zamenjaj s proceduro
if (!mysqli_query($link, $shrani)) {
				$error_int = 3;

$sql = "SELECT MTWSET from nastavi order by datumcas desc limit 1";
$MTWSET = $link->query($sql)->fetch_object()->MTWSET;
echo "{MTWSET=".$MTWSET."}";

function responce($error_int){
        $response = array();
	    $response["error"] = $error_int;
	    $response["success"] = false; 
		echo json_encode($response);


PHP script for OpenWeather APIPHP
$apiKey = #your_api_key;

	$cityName = $_POST['kraj'];
}	else{
	$cityName = "Ljubljana";

function dobi_vreme($city,$api){
	global $Imkraja, $dan11, $dan12, $dan13, $dan14, $t1, $t2, $t3, $t4, $t, $rain, $data ;

	$apiUrl = "" .$city . "&appid=" .$api. "&units=metric";
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_URL, $apiUrl);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_VERBOSE, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	$response = curl_exec($ch);

	$data = json_decode($response);
	$currentTime = time();

	$Imkraja = ucwords($data->city->name);
	$dan11 = $data->list[0]->dt;
	$dan12 = $data->list[5]->dt;
	$dan13 = $data->list[10]->dt;
	$dan14 = $data->list[15]->dt;

	$t1 = round($data->list[0]->main->temp);
	$t2 = round($data->list[5]->main->temp);
	$t3 = round($data->list[10]->main->temp);
	$t4 = round($data->list[15]->main->temp);

	$t = array();
	$rain = array();
	for ($i=0; $i <= 15; $i+=5) {
		$t[$j]= round($data->list[$i]->main->temp);
			$rain[$j] = $data->list[$i]->rain->{'3h'};
			$rain[$j] = 0;




Custom PCB for off the grid sensor value transmitter with solar power
97973846 2735005036737484 8901045500183052288 n 84slnxjalf
MySQL status table
Sql igrow xypxywlmcv
MySQL set table
Sql set igrow ikekkwmhhj
Water tank measuring module schematics
Altium dl3klunbfv


Similar projects you might like

Advanced Irrigation System

Project tutorial by Rahul Narang

  • 33 respects

Soil Control Grid: From The Ground To The Cloud

Project tutorial by Andrea De Gaetano

  • 13 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 40 respects

SERENA: Alarm Control Panel

Project tutorial by Michael Marinis

  • 18 respects

IoT Based Homemade Robot with Android and Voice Control Tech

Project showcase by Md Amirul Islam

  • 5 respects

Automatic irrigation with DHT22

Project showcase by Cristian Cadena

  • 7 respects
Add projectSign up / Login