Monitoring of irrigation in agricultural crops, via the internet and mobile phone messages.
This project is ready to use, even at locations out of the electricity grid’s range, as it uses solar panels for its power supply.
Using the SIM900, through the GPRS network, we send the sensor’s data to ThingSpeak IoT platform.
In this project, we monitor a gravity analog water pressure sensor, like the DFROBOT’s SKU SEN0257 https://wiki.dfrobot.com/Gravity__Water_Pressure_Sensor_SKU__SEN0257.
We also are monitoring the voltage of the battery to know the charging condition.
This is the basic function of the project. You could add more sensors depending on what you want to do.
The project aims to save energy by limiting unnecessary trips to control irrigation systems and better management of water resources by identifying any malfunctions from the outset.
In all cases of malfunction, non-operation of the pumps or breakage of the pipes, the first indication is the loss or change in the operating pressure of the irrigation water.
The system in this version monitors the water pressure through a pressure sensor and transmits via the Internet every 10 minutes the pressure value on the ThingSpeak IoT platform (Internet of Things), where through an application for PC or Smartphone we always have a display of the values in a chart.
The Arduino Nano is used as the main processor and the communication via the Internet is done with the SIM900 GPRS shield.
Δυνατότητα παρακολούθησης πολλών αισθητήτρων
Το πρότζεκτ στοχεύει στην εξοικονόμηση ενέργειας περιορίζοντας τις άσκοπες μετακινήσεις για έλεγχο των συστημάτων ποτίσματος και στην καλύτερη διαχείριση των υδάτινων πόρων εντοπίζοντας την οποία δυσλειτουργία από την πρώτη κιόλας στιγμή.
Στο σύνολο των περιπτώσεων δυσλειτουργίας, μη λειτουργίας των αντλιών ή σπασίματος των αγωγών, η πρώτη ένδειξη είναι η απώλεια ή αλλαγή στην πίεση λειτουργίας του νερού ποτίσματος.
Το σύστημα σε αυτή του την έκδοση, παρακολουθεί την πίεση του Νερού μέσω ενός αισθητήρα πίεσης και μεταδίδει μέσω ίντερνετ κάθε 10 λεπτά την τιμή της πίεση στην πλατφόρμα ThingSpeak IoT ( Internet of Things) (διαδίκτυο των πραγμάτων), όπου μέσω εφαρμογής για PC ή Smartphone έχουμε ανά πάσα στιγμή έλεγχο των τιμών σε γράφημα.
Ως κεντρικός επεξεργαστής χρησιμοποιείται το Arduino Nano και η επικοινωνία μέσω ίντερνετ γίνεται με την SIM900 GPRS shield.
Το σύστημα είναι έτοιμο για χρήση ακόμα και σε περιοχές εκτός ηλεκτρικού δικτύου, καθώς τροφοδοτείτε μέσω μπαταρίας 12volt και φόρτιση μέσω ηλιακού πάνελ.
/* /\\\\\\\\\\\ /\\\\\\\\\\\\\\\ /\\\\\\\\\\\ /\\\\\\\\\\\\\\\ /\\\ /\\\ /\\\\\\\\\ /\\\\\ /\\\ /\\\/////////\\\ \/\\\/////////// \/////\\\/// \///////\\\///// \/\\\ \/\\\ /\\\\\\\\\\\\\ \/\\\\\\ \/\\\ \//\\\ \/// \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ /\\\/////////\\\ \/\\\/\\\ \/\\\ \////\\\ \/\\\\\\\\\\\ \/\\\ \/\\\ \/\\\\\\\\\\\\\\\ \/\\\ \/\\\ \/\\\//\\\ \/\\\ \////\\\ \/\\\/////// \/\\\ \/\\\ \/\\\/////////\\\ \/\\\\\\\\\\\\\\\ \/\\\\//\\\\/\\\ \////\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\/////////\\\ \/\\\ \//\\\/\\\ /\\\ \//\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \//\\\\\\ \///\\\\\\\\\\\/ \/\\\\\\\\\\\\\\\ /\\\\\\\\\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \/\\\ \//\\\\\ \/////////// \/////////////// \/////////// \/// \/// \/// \/// \/// \/// \///// */ // ________________________________________________ //---------CREATED BY SEITANIS THANASIS---------\\ //----------------VERSION 12/02/2020--------------\\ //------------------ www.seithan.com ---------------\\ //-----------------seithagta@gmail.com----------------\\ //----------- CODE FOR MONITORING IRRIGATION -----------\\ //---------------- FOR ARGICULTURAL CROPS ----------------\\ //----------- THROUGH INTERNET USING ThinkSpeak ------------\\ /* * Monitoring of irrigation in agricultural crops, via the internet and mobile phone messages. * The project aims to save energy by limiting unnecessary trips to control irrigation systems * and better management of water resources by identifying any malfunctions from the outset, * using the SIM900, through the GPRS network and sending the sensor’s data to ThingSpeak IoT platform. * In this project, we monitor a gravity analog water pressure sensor, like the DFROBOT’s SKU SEN0257 * https://wiki.dfrobot.com/Gravity__Water_Pressure_Sensor_SKU__SEN0257 * and transmit its value via the Internet every 10 minutes * We also are monitoring the voltage of the battery to know the charging condition. * This is the basic function of the project. * You could add more sensors depending on what you want to do */ /* * Copyright (C) 2019 author: THANASIS SEITANIS contact: seithagta@gmail.com * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * * Neither the name of Thanasis Seitanis nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. */ //------END OF COPYRIGHT NOTICE AND DISCLAIMER OF GUARANTEE------\\ /* *********** CONNECTION: ************** * SIM900 RX -> 8 Arduino * SIM900 TX -> 7 Arduino * SIM900 GND -> GND Arduino * SIM900 power supply: If 5V is at list 2A * SIM900 switch in the EXTERNAL position * *********************************************************************** */ #include <SoftwareSerial.h> // softwareserial library to communicate with sim900 #include <String.h> const int GSM_VOLT_PIN = 6; const int PRESPIN = A6; // Pressure sensor pin const int BATTPIN = A7; // Battery Voltage pin const int POWERPIN = 9;// Sim900 power on/off pin const float VBATT_FACTOR = 0.01333; // Factor to scale 0-14V (14/1024=0.01367 in paper) // for the real reading check with a polymeter and GAIN (+/-) float pres = 0.00; // Water Pressure float battVolt = 0.00; // Battery voltage int batt_sensorValue = 0; int pres_sensorValue = 0; unsigned long timer = 0; float all; float mid_all_press; #define RETRY_LOOP 100 // The number of times that it will read the value of any sensor for more accurate reading SoftwareSerial SIM900(7, 8); // pins RX TX sim900 - arduino 7 & 8 void setup() { SIM900.begin(19200); Serial.begin(19200); pinMode(GSM_VOLT_PIN, INPUT); pinMode(PRESPIN, INPUT); //sets the pin as input pinMode(BATTPIN, INPUT); //sets the pin as input pinMode(POWERPIN, OUTPUT);//sets the pin as output digitalWrite(POWERPIN, LOW); delay(1500); if(checkOnOff() == false){ Serial.println("SIM900 IS OFF"); Serial.println("Trying to power on SIM900"); SIM900_powerOnOff(); Wait_Call_Ready(); } if(checkOnOff() == true){ Serial.println("SIM900 IS ON"); } SIM900.flush(); pres = readPressure(); battVolt = readVoltage(); Serial.print("1st Start Battery Voltage: "); Serial.println(battVolt,5); Serial.print("1st Start Water Pressure: "); Serial.println(pres,3); Serial.println("------FIRST SEND START------"); send_to_internet(); // send it to Internet Serial.println("+++++++FIRST SEND END++++++"); timer = millis(); } // All the AT commands can be found in SIM900 documentation void loop() { pres = readPressure(); battVolt = readVoltage(); Serial.print("Battery voltage: "); Serial.println(battVolt,5); Serial.print("Water pressure: "); Serial.println(pres,3); if(readPressure() >= 0.05){ all = 0; for(int i = 0; i < 10; i++){ all = all + readPressure(); delay(1000); } mid_all_press = 0; mid_all_press = all / 10; if(mid_all_press > 0.05 && checkOnOff() == true && (millis() - timer) >= 600000 ){ send_to_internet(); // send it to Internet timer = millis(); }else if(mid_all_press > 0.05 && checkOnOff() == false && (millis() - timer) >= 600000){ SIM900_powerOnOff(); Wait_Call_Ready(); send_to_internet(); timer = millis(); } }else if(readPressure() < 0.05){ all = 0; for(int i = 0; i < 10; i++){ all = all + readPressure(); delay(1000); } mid_all_press = 0; mid_all_press = all / 10; if(mid_all_press < 0.05 && checkOnOff() == true && (millis() - timer) >= 600000){ send_to_internet(); if(readPressure() <= 0.05){ powerOFFsim900(); } timer = millis(); }else if(mid_all_press < 0.05 && checkOnOff() == false && (millis() - timer) >= 3600000){ SIM900_powerOnOff(); Wait_Call_Ready(); send_to_internet(); if(readPressure() <= 0.05){ powerOFFsim900(); } timer = millis(); } } delay(120000);//120000 } void send_to_internet(void) { // sending data via GPRS / prepare module / establish connection SIM900.println("AT"); delay(1000); SIM900.println("AT+CPIN?"); delay(1000); SIM900.println("AT+CREG?"); delay(1000); SIM900.println("AT+CGATT?"); delay(1000); SIM900.println("AT+CIPSHUT"); delay(1000); SIM900.println("AT+CIPSTATUS"); delay(2000); SIM900.println("AT+CIPMUX=0"); delay(2000); ShowSerialData(); SIM900.println("AT+CSTT=\"internet\"");//start task and setting the APN, delay(1000); ShowSerialData(); SIM900.println("AT+CIICR");//bring up wireless connection delay(3000); ShowSerialData(); SIM900.println("AT+CIFSR");//get local IP adress delay(2000); ShowSerialData(); SIM900.println("AT+CIPSPRT=0"); delay(3000); ShowSerialData(); SIM900.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection delay(6000); ShowSerialData(); SIM900.println("AT+CIPSEND");//begin send data to remote server delay(4000); ShowSerialData(); String str1="GET http://api.thingspeak.com/update?api_key=****************&field1=" + String(pres)+"&field2=" + String(battVolt); SIM900.println(str1);//begin send data to remote server delay(4000); ShowSerialData(); SIM900.println((char)26);//sending // End AT command with a ^Z, ASCII code 26 delay(8000);//waitting for reply, important! the time is base on the condition of internet SIM900.println(); ShowSerialData(); SIM900.println("AT+CIPSHUT");//close the connection delay(100); ShowSerialData(); delay(5000); } void ShowSerialData() { //Read and delete - clear the serial buffer while(SIM900.available()!=0) Serial.write(SIM900.read()); } float readPressure() { //calibrating and reading the pressure value float pres2 = 0.00; uint32_t adc_val = 0; for(int i = 0; i < RETRY_LOOP; i++){ adc_val += analogRead(PRESPIN); // at adc_val, it adds the value of analogRead(PRESPIN) // as long as the number of times are less than the RETRY_LOOP delay(1); } pres_sensorValue =(adc_val / RETRY_LOOP); // it calculates the average value of ProbeOne adc_val = 0; float presVoltage= pres_sensorValue * 5.00000 / 1024; //Serial.print(presVoltage,5);/ float OFFSET = 0.4834; const int PRESS_FACTOR = 3; pres2 = (presVoltage - OFFSET) * PRESS_FACTOR; return pres2; } float readVoltage() { //calibrating and reading the voltage value float battVolt2 = 0.00; uint32_t adc_val = 0; // 32-bit variable used for adding up analogRead of any sensor (Voltage and Temperture). Average values for more accurate reading for(int i = 0; i < RETRY_LOOP; i++){ adc_val += analogRead(BATTPIN); // at adc_val, it adds the value of analogRead(ANALOG_PIN_TWO) as long as the number of times are less than the RETRY_LOOP delay(1); } batt_sensorValue = (adc_val / RETRY_LOOP); // it calculates the average value of ProbeTwo battVolt2 = batt_sensorValue * VBATT_FACTOR; // Convert the analog reading sensor value which goes from 0 - 1023 to a voltage scale of 0 - 14V: return battVolt2; } void SIM900_powerOnOff() { // power on or off the SIM900 module through the digital pin 9 (D9) digitalWrite(POWERPIN, HIGH); delay(2000); digitalWrite(POWERPIN, LOW); delay(1000); //<--------------------maybe higher value needed to test the module start time } boolean checkOnOff() { //checking either if the SIM900 is on or off through the digital pin 6 (D6), which is connected to a 2.8V output pin on SIM900 module if(digitalRead(GSM_VOLT_PIN) == HIGH){ Serial.println("SIM900 IS ALREADY ON. 2.8V PRESENTED"); return true; }else{ Serial.println("SIM900 IS OFF. 2.8V NOT PRESENTED"); return false; } } void powerOFFsim900() { //sim900 power off with AT command SIM900.flush(); SIM900.println("AT+CPOWD=1"); delay(1000); if(SIM900.find("POWER DOWN") == true){ Serial.println("SIM900 NORMAL POWER DOWN"); delay(2000); } if(checkOnOff() == true){ delay(5000); if(checkOnOff() == true){ SIM900_powerOnOff(); Serial.println("SIM900 MANUAL POWER DOWN"); } if(checkOnOff() == false){ Serial.println("POWER DOWN SUCCESFUL"); }else{ Serial.println("POWER DOWN FAILURE"); } } } void Wait_Call_Ready() { // Wait for the Module sim900 to powered ON and finish the initialization procedure (Call Ready) int i = 0; while(SIM900.available() > 0){ if(SIM900.find("Call Ready") == true){ Serial.println("CALL READY IS FOUND"); break; } delay(3500); if(i == 10){ Serial.println("CALL READY IS NOT FOUND"); break; } i++; } }
The .zip file contains:
290
times.