devancakra / Aquaponic-pH-Control-Monitoring-with-Type-2-Fuzzy-Method-Based-on-IoT-Bot

UPN Veteran Jatim | Aquaponic pH Control-Monitoring with Type-2 Fuzzy Method Based on IoT Bot | S1 Thesis Project

Home Page:https://www.youtube.com/watch?v=yWIjs6XYV9M

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Open Source Love License: MIT GitHub last commit Thesis-Project

Aquaponic-pH-Control-Monitoring-with-Type-2-Fuzzy-Method-Based-on-IoT-Bot

Undergraduate Thesis Project Documentation (S1) - Informatics UPN Veteran Jatim

Aquaponic system is a combined farming system between fish with vegetables where the activities are mutually beneficial. On the other hand, crop failure can also be a concern for aquaponic farmers as this can happen at any time. Harvest failure can be influenced by many factors, but is usually caused by the high pH ambiguity of the water around the scope of cultivation. The aquaponic farmers are worried that if the crop failure continues it will have a negative impact on their food security. This project was created in the hope of solving the pH problem. This project has been carried out and took approximately 1 year. The system created can control and monitor changes in water pH at any time. This system is based on the Internet of Things (IoT), using MQTT as the communication protocol. This system is also equipped with artificial intelligence, which uses IT2FL (Interval Type-2 Fuzzy Logic) as its decision support. In addition, the system interface uses Telegram Bot, making it easier for users to interact.



Project Requirements

Part Description
Development Board DOIT ESP32 DEVKIT V1
Supporting Board Arduino Uno R3
Code Editor Arduino IDE
Application Support • Telegram Bot
• Matlab R2020
Driver CP210X USB Driver
IoT Platform io-t.net
Communications Protocol • Inter Integrated Circuit (I2C)
• Message Queuing Telemetry Transport (MQTT)
• MTProto
IoT Architecture 4 Layer
Matlab Fuzzy Interface System
Programming Language C/C++
Arduino Library • WiFi (default)
• Wire (default)
• PubSubClient
• LiquidCrystal_I2C
• CTBot
• ArduinoJson
• RTClib
Actuators • Submersible pump aquarium (x1)
• Pneumatic solenoid valve (x2)
• Piezoelectric (x1)
Sensor • pH Sensor (x1)
• RTC (x1)
Display LCD I2C (x1)
Experimental Object • Pakcoy mustard seeds
• Dumbo catfish fry
Other Components • Micro USB cable - USB type A (x1)
• Jumper cable (1 set)
• Switching power supply 12V 1A (x1)
• Electrical relay 2 channel (x1)
• Round switch (x1)
• ESP32 expansion board (x1)
• PCB Dot Matrix (x1)
• Terminal PCB block screw (x10)
• Socket female jack DC (x1)
• Connector male jack DC (x3)
• Probe Elektroda pH (x1)
• Pipes (1 set)
• Netpot (1 set)
• Rockwool (1 set)
• Flannel fabric (1 set)
• Water filter (x1)
• Glass hubcap (1 set)
• Bottle (x2)
• Aquarium wheeled placemat (x1)
• Aquarium (x1)
• Casing box (x1)
• Skun (1 set)
• Galvanized plate (x1)
• Bolts plus (1 set)
• Nuts (1 set)



Download & Install

  1. Arduino IDE

    https://www.arduino.cc/en/software
    

  2. CP210X USB Driver

    https://bit.ly/CP210X_USB_Driver
    

  3. Matlab R2020

    https://bit.ly/Matlab_R2020a_Installer
    



Project Designs

Pictorial Diagram Prototype Design Main Box Design
Pictorial-Diagram Prototype-Design MainBox-Design
Fuzzy Interface System IT2FL IT2FL Input Variable IT2FL Output Variable
FIS-IT2FL VarIn-IT2FL VarOut-IT2FL



Scanning the I2C Address on the LCD

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(115200);
  while (!Serial); // Wait for serial monitor
  Serial.println("\nI2C Scanner");
}

void loop() {
  int nDevices = 0;
  Serial.println("Scanning...");

  for (byte address = 1; address < 127; ++address) {
    // The i2c_scanner uses the return value of the Wire.endTransmission
    // To see if a device did acknowledge to the address
    Wire.beginTransmission(address);
    byte error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.print(address, HEX);
      Serial.println("  !");

      ++nDevices;
    } else if (error == 4) {
      Serial.print("Unknown error at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.println(address, HEX);
    }
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  } else {
    Serial.println("done\n");
  }
  delay(5000); // Wait 5 seconds for next scan
}


pH Sensor Calibration

The pH sensor can be calibrated using the results of a linear regression calculation. You can see the linear regression equation as follows.

I Persamaan-I

Explanation of the symbols in equation I, you can see more details in the following table.

Symbol Description
𝑌 pH buffer value
𝑋 voltage value obtained based on Y
𝑎 and 𝑏 linear regression determination value

The linear regression determination values (a and b) can be obtained through equations II and III.

II Persamaan-II
III Persamaan-III

Example of pH sensor calibration: Click Here



RTC Sensor Calibration

This RTC sensor can be calibrated using the following program code :

#include <RTClib.h> // Calling the RTC library
RTC_DS3231 rtc; // Constructor

void setup(){
   RTCinit(); // Calling the RTCinit method
}

void loop(){}

void RTCinit(){
   // Starting up the RTC
   rtc.begin();

   // DateTime Setting
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

   // Set Time Now
   // If calibrated, please close with a comment
   rtc.adjust(DateTime(YYYY,MM,DD,HH,MM,SS));
}


Arduino IDE Setup

  1. Open the Arduino IDE first, then open the project by clicking File -> Open :

    PH_IT2FL.ino


  2. Fill in the Additional Board Manager URLs in Arduino IDE

    Click File -> Preferences -> enter the Boards Manager Url by copying the following link :

    https://dl.espressif.com/dl/package_esp32_index.json
    

  3. Board Setup in Arduino IDE

    How to setup the DOIT ESP32 DEVKIT V1 board

    • Click Tools -> Board -> Boards Manager -> Install esp32.

    • Then selecting a Board by clicking: Tools -> Board -> ESP32 Arduino -> DOIT ESP32 DEVKIT V1.

    Arduino Uno board in this project is only used as a filter or voltage divider.

    • You don't need to configure the Arduino Uno board, just focus on the ESP32.


  4. Change the Board Speed in Arduino IDE

    Click Tools -> Upload Speed -> 115200


  5. Install Library in Arduino IDE

    Download all the library zip files. Then paste it in the: C:\Users\Computer_Username\Documents\Arduino\libraries


  6. Port Setup in Arduino IDE

    Click Port -> Choose according to your device port (you can see in device manager)


  7. Change the WiFi Name, WiFi Password, and so on according to what you are currently using.

  8. Before uploading the program please click: Verify.

  9. If there is no error in the program code, then please click: Upload.

  10. Some things you need to do when using the ESP32 board :

    Arduino IDE information: Uploading... -> immediately press and hold the BOOT button.

    Arduino IDE information: Writing at .... (%) -> release the BOOT button.

    • Wait until the message appears: Done Uploading -> The program is directly operated.

    • Press the EN (RST) button and then Restart to handle the ESP32 board that cannot process the SC.

    • Do not press the BOOT and EN buttons at the same time as this may switch to Upload Firmware mode.


  11. If there is still a problem when uploading the program, then try checking the driver / port / others section.



Io-t.net Setup

  1. Getting started with io-t.net :

    • Go to the official website at the following link : io-t.net.

    • If you do not have an account, please Register first -> activate your account via email.

    • If you already have an account, please Sign In to be able to access io-t.net services.


  2. Create a node :

    • Go to Instance menu -> Set Node.

    • Then give the node a unique name that you use.


  3. Create a device :

    • Go to Devices menu.

    • Select Add Devices -> fill in the Client ID, Access, Topic sections as needed. For example :

    • Client ID -> Phiotnet_v1.

    • Access -> Publish & Subscribe.

    • Topic -> detect.



Telegram Bot Setup

  1. Open @BotFather.

  2. Type /newbot.

  3. Type the desired bot name, for example: phiotnet_bot.

  4. Type the desired bot username, for example: phiotnet_bot.

  5. Also do it for bot image settings, bot descriptions, and so on according to your needs.

  6. Copy your telegram bot API token -> then paste it into the #define BOTtoken "YOUR_API_BOT_TOKEN" section.

    For example :

    #define BOTtoken "2006772150:AAE6Fdjk3KbiySkzV6CLbd6ClJDzgTfJ5y0"



Matlab Setup

  1. Open the Matlab.

  2. Open the Set Path dialog box using the command :

    pathtool
    

    set-path-matlab

  3. Select Add Folder... -> search the FIS-IT2FLS-Toolbox-MATLAB folder -> Select Folder.

  4. Click Save and then click Close.

  5. Open the IT2FL Toolbox using the command :

    fuzzyt2
    

    it2fl-toolbox

  6. The rest you can customize according to your needs.



Get Started

  1. Download and extract this repository.

  2. Make sure you have the necessary electronic components.

  3. Make sure your components are designed according to the diagram.

  4. Configure your device according to the settings above.

  5. Please enjoy [Done].



Demonstration of Application

Via Telegram: @phiotnet_bot



Highlights

Product IT2FL Decision Support System Telegram Bot
Product IT2FL-SPK Telegram-Bot

More information:

• Undergraduate Thesis: Click Here

• SINTA-type journals: Click Here

• Non SINTA-type journals: Click Here



Disadvantages

  1. Hardware:

    • Electrical leakage current is caused by the use of non-standard PSU or the lack of insulators used.

    • Lack of air circulation in the main box can cause heat.

    • NO (Normally Open) applied to the relay causes the solenoid valve to become hot.

    • The lack of electric current causes the LCD to not power on.

    • The use of Arduino Uno as a filter or voltage divider is considered inefficient.

    • The pH sensor probe has no protection.


  2. Firmware:

    • The delay time in each method is considered excessive, it should use the millis() function so as not to interfere with other methods.

    • The use of io-t.net is considered not maximal because it is known that its use is just limited to publish.

    • The security features on telegram bots are not good.


  3. Others:

    • Filling gallons of pH and giving AB Mix is still done manually, making it difficult for users.

    • Fish feeding is still done manually.

    • Pakcoy mustard greens lack regular sunlight intake, so after transplanting the land, its development is not as fast as before.

    • Draining and filling the aquarium water is still done manually, making it very inconvenient for users.



Advantages

• The system interface is through a telegram bot, so that giving orders as well as monitoring efforts can be done anytime and anywhere.

• With IT2FL, the accuracy of the sensor becomes more accurate.

• The system can automatically make its own decisions and can also be manually controlled by the user.

• The system has been equipped with a timing feature.



In the Future

• Need for increased amperage. You can use a 3A PSU.

• Need to change the NO (Normally Open) to NC (Normally Close) on the relays so that the electrified device can avoid damage.

• Need for voltage and current sharing. You can use a step down.

• Need for increased the security features of telegram bots.

• Need for increased security on the pH sensor.

• Need for the addition of pH tank re-fill devices and AB mix tanks that are made automatically.

• Need for additional devices that can measure water temperature and ammonia.

• Need for additional devices in automatic fish feeding.

• Need for additional devices that can emit warm light as a substitute for sunlight.

• Need for additional devices that can drain and fill aquarium water.

• Need for additional devices that can optimally cool the main box.

• The existing hydroponic planting field in this study may need to be developed further in the future. In addition, rockwool planting media can be replaced with other planting media that are more adequate for plant needs, for example: husk charcoal or cocopeat.



Appreciation

If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ⭐Star button at the top of the repository.



Disclaimer

This application has been created by including third-party sources. Third parties here are service providers, whose services are in the form of libraries, frameworks, and others. I thank you very much for the service. It has proven to be very helpful and implementable.



LICENSE

MIT License - Copyright © 2020 - Devan C. M. Wijaya, S.Kom

Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:

The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.

IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.

About

UPN Veteran Jatim | Aquaponic pH Control-Monitoring with Type-2 Fuzzy Method Based on IoT Bot | S1 Thesis Project

https://www.youtube.com/watch?v=yWIjs6XYV9M

License:MIT License


Languages

Language:C++ 100.0%