Database not receive data

i used a free account with database. before this my database can receive all my data, but recently my database not receiving my data from 22.10.2019 until today. i am not changing anything before that. that why i dont understand why my database not receiving any data anymore, meanwhile my system running for 24 hours. here i attached my website picture

. i hope team from 000webhost service can help me out. Thank you.

URL would be lovely.

Remember we have hourly database limits and a 1GB OR 200 TABLE LIMIT.

yes, i check already my database size. it’s only 176kiB. i already delete the older data in order to give some space for the new data to enter. but it does not work.

http://smartgreeenspace.000webhostapp.com/

this is my URL

this is my URL

http://smartgreeenspace.000webhostapp.com/

Can’t see any issues currently, how does your system push the updates etc?

my system will push the data every one hour to the database. but the last data was on 22.10.2019. i already delete some of the older data, but my data still not appear in the website nor database. i dont know why…

anyone can help me to figure out why my database did not receive data from my system? if i upgrade to premiun, will my wesite up again? and my database receive the data?

Hello! We need more information. How does your application insert data into database? Is it a cronjob?

data.php

<!DOCTYPE html>
<html>
	<head>
		<title>SmartGreeenSpace</title>
		<link rel="icon" type="image/png" href="images/icon.jpg"/>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
		<meta http-equiv="refresh" content="300">
		<style>
		    
		    {
		        background-image: url("images/logo.jpg");
                background-repeat: no-repeat;
                background-size: 105%;
		    }
		    
            .heading
            {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                text-align: center;
                color:#4CAF50;
                padding-top: 33px;
         
            }
            
            #tabledata
            {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                font-size: 16px;
                border-collapse: collapse;
                width: 70%;
                margin: 0 auto;
            }
            
            #tabledata td, #tabledata th 
            {
                border: 4px solid #ddd;
                padding: 8px;
                text-align: center;
            }
            
            #tabledata tr:nth-child(even){background-color: #f2f2f2;}
            
            #tabledata tr:hover {background-color: #ddd;}
            
            #table th 
            {
                padding-top: 10px;
                padding-bottom: 10px;
                text-align: center;
                background-color: #4CAF50;
                color: white;
            }
            
            .data-container{width: 100%;}
            .display-chart{width: 100%;}
            
            @media screen and (max-width:600px) 
            {
                .data-container {width: 100%;}
                .display-chart{width: 100%;}
                #tabledata {font-size: 12px;}
            }
            
            {border: 1px solid red;}
        </style>
	</head>
	
	<body>
	    <div class="display-chart">
	        <h1 class="heading chart">REAL TIME PLOT CHART</h1>
            <?php include 'line_chart.php';?>
	    </div>
	    <div class="data-container">
    		<h1 class="heading data">REAL TIME DATA COLLECTION</h1>
    		<table id="tabledata">
    			<tr>
    				<th>TIME</th>
    				<th>DATE</th>
    				<th>MOISTURE CONTENT</th>
    				<th>TEMPERATURE (<sup>o</sup>C)</th>
    				<th>HUMIDITY (%)</th>
    				<th>DAY</th>
    				<th>HOUR</th>
    				<th>Fuzzyfied Time of Irrigation</th>
    			</tr>
    	            
    		    <?php
    			    include ('connect.php');
    			    $sql = "SELECT * FROM data ORDER BY time DESC LIMIT 200"; //Table in database
    			    $result = mysqli_query($connect, $sql);
    			
    		
    			    if (mysqli_num_rows($result) > 0) {
    				// output data of each row
    				    while($row = mysqli_fetch_assoc($result))
    				    {
    				        $time = date_format(date_create($row["TIME"]), 'g:i:s A');
    				        $date = date_format(date_create($row["TIME"]), 'd-m-Y');
    				        
    					    echo "<tr> <td> " . 
    					        $time . "</td> <td> " .
    					        $date . "</td> <td> " .
    					        $row["MOISTURE_CONTENT"]. " </td> <td> " . 
    					        $row["TEMPERATURE"]. " </td> <td>" .
    					        $row["HUMIDITY"]. " </td> <td>" . 
    					        $row["DAY"]. "</td><td>".
    					        $row["HOUR"] . "</td><td>".
    					        $row["Fuzzyfied"] . "</td></tr>";
    				    }
    			    } else {
    				    echo "0 results";
    			    }
    			    mysqli_close($connect);
    		    ?>
    		</table>
		</div>
	</body>
</html>

connect.php

<?php
$hostname = "localhost";
$username = "id5446383_nooryani";
$password = "xxxxxxxxxxxxxxxxxxxx";
$database = "id5446383_smartgreeenspace";  


// Create connection
$connect = mysqli_connect($hostname, $username, $password, $database);

// Check connection
if (!$connect)
{
    die("Connection Failed: " . mysqli_connect_error());
}
//else
//	echo "Connected successfully";
	
?>

add.php


<?php
include('connect.php');


$moist1 = (float) $_POST["s"];
$temp1= (float) $_POST["t"];
$hum1= (float) $_POST["h"];
$day=  $_POST["d"];
$hour=  $_POST["hour"];
$date = date("Y-m-d H:i:s");
$Irrigationtime= (float) $_POST["Irrigationtime"];
    
$query = "INSERT INTO data (TIME, MOISTURE_CONTENT, TEMPERATURE, HUMIDITY, DAY, HOUR, Fuzzyfied) 
          VALUES ('$date', $moist1 , $temp1 , $hum1 , $day , $hour , $Irrigationtime )";
          
//$query_test = "INSERT INTO test (TEMPERATURE) 
          //VALUES ($temp1)";

//echo $query;
mysqli_query($connect, $query);
//mysqli_query($connect, $query_test);
mysqli_close($connect);
//header("Location: data.php");

?>

linechart.php

<?php
include('connect.php');
$query = 'SELECT * FROM data ORDER BY TIME DESC';

$result = mysqli_query($connect, $query);

$rows = array();
$table = array();

$table['cols'] = array( 
    array('label' => 'Date Time', 'type' => 'datetime'),
    array('label' => 'Moisture Content', 'type' => 'number'),
    array('label' => 'Temperature', 'type' => 'number'),
    array('label' => 'Humidity', 'type' => 'number'),
    array('label' => 'Fuzzyfied Time of Irrigation', 'type' => 'number')
);

while($row = mysqli_fetch_array($result))
{
 $sub_array = array();
 $datetime = explode(".", $row["TIME"]);
 $localtime= strtotime($datetime[0]);
 
 //$sub_array[] =  array("v" => 'Date(' .$datetime[0]  . '000)');
 $sub_array[] =  array("v" => 'Date(' . $localtime*1000 . ')');
 $sub_array[] =  array("v" => $row["MOISTURE_CONTENT"]);
 $sub_array[] =  array("v" => $row["TEMPERATURE"]);
 $sub_array[] =  array("v" => $row["HUMIDITY"]);
 $sub_array[] =  array("v" => $row["Fuzzyfied"]);
 $rows[] =  array("c" => $sub_array);
}

$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>

<html>
 <head>
    <title>SmartGreenSpace</title>
	<link rel="icon" type="image/png" href="images/icon.jpg"/>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	<meta http-equiv="refresh" content="300">
	
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawChart);
    
    /*var dateFormatter = new google.visualization.DateFormat({formatType: 'long',timeZone: +0800 });
    dateFormatter.format(data,0);*/
   
    function drawChart()
    {
        var data = new google.visualization.DataTable(<?php echo $jsonTable; ?>);

    var options = 
    {
        title:'Sensors Data',
        legend:{position:'bottom'},
        chartArea:{width:'80%', height:'65%'}
        
    };
    
    /*var view = new google.visualization.DataView(data);
    view.setColumns([0, 1, {
    calc: "stringify",
    sourceColumn: 1,
    type: "string",
    role: "annotation"}]);*/
    
    var chart = new google.visualization.LineChart(document.getElementById('line_chart'));
    chart.draw(data, options);
   }
   
  </script>
  <style>
    .page-wrapper
    {
      width: 1000px;
      margin: 0 auto;
    }

    #line_chart
    {
      width: 120%;
      height: 500px;
      margin-left: -90px;
      margin-top: -20px;
    }

  </style>
 </head>  
 
 <body>
  <div class="page-wrapper">
   <br />
   <div id="line_chart" ></div>
  </div>
 </body>
</html>



#include <Fuzzy.h>
#include <FuzzyComposition.h>
#include <FuzzyInput.h>
#include <FuzzyIO.h>
#include <FuzzyOutput.h>
#include <FuzzyRule.h>
#include <FuzzyRuleAntecedent.h>
#include <FuzzyRuleConsequent.h>
#include <FuzzySet.h>


//including all library
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <Fuzzy.h>

#define BLYNK_PRINT Serial
#define DHTTYPE DHT11     //DHT11
#define moisture_pin A0   //A0
#define REDLED 12 //D6
#define YELLOWLED 13 //D7 
#define dht_dpin 5 //D1       
#define water_pin 0 //D3       
#define fertilizer_pin 4 //D2  
#define WEBSITE "smartgreeenspace.000webhostapp.com" //Website address


String uri = "/add.php"; 
String data;
int moistureValue;
int day = 1;
int hours = 1;
int j=1;
int k=1;
float h;
float t;
DHT dht(dht_dpin , DHTTYPE);
float irrigationtime;
Fuzzy *fuzzy = new Fuzzy();

//Get from BLYNK APP
//Go to project setting (nut icon)
char auth[] = "####################################"; 

//Wifi credentials
//set password to "" for open wifi

//lab agri
char ssid[] = "agriculture";
char pass[] = "#########./";

//char ssid[] = "AndroidAP096F";
//char pass[] = "###########";


BLYNK_WRITE (V2){
  int i = param.asInt();
  if( i == 1 ){
    digitalWrite(water_pin, HIGH);
    Blynk.virtualWrite(V2,HIGH);
    Serial.println("watering");
  }
  else{
    digitalWrite(water_pin, LOW);
    Blynk.virtualWrite(V2,LOW);
  }
}

void setup() {
  // put your setup code here, to run once:
      Serial.begin(115200);
      
      //Initiate FUZZY INPUT
      //SOIL MOISTURE
      FuzzyInput *moisture = new FuzzyInput(1);
      FuzzySet *wet = new FuzzySet(0, 0, 200, 350);
      moisture->addFuzzySet(wet);
      FuzzySet *moist = new FuzzySet(200, 350, 500, 700);
      moisture->addFuzzySet(moist);
      FuzzySet *dry = new FuzzySet(500, 700, 1024, 1024);
      moisture->addFuzzySet(dry);
      fuzzy->addFuzzyInput(moisture);
    
      //TEMPERATURE
      FuzzyInput *temperature = new FuzzyInput(2);
      FuzzySet *cold = new FuzzySet(20, 20, 22 , 26);
      temperature->addFuzzySet(cold);
      FuzzySet *normal = new FuzzySet(22, 26, 33, 37);
      temperature->addFuzzySet(normal);
      FuzzySet *hot = new FuzzySet(33, 37, 40, 40);
      temperature->addFuzzySet(hot);
      fuzzy->addFuzzyInput(temperature);
    
      //HUMIDITY
      FuzzyInput *humidity = new FuzzyInput(3);
      FuzzySet *low = new FuzzySet(0, 0, 40, 60);
      humidity->addFuzzySet(low);
      FuzzySet *modest = new FuzzySet(40, 60, 75, 95);
      humidity->addFuzzySet(modest);
      FuzzySet *high = new FuzzySet(75, 95, 100, 100);
      humidity->addFuzzySet(high);
      fuzzy->addFuzzyInput(humidity);
      
      //Initiate FUZZY OUTPUT
      //WATERPUMP
      // Instantiating a FuzzyOutput objects
      FuzzyOutput *irrigation = new FuzzyOutput(1);
      // Instantiating a FuzzySet object
      FuzzySet *lowpump = new FuzzySet(0, 0, 1000, 1500);
      irrigation->addFuzzySet(lowpump);
      // Instantiating a FuzzySet object
      FuzzySet *mediumpump = new FuzzySet(1400, 180000, 225000, 245000);
      // Including the FuzzySet into FuzzyOutput
      irrigation->addFuzzySet(mediumpump);
      // Instantiating a FuzzySet object
      FuzzySet *highpump = new FuzzySet(240000, 270000, 285000, 300000);
      // Including the FuzzySet into FuzzyOutput
      irrigation->addFuzzySet(highpump);
      // Including the FuzzyOutput into Fuzzy
      fuzzy->addFuzzyOutput(irrigation);
    
      //Fuzzy rules
      //Rules declaration
      FuzzyRuleAntecedent *MoistureDryAndTemperatureCold= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureCold->joinWithAND(dry, cold);
    
      FuzzyRuleAntecedent *MoistureDryAndTemperatureNormal= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureNormal->joinWithAND(dry, normal);
    
      FuzzyRuleAntecedent *MoistureDryAndTemperatureHot= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureHot->joinWithAND(dry, hot);
    
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureCold= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureCold->joinWithAND(moist, cold);
    
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureNormal= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureNormal->joinWithAND(moist, normal);
    
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureHot= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureHot->joinWithAND(moist, hot);
    
      FuzzyRuleAntecedent *MoistureWetAndTemperatureCold= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureCold->joinWithAND(wet, cold);
    
      FuzzyRuleAntecedent *MoistureWetAndTemperatureNormal= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureNormal->joinWithAND(wet, normal);
    
      FuzzyRuleAntecedent *MoistureWetAndTemperatureHot= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureHot->joinWithAND(wet, hot);
    
      /////////////////////////////////////////////////////////////////
      FuzzyRuleAntecedent *HumidityLow = new FuzzyRuleAntecedent();
      HumidityLow->joinSingle(low);
    
      FuzzyRuleAntecedent *HumidityHigh = new FuzzyRuleAntecedent();
      HumidityHigh->joinSingle(high);
    
      FuzzyRuleAntecedent *HumidityModest = new FuzzyRuleAntecedent();
      HumidityModest->joinSingle(modest);
    
      ////////////////////////////////////////////////////////////////////
    
      FuzzyRuleConsequent *thenIrrigationLow = new FuzzyRuleConsequent();
      thenIrrigationLow->addOutput(lowpump);
    
      FuzzyRuleConsequent *thenIrrigationMedium = new FuzzyRuleConsequent();
      thenIrrigationMedium->addOutput(mediumpump);
    
      FuzzyRuleConsequent *thenIrrigationHigh = new FuzzyRuleConsequent();
      thenIrrigationHigh->addOutput(highpump);
      
      
      //Rule 1
    
      FuzzyRuleAntecedent *MoistureDryAndTemperatureColdAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureColdAndHumidityLow->joinWithAND(MoistureDryAndTemperatureCold, HumidityLow);
      FuzzyRule *fuzzyRule1 = new FuzzyRule(1, MoistureDryAndTemperatureColdAndHumidityLow, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule1);
    
      //Rule2
      FuzzyRuleAntecedent *MoistureDryAndTemperatureColdAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureColdAndHumidityHigh->joinWithAND(MoistureDryAndTemperatureCold, HumidityHigh);
      FuzzyRule *fuzzyRule2 = new FuzzyRule(2, MoistureDryAndTemperatureColdAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule2);
    
      
      //Rule3
      FuzzyRuleAntecedent *MoistureDryAndTemperatureColdAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureColdAndHumidityModest->joinWithAND(MoistureDryAndTemperatureCold, HumidityModest);
      FuzzyRule *fuzzyRule3 = new FuzzyRule(3, MoistureDryAndTemperatureColdAndHumidityModest, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule3);
    
      //Rule4
      FuzzyRuleAntecedent *MoistureDryAndTemperatureNormalAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureNormalAndHumidityLow->joinWithAND(MoistureDryAndTemperatureNormal, HumidityLow);
      FuzzyRule *fuzzyRule4 = new FuzzyRule(4, MoistureDryAndTemperatureNormalAndHumidityLow, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule4);
    
      //Rule5
      FuzzyRuleAntecedent *MoistureDryAndTemperatureNormalAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureNormalAndHumidityHigh->joinWithAND(MoistureDryAndTemperatureNormal, HumidityHigh); 
      FuzzyRule *fuzzyRule5 = new FuzzyRule(5, MoistureDryAndTemperatureNormalAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule5);
    
      //Rule6
      FuzzyRuleAntecedent *MoistureDryAndTemperatureNormalAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureNormalAndHumidityLow->joinWithAND(MoistureDryAndTemperatureNormal, HumidityModest);
      FuzzyRule *fuzzyRule6 = new FuzzyRule(6, MoistureDryAndTemperatureNormalAndHumidityModest, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule6);
    
      //Rule7
      FuzzyRuleAntecedent *MoistureDryAndTemperatureHotAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureHotAndHumidityLow->joinWithAND(MoistureDryAndTemperatureHot, HumidityLow);
      FuzzyRule *fuzzyRule7 = new FuzzyRule(7, MoistureDryAndTemperatureHotAndHumidityLow, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule7);
    
      //Rule8
      FuzzyRuleAntecedent *MoistureDryAndTemperatureHotAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureHotAndHumidityHigh->joinWithAND(MoistureDryAndTemperatureHot, HumidityHigh);
      FuzzyRule *fuzzyRule8 = new FuzzyRule(8, MoistureDryAndTemperatureHotAndHumidityHigh, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule8);
    
      //Rules9
      FuzzyRuleAntecedent *MoistureDryAndTemperatureHotAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureDryAndTemperatureHotAndHumidityModest->joinWithAND(MoistureDryAndTemperatureHot, HumidityModest);
      FuzzyRule *fuzzyRule9 = new FuzzyRule(9, MoistureDryAndTemperatureHotAndHumidityModest, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule9);
    
      //Rules10
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureColdAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureColdAndHumidityLow->joinWithAND(MoistureMoistAndTemperatureCold, HumidityLow); 
      FuzzyRule *fuzzyRule10 = new FuzzyRule(10, MoistureMoistAndTemperatureColdAndHumidityLow, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule10);
    
      //Rules11
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureColdAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureColdAndHumidityHigh->joinWithAND(MoistureMoistAndTemperatureCold, HumidityHigh);
      FuzzyRule *fuzzyRule11 = new FuzzyRule(11, MoistureMoistAndTemperatureColdAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule11);
    
      //Rules12
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureColdAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureColdAndHumidityModest->joinWithAND(MoistureMoistAndTemperatureCold, HumidityModest);
      FuzzyRule *fuzzyRule12 = new FuzzyRule(12, MoistureMoistAndTemperatureColdAndHumidityModest, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule12);
    
      //Rules13
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureNormalAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureNormalAndHumidityLow->joinWithAND(MoistureMoistAndTemperatureNormal, HumidityLow);
      FuzzyRule *fuzzyRule13 = new FuzzyRule(13, MoistureMoistAndTemperatureNormalAndHumidityLow, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule13);
    
      //Rules14
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureNormalAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureNormalAndHumidityHigh->joinWithAND(MoistureMoistAndTemperatureNormal, HumidityHigh);
      FuzzyRule *fuzzyRule14 = new FuzzyRule(14, MoistureMoistAndTemperatureNormalAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule14);
    
      //Rules15
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureNormalAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureNormalAndHumidityModest->joinWithAND(MoistureMoistAndTemperatureNormal, HumidityModest);
      FuzzyRule *fuzzyRule15 = new FuzzyRule(15, MoistureMoistAndTemperatureNormalAndHumidityModest, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule15);
    
      //Rules16
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureHotAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureHotAndHumidityLow->joinWithAND(MoistureMoistAndTemperatureHot, HumidityLow);
      FuzzyRule *fuzzyRule16 = new FuzzyRule(16, MoistureMoistAndTemperatureHotAndHumidityLow, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule16);
    
      //Rules17
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureHotAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureHotAndHumidityHigh->joinWithAND(MoistureMoistAndTemperatureHot, HumidityHigh);
      FuzzyRule *fuzzyRule17 = new FuzzyRule(17, MoistureMoistAndTemperatureHotAndHumidityHigh, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule17);
    
      //Rules18
      FuzzyRuleAntecedent *MoistureMoistAndTemperatureHotAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureMoistAndTemperatureHotAndHumidityModest->joinWithAND(MoistureMoistAndTemperatureHot, HumidityModest);
      FuzzyRule *fuzzyRule18 = new FuzzyRule(18, MoistureMoistAndTemperatureHotAndHumidityModest, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule18);
    
      //Rules19
      FuzzyRuleAntecedent *MoistureWetAndTemperatureColdAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureColdAndHumidityLow->joinWithAND(MoistureWetAndTemperatureCold, HumidityLow);
      FuzzyRule *fuzzyRule19 = new FuzzyRule(19, MoistureWetAndTemperatureColdAndHumidityLow, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule19);
    
      //Rules20
      FuzzyRuleAntecedent *MoistureWetAndTemperatureColdAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureColdAndHumidityLow->joinWithAND(MoistureWetAndTemperatureCold,HumidityHigh);
      FuzzyRule *fuzzyRule20 = new FuzzyRule(20, MoistureWetAndTemperatureColdAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule20);
    
      //Rules21
      FuzzyRuleAntecedent *MoistureWetAndTemperatureColdAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureColdAndHumidityModest->joinWithAND(MoistureWetAndTemperatureCold,HumidityModest);
      FuzzyRule *fuzzyRule21 = new FuzzyRule(21, MoistureWetAndTemperatureColdAndHumidityModest, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule21);
    
      //Rules22
      FuzzyRuleAntecedent *MoistureWetAndTemperatureNormalAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureNormalAndHumidityLow->joinWithAND(MoistureWetAndTemperatureNormal, HumidityLow);
      FuzzyRule *fuzzyRule22 = new FuzzyRule(22, MoistureWetAndTemperatureNormalAndHumidityLow, thenIrrigationMedium);
      fuzzy->addFuzzyRule(fuzzyRule22);
    
      //Rules23
      FuzzyRuleAntecedent *MoistureWetAndTemperatureNormalAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureNormalAndHumidityHigh->joinWithAND(MoistureWetAndTemperatureNormal, HumidityHigh);
      FuzzyRule *fuzzyRule23 = new FuzzyRule(23, MoistureWetAndTemperatureNormalAndHumidityHigh, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule23);
    
      //Rules24
      FuzzyRuleAntecedent *MoistureWetAndTemperatureNormalAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureNormalAndHumidityModest->joinWithAND(MoistureWetAndTemperatureNormal, HumidityModest);
      FuzzyRule *fuzzyRule24 = new FuzzyRule(24, MoistureWetAndTemperatureNormalAndHumidityModest, thenIrrigationLow);
      fuzzy->addFuzzyRule(fuzzyRule24);
    
      //Rules25
      FuzzyRuleAntecedent *MoistureWetAndTemperatureHotAndHumidityLow= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureHotAndHumidityLow->joinWithAND(MoistureWetAndTemperatureHot, HumidityLow);
      FuzzyRule *fuzzyRule25 = new FuzzyRule(25, MoistureWetAndTemperatureHotAndHumidityLow, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule25);
    
      //Rules26
      FuzzyRuleAntecedent *MoistureWetAndTemperatureHotAndHumidityHigh= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureHotAndHumidityHigh->joinWithAND(MoistureWetAndTemperatureHot, HumidityHigh);
      FuzzyRule *fuzzyRule26 = new FuzzyRule(26, MoistureWetAndTemperatureHotAndHumidityHigh, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule26);
    
      //Rules27
      FuzzyRuleAntecedent *MoistureWetAndTemperatureHotAndHumidityModest= new FuzzyRuleAntecedent();
      MoistureWetAndTemperatureHotAndHumidityModest->joinWithAND(MoistureWetAndTemperatureHot, HumidityModest);
      FuzzyRule *fuzzyRule27 = new FuzzyRule(27, MoistureWetAndTemperatureHotAndHumidityModest, thenIrrigationHigh);
      fuzzy->addFuzzyRule(fuzzyRule27);
      
      Blynk.begin(auth, ssid, pass);
    
      dht.begin();
    
      Serial.print("Connecting to "+*ssid);
      delay(1000); //1 second
      WiFi.begin(ssid, pass);
       //while (WiFi.status() != WL_CONNECTED) //not connected,  ...waiting to connect
       while (!WiFi.localIP()) //not connected,  ...waiting to connect
        {
          delay(1000); //1 second
          Serial.print(".");
        }
      Serial.println();
      Serial.println("Credentials accepted! Connected to wifi\n ");
      Serial.println();
    
      pinMode(dht_dpin , INPUT);
      pinMode(water_pin, OUTPUT);
      pinMode(fertilizer_pin, OUTPUT);
      digitalWrite(fertilizer_pin, LOW);
      Blynk.virtualWrite(V2,LOW);
      delay(1000);

}

void loop() {
  // put your main code here, to run repeatedly:
  t = dht.readTemperature();
  h = dht.readHumidity();
  Blynk.virtualWrite(V0, h ); // Humidity for gauge
  Blynk.virtualWrite(V1, t ); // Temperature for gauge
  
  soilMoisture();
  Blynk.run();
  
  data = "s=" + String (moistureValue) + "&t=" + String (t) + "&h=" + String (h) + "&d=" + String (day) + "&hour=" + String(hours) + "&Irrigationtime=" + float(irrigationtime);
  Serial.println(data);
  Serial.println(day);
  Serial.println(hours);

  if (j == 1){
    //Serial.println("send data");
    waterPump();
    //sendData();
   
  }
  
  else if ( j == 3600){ //3600
    hours++;
    j = 0;
  }

  if ( k == 1){
    waterPump();
  }
    

  if ( day == 8){
    fertilizer();
    Serial.println("fertilizer");
    day = 1;
  }
  
  if(hours == 25){
    hours = 1;
    day++;
    k = 0;
  }


  j++;
  k++;
  delay(1000); //1000
}


void soilMoisture()
{
        moistureValue = analogRead(moisture_pin);  
        Serial.print("moistureValue Level : ");
        Serial.println(moistureValue);
}

void waterPump(){
    // Set the moisture value as an input
    fuzzy->setInput(1, moistureValue);
    fuzzy->setInput(2, t);
    fuzzy->setInput(3, h);
     // Running the Fuzzification
    fuzzy->fuzzify();
    // Running the Defuzzification
    irrigationtime = fuzzy->defuzzify(1);
    //float irrigationtime2 = irrigationtime/1000;
    //Serial.print("irrigationtime : ");
    //Serial.println(irrigationtime);

    // Serial.print("irrigationtime2 : ");
    //Serial.println(irrigationtime2);
    
    if ( irrigationtime < 1000){
      irrigationtime = 0;
    }
    digitalWrite(water_pin, HIGH);
    Blynk.virtualWrite(V2,HIGH);
    Serial.println("watering");
    delay(180000);
    //delay(1000);
    digitalWrite(water_pin, LOW);
    Blynk.virtualWrite(V2,LOW);
    Serial.println("send data inside irrigation");
    sendData();
}

void fertilizer(){
    digitalWrite(fertilizer_pin, HIGH);
    delay(12000);
    //delay(300);
    digitalWrite(fertilizer_pin, LOW); 
}

void sendData()
{
  //Wifi connection
  WiFiClient client;

  if (client.connect(WEBSITE, 80))
    { 
          Serial.println(data);
          Serial.println("WiFi Client connected. Data sent to website");
          String postRequest =
          "POST " + uri + " HTTP/1.0\r\n" +
          "Host: " + WEBSITE + "\r\n" +
          "Accept: *" + "/" + "*\r\n" +
          "Content-Length: " + data.length() + "\r\n" +
          "Content-Type: application/x-www-form-urlencoded\r\n" + "\r\n" + data;
          client.print(postRequest);
          Serial.println("------------------");
           Serial.println(postRequest);
           Serial.println("------------------");
          delay(1000); //1 second
    } 
   //end client connect
   else Serial.print("Couldnt connect to My Agriculture\n");  //If client connect failed
   client.stop();

Hey @nooryani I can only suggest checking your local setup on what sends it and making sure the request is being sent correctly?

I have used POSTMAN today to send a test request and it seems to have gone through no problems.

Hello sir,

Alright i will check it. Thank you

1 Like

This topic was automatically closed after 13 days. New replies are no longer allowed.